[Haskell-cafe] Re: Well-typed functions with nonexisting signatures [Was: type variable question]

apfelmus at quantentunnel.de apfelmus at quantentunnel.de
Sat Dec 16 07:43:10 EST 2006

oleg at pobox.com wrote:
>> Is there a canonical example example that exhibits this behavior?
> Yes, it was discussed back in 2003. Here's the canonical form:
> g::(Show a,Show b) => a->b
> g = undefined
> --h :: Show a => b -> a
> h x = g(h x)
> Both Hugs and GHC (in the pure Haskell98 mode!) are happy with h. 
> Both compilers infer the type for h, shown in the comment. If you give
> h the type signature -- the one that is inferred by the compilers
> themselves -- both compilers complain.

Strangely, ghci accepts it on the command line:

$ ghci
  GHC Interactive, version 6.4.2, for Haskell 98.
Prelude> let g :: (Show a, Show b) => a -> b; g = undefined; h :: Show a
=> b -> a; h x = g (h x) in h 1
*** Exception: Prelude.undefined

but not from a file to be loaded. Hugs +98 does not accept it on command
line as expected. What's going on?


More information about the Haskell-Cafe mailing list