
"Nicola Paolucci"
Hi All,
I'm loving learning Haskell quite a bit. It is stretching my brain but in a delightfull way.
I've googled, I've hoogled but I haven't found a clear explanation for what exactly liftM2 does in the context below.
Using the cool lambdabot "pointless" utility I found out that:
\x -> snd(x) - fst(x)
is the same as:
liftM2 (-) snd fst
I like the elegance of this but I cannot reconcile it with its type. I can't understand it. I check the signature of liftM2 and I get:
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 am sure if I get this I'll be another step closer to illumination ...
Does typing :t liftM2 (-) snd into ghc enlighten you at all? -- Jón Fairbairn Jon.Fairbairn@cl.cam.ac.uk