#1537: do notation translation
----------------------------------------+-----------------------------------
    Reporter:  Isaac Dupree             |        Owner:             
        Type:  bug                      |       Status:  new        
    Priority:  normal                   |    Milestone:  6.10 branch
   Component:  Compiler (Type checker)  |      Version:  6.7        
    Severity:  normal                   |   Resolution:             
    Keywords:                           |   Difficulty:  Unknown    
          Os:  Unknown                  |     Testcase:  rebindable8
Architecture:  Unknown                  |  
----------------------------------------+-----------------------------------
Changes (by mnislaih):

  * testcase:  => rebindable8

Old description:

> Really there are two things:
>
> Normally, (do True) fails to compile in GHC because there is no Monad
> Bool, whereas Haskell-98 translates it to (True).
>
> With `-fno-implicit-prelude`, ( according to
> http://comonad.com/reader/2007/parameterized-monads-in-haskell/ ):
>
> """
> Caveat: It appears that GHC enforces the fact that the arguments and
> results of (>>=) must have a signature like
>
> (>>=) :: forall m a. (...) => m a -> (a -> m b) -> m b
>
> insofar as when you use the do-sugar, your types will not be able to
> vary. Ideally it should be able to get by with a more liberal signature,
> but it seems like no one has needed it before now.
> """
>
> I think do-notation will be the simplest sugar (from one point of view at
> least) when it just translates to (>>=), (>>), fail, and let..in.. as
> specified in Haskell98 (or non-Prelude-qualified when `-fno-implicit-
> prelude`, of course).
>
> It appears #303 was an older similar problem.  Also, maybe the behavior
> (in the new version) should be explicitly documented somewhere in the
> User's Guide.

New description:

 &
 Really there are two things:

 Normally, (do True) fails to compile in GHC because there is no Monad
 Bool, whereas Haskell-98 translates it to (True).

 With `-fno-implicit-prelude`, ( according to
 http://comonad.com/reader/2007/parameterized-monads-in-haskell/ ):

 """
 Caveat: It appears that GHC enforces the fact that the arguments and
 results of (>>=) must have a signature like

 (>>=) :: forall m a. (...) => m a -> (a -> m b) -> m b

 insofar as when you use the do-sugar, your types will not be able to vary.
 Ideally it should be able to get by with a more liberal signature, but it
 seems like no one has needed it before now.
 """

 I think do-notation will be the simplest sugar (from one point of view at
 least) when it just translates to (>;=), (>>), fail, and let..in.. as
 specified in Haskell98 (or non-Prelude-qualified when `-fno-implicit-
 prelude`, of course).

 It appears #303 was an older similar problem.  Also, maybe the behavior
 (in the new version) should be explicitly documented somewhere in the
 User's Guide.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1537#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to