funcool

A channel for discussing and asking questions about Funcool libraries https://github.com/funcool/
2015-10-21T15:10:40.000012Z

heyo, is there any existing sugar for (m/fapply (m/fmap curried+ (just 1)) (just 2) (just 3)), i.e. being able to write (some-sugar curried+ (just 1) (just 2) (just 3))?

2015-10-21T15:10:58.000013Z

essentially, idiom brackets from the original applicative paper

tcsavage 2015-10-21T16:13:31.000014Z

Doesn’t look like it but one could probably write a simple macro wrapping alet

tcsavage 2015-10-21T16:24:00.000015Z

Would something like this do the trick?

(defmacro idiom
  [f & as]
  (let [args (map (fn [x] [(gensym) x]) as)]
    `(m/alet [~@(apply concat args)]
      (~f ~@(map first args)))))

2015-10-21T18:50:15.000018Z

yep, that looks reasonable. I was mainly wondering if there was such a thing hidden in the library already.

2015-10-21T18:53:54.000019Z

(defn ap [f arg & args]
  (apply m/fapply (m/fmap f arg) args))

2015-10-21T20:01:05.000022Z

we can currently lift a function to a monadic context with lift-m and we're working on a lift-a version https://github.com/funcool/cats/pull/113

2015-10-21T20:02:34.000024Z

for the moment you can wrap alet as tcsavage suggests

2015-10-21T20:03:49.000025Z

@blendmaster: the ap combinator could be a great addition to cats

2015-10-21T20:18:20.000026Z

I like it semantically, but it could certainly use some syntax bikeshedding

2015-10-21T20:18:48.000027Z

See https://ocharles.org.uk/IdiomBrackets.html for haskell and https://github.com/aztek/scala-workflow for scala

2015-10-21T21:35:03.000029Z

thanks for the references, i'll look into those

2015-10-21T21:36:10.000030Z

we've tried to design the sugar (`mlet` and alet) to be idiomatic