2 ms·
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
by coolsunglasses 13y ago
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).