Java-like

Ben Rudiak-Gould Benjamin.Rudiak-Gould at cl.cam.ac.uk
Tue Feb 7 15:21:56 EST 2006


Bulat Ziganshin wrote:
> {-# OPTIONS_GHC -fglasgow-exts #-}
> main = do return "xx" >>= ((\x -> print x) :: Show a => a -> IO ())
> main2 = do return "xx" >>= (\(x:: (forall a . (Show a) => a)) -> print x)
> main3 = do (x :: forall a . Show a => a) <- return "xx"
>            print x
> 
> in this module, only "main" compiles ok

The other two need "exists" rather than "forall", which isn't supported by 
GHC. As written, they say that x can produce a value of any type that's an 
instance of Show, but the value you're binding to x has type String, which 
can only produce a value via Show String.

-- Ben



More information about the Haskell-prime mailing list