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))
?
essentially, idiom brackets from the original applicative paper
Doesn’t look like it but one could probably write a simple macro wrapping alet
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)))))
yep, that looks reasonable. I was mainly wondering if there was such a thing hidden in the library already.
(defn ap [f arg & args]
(apply m/fapply (m/fmap f arg) args))
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
for the moment you can wrap alet
as tcsavage suggests
@blendmaster: the ap
combinator could be a great addition to cats
I like it semantically, but it could certainly use some syntax bikeshedding
See https://ocharles.org.uk/IdiomBrackets.html for haskell and https://github.com/aztek/scala-workflow for scala
thanks for the references, i'll look into those
we've tried to design the sugar (`mlet` and alet
) to be idiomatic