This is the fault of the dreaded Monomorphism restriction. Basically, because you didn't specify a type for m
, GHCi guesses it for you. In this case, it guesses that m
should have the type [()] -> ()
, even though that is clearly not what you want. Just give m
a type signature in GHCi
and you'll be fine.
> :set +m -- multiline expressions, they're handy
> let m :: Ord a => [a] -> a
| m = head . sort
You can disable the Monomorphism restriction with
> :set -XNoMonomorphismRestriction
But it's usually pretty handy, otherwise you have to specify lots of types for things that you normally wouldn't in interactive mode.