[Haskell-beginners] Is this MR? Type restriction confusion

Mike Erickson mike.erickson at gmail.com
Thu Dec 17 17:56:13 EST 2009

I was trying to convert a function,

f1 x l = map (\y -> y*x) l

to so-called point-free style, but in reducing it I found two
functions that seemed to work the same, until I discovered they have
different types, and aren't equivalent:

f1a x = map (*x) -- has type (Num a) => a -> [a] -> [a]

f1b = \x -> map (*x) -- has type Integer -> [Integer] -> [Integer]

Can someone help me understand why the latter has a more restrictive type?

If I add the type signature "f1b :: (Num a) => a -> [a] -> [a]", they
are once again equivalent, but am confused about what's going on. If
this is MR, what exactly am I overloading here?

I read through http://www.haskell.org/haskellwiki/Monomorphism_restriction
and http://www.cs.auckland.ac.nz/references/haskell/haskell-intro-html/pitfalls.html.
If anyone has a good reading recommendation here, I'd love to see it.
Because if this is MR, I'm not understanding what MR is correctly.
Also, They don't generate a type error, which makes me think it is not
MR, but something else.



More information about the Beginners mailing list