Re:Monadic lifting in C++
by coolsunglasses on Monday March 10, 2014 @04:04AM
(#7371776)
Speaking as a Haskell user:
Maybe chaining is just sequencing functions against results with bind.
Lifting is a general concept that is applicable to functors, applicatives, monads, etc.
--> signifies the result of the computation
fmap (+1) [0, 1, 2] --> [1, 2, 3]
map (+1) [0, 1, 2] --> [1, 2, 3]
fmap (+1) (Just 2) --> Just 3
In the above examples, fmap (from the Functor typeclass, polymorphic) and map (monomorphic function for mapping functions over lists) are lifting the functions they are passed.There's a little bit of regrettable redundancy in Haskell's typeclasses, fmap, liftA, and liftM (functor, applicative, monad) all the same thing.
But liftM, while relevant to monads, isn't >>=, which is bind. bind being what's relevant to Maybe chaining (just using >>= against Maybe values).
I worked on a toy example for this before.
http://stackoverflow.com/questions/7690864/haskell-style-may...
http://stackoverflow.com/questions/9692630/implementing-hask...