[Haskell-cafe] Should "do 1" compile

Stefan Holdermans stefan at cs.uu.nl
Wed May 23 13:46:31 EDT 2007


Neil,

> As discussed on #haskell, the following code:
>
> ----------------
> module Foo where
> foo = do (1 :: Int)
> ----------------
>
> Compiles fine on Yhc, but doesn't on Hugs and GHC.

> So the question is, who is right? Where do the bugs need filing? Does
> this issue need clarifying for Haskell' ?

Well, the Report (Sec. 3.14) states that, for any expression e,

   do {e}

should be translated to

   e.

So

   foo = do (1 :: Int}

should be translated to

   foo = (1 :: Int)

which seems type correct to me.

However, although the Report does not state it explicitly, I think it  
was the intention of the language designers to always associate a do- 
block with a particular monad. So, maybe this should be stated (in  
some form) in the Report for Haskell'.

Cheers,

   Stefan


More information about the Haskell-Cafe mailing list