3 ms·
Is Maybe chaining the same as lifting? I worked on a toy example for this before. http://stackoverflow.com/questions/7690864/haskell-style-maybe-type-chaining
by zrb 13y ago
Is Maybe chaining the same as lifting?
I worked on a toy example for this before.
http://stackoverflow.com/questions/7690864/haskell-style-maybe-type-chaining-in-c11 http://stackoverflow.com/questions/7690864/haskell-style-may...
http://stackoverflow.com/questions/9692630/implementing-haskells-maybe-monad-in-c11 http://stackoverflow.com/questions/9692630/implementing-hask...
- coolsunglasses 13y agoSpeaking 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).