[Haskell-beginners] Pointfree expeiments

Paul Sargent psarge at gmail.com
Wed Nov 24 20:44:43 EST 2010

I'd been playing with pointfree, looking at what certain patterns transformed into, and I came across this:

   pauls at Mudskipper> pointfree -v "\x -> x + x"                                  ~
   Transformed to pointfree style:
   ap (+) id
   Optimized expression:
   ap (+) id
   join (+)

Basically I wanted to see what happened when you used a parameter multiple times within a function.

Intrigued by this, I did the following:

   Prelude Control.Monad> :t ap (+) id
   ap (+) id :: (Num a, Monad ((->) a)) => a -> a

I'm aware that 'ap' is related the liftM, but what is this monad, and why are we working in a monad at all?

...and surely this isn't the same as the original code as we now have a different type signature?

More information about the Beginners mailing list