Quoth Nicola Paolucci, nevermore:

Prelude> :t liftM2
Prelude> liftM2 :: (Monad m) => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r

Can someone help me understand what's happening here ?
What does a Monad have to do with a simple subtraction ?
What is actually the "m" of my example ?

I'm honestly not sure what the actual Monad m is in this case. I'm sure some enlightened individual will help us out. Maybe Identity?

But I thought you might find this handy --- the interactive console will give you the type of whole expressions, not just bare functions. It can be pretty helpful when trying to decode typery.

:t liftM2
liftM2 :: (Monad m) => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r
:t liftM2 (-)
liftM2 (-) :: (Num a1, Monad m) => m a1 -> m a1 -> m a1
:t liftM2 (-) snd
liftM2 (-) snd :: (Num b) => ((a, b) -> b) -> (a, b) -> b
:t liftM2 (-) snd fst
liftM2 (-) snd fst :: (Num a) => (a, a) -> a

Cheers,

D.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to