Perhaps a bug in GHC 6.10
Hi, One of my students wrote code like this: prop_blank s (i,j) li = if i==li then do if something then True else False else prop_blank (...) (i,j) (li+1) This code is not accepted from GHC 6.8.3 because Bool is not a monad. In particular the error message is: Sudoku.hs:269:5: Couldn't match expected type `Bool' against inferred type `a b' In the expression: ...... Surprisingly the same code is accepted from GHC 6.10. This looks like a bug for me. The easiest way to reproduce this is to try to evaluate:
do True
in GHCi with GHC 6.8.3 and with GHC 6.10 Is there any reason to accept this code? Regards, Krasimir
It looks like the 6.10 behavior is actually the correct one: http://www.mail-archive.com/glasgow-haskell-bugs@haskell.org/msg13632.html Also, see the do-notation translation section in the Haskell 98 Report: http://www.haskell.org/onlinereport/exps.html#sect3.14 -Eric On Wed, Dec 3, 2008 at 5:45 AM, Krasimir Angelov <kr.angelov@gmail.com> wrote:
Hi,
One of my students wrote code like this:
prop_blank s (i,j) li = if i==li then do if something then True else False else prop_blank (...) (i,j) (li+1)
This code is not accepted from GHC 6.8.3 because Bool is not a monad. In particular the error message is:
Sudoku.hs:269:5: Couldn't match expected type `Bool' against inferred type `a b' In the expression: ......
Surprisingly the same code is accepted from GHC 6.10. This looks like a bug for me. The easiest way to reproduce this is to try to evaluate:
do True
in GHCi with GHC 6.8.3 and with GHC 6.10
Is there any reason to accept this code?
Regards, Krasimir _______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
On 2008 Dec 3, at 8:45, Krasimir Angelov wrote:
Sudoku.hs:269:5: Couldn't match expected type `Bool' against inferred type `a b' In the expression: ......
Surprisingly the same code is accepted from GHC 6.10. This looks like a bug for me. The easiest way to reproduce this is to try to evaluate:
6.8.3 was changed on the theory that do "ought to" require a monad, contra Haskell98. I suspect Haskell98 compatibility won. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
participants (3)
-
Brandon S. Allbery KF8NH -
Eric Walkingshaw -
Krasimir Angelov