#303: Rebindable syntax doesn't work as advertised
-------------------------------------+--------------------------------------
 Reporter:  nobody                   |          Owner:  nobody   
     Type:  bug                      |         Status:  closed   
 Priority:  normal                   |      Milestone:           
Component:  Compiler (Type checker)  |        Version:  6.8.3    
 Severity:  normal                   |     Resolution:  duplicate
 Keywords:                           |     Difficulty:  Unknown  
 Testcase:  rebindable/T303          |   Architecture:  Unknown  
       Os:  Unknown                  |  
-------------------------------------+--------------------------------------
Changes (by simonpj):

  * testcase:  => rebindable/T303
  * difficulty:  => Unknown
  * status:  reopened => closed
  * resolution:  => duplicate

Old description:

> {{{
> --
> -- According to section 7.3.5. Rebindable syntax in the
> user's manual
> -- this should work (unless I totally misunderstood it).
> -- It doesn't.
> --
> -- Compile with -fno-implicit-prelude
> --
> --     Lennart
> --
>
> import Prelude hiding(Monad(..))
>
> class B a where
>     b :: a
>
> instance B Bool where
>     b = False
>
> class M m where
>     return :: a -> m a
>     (>>=)  :: (B a) => m a -> (a -> m b) -> m b
>     (>>)   :: (B a) =>  m a -> m b -> m b
>     fail   :: String -> m a
>
>     p >> q  = p >>= \ _ -> q
>     fail s  = error s
>
> instance M Maybe where
>     return x = Just x
>     (>>=) = error "bind"
>
> test :: Maybe Bool
> test = do
>     x <- return True
>     return (x && x)
>
> unJust (Just x) = x
>
> main = print (unJust test)
>
> }}}

New description:

 {{{
 --
 -- According to section 7.3.5. Rebindable syntax in the
 user's manual
 -- this should work (unless I totally misunderstood it).
 -- It doesn't.
 --
 -- Compile with -fno-implicit-prelude
 --
 --     Lennart
 --

 import Prelude hiding(Monad(..))

 class B a where
     b :: a

 instance B Bool where
     b = False

 class M m where
     return :: a -> m a
     (>>=)  :: (B a) => m a -> (a -> m b) -> m b
     (>>)   :: (B a) =>  m a -> m b -> m b
     fail   :: String -> m a

     p >> q  = p >>= \ _ -> q
     fail s  = error s

 instance M Maybe where
     return x = Just x
     (>>=) = error "bind"

 test :: Maybe Bool
 test = do
     x <- return True
     return (x && x)

 unJust (Just x) = x

 main = print (unJust test)

 }}}

Comment:

 This is really a dup of #1537, which was fixed last year but never got
 into 6.8.  Works in HEAD (and hence the upcoming GHC 6.10).  However, I've
 added your program as a new test case in the regression test suite
 `rebindable/T303`, so that we'll know if it ever fails in the future.

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/303#comment:9>
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