Fork me on GitHub
#funcool
<
2016-03-03
>
nha12:03:50

At the end of http://funcool.github.io/cats/latest/#applicative there is :

(require '[cats.monad.maybe :as maybe])

(pure maybe/maybe-monad 5)
;; => #<Just 5>
has maybe-monad been removed ?

nha12:03:43

Also, unrelated but I asked a question there : http://stackoverflow.com/q/35770498/1327651

nha13:03:33

also, why do these don't work, given that (just [1 2 3]) is a wrapped value ?

(fmap inc (just [1 2 3]))
(fmap inc (map just [1 2 3]))

dialelo16:03:15

@nha: i suspect that docs are out of sync, i believe it was renamed to maybe-context

nha16:03:05

Probably a doc thing, yes.

nha16:03:11

I don't see maybe-context though

nha16:03:25

Ah thanks simple_smile

dialelo16:03:36

and about the mapping

dialelo16:03:48

take into account that fmap "peels" one layer of monadic context

dialelo16:03:02

so in the example

(fmap inc (just [1 2 3]))

dialelo16:03:13

will try to apply inc to [1 2 3]

dialelo16:03:14

thus failing

nha16:03:22

ah I see. (inc [ 1 2 3])

dialelo16:03:26

you can combine maybe and sequence functors

dialelo16:03:37

and map over nested vectors inside maybe or viceversa

dialelo16:03:49

although having many layers can get hairy

dialelo16:03:04

(fmap #(map inc %) (just [1 2 3])) may be simpler

nha16:03:49

Right thanks simple_smile

nha16:03:58

just out of curiosity (as I think I remember you do scala), is there an equivalent of their flatten that resolves async values (note : I don't do scala so I may be wrong about that)

dialelo17:03:25

you mean for example transforming Future[A] into A?

dialelo17:03:45

in Clojure you can dereference futures and the thread will block until available (timeout is optional)

dialelo17:03:56

(deref some-future)