[Haskell-beginners] GHC: missing "No instance for ..." errors without the monomorphism restriction

Máté Kovács mkovaxx at gmail.com
Sun Mar 25 17:34:45 CEST 2012


Hi guys,

Give the following code:

================

module Main where

class C a where

bar :: C a => a -> a
bar x = x

foo = bar bar

main = do
  putStrLn "hello"

================

GHC says "No instance for (C (a0 -> a0)) arising from a use of `bar'",
which is what I would normally expect.
But with -XNoMonomorphismRestriction, it compiles without even a
warning, as long as I don't use `foo' somewhere.

Could someone please explain why this is so?

Thanks,
Máté



More information about the Beginners mailing list