[Haskell-cafe] Beginner question
Benjamin Bach
benjaoming at gmail.com
Fri Jan 2 11:57:48 EST 2009
Supposing I have the following code:
> module Main(main) where
> main = putStr (show [])
I will get these errors from GHC and Hugs respectively:
> Main.hs:2:16:
> Ambiguous type variable `a' in the constraint:
> `Show a' arising from a use of `show' at Main.hs:2:16-22
> Probable fix: add a type signature that fixes these type variable(s)
> ERROR "src/Main.hs":2 - Unresolved top-level overloading
> *** Binding : main
> *** Outstanding context : Show b
But if I change my code to the following, it will compile.
> module Main(main) where
> main = putStr (show [1])
I have no problems typing in "putStr (show [])" in Hugs... runs fine.
So what's wrong? I've really tried hard to think of an explanation,
but with no luck..
Thanks,
Benjamin
More information about the Haskell-Cafe
mailing list