RE: A couple of bugs



About this list Date view Thread view Subject view Author view

Malcolm Wallace (malcolm-nhc@cs.york.ac.uk)
Tue, 8 Aug 2000 10:48:53 +0100


Wojciech Moczydlowski writes: > module MonadState where > class (Monad m) => MonadState s m where > get :: m s > put :: s -> m () gives the error > In file ./MonadState.hs: > -} but expected a {-EOF-} On my machine, I get > In file ./MonadState.hs: > 3:33 Found m but expected a {-EOF-} which is slightly more informative. Multi-parameter type classes are not Haskell'98, and are not supported by nhc98. I'd be interested to know why your nhc98 did not produce the same error message as mine though. Can you give some more details of the compiler version, what type of machine you are using, and the compiler that you used to build nhc98 with? > module Main where > {-# -} > main = return () gives the error > In file ./1.hs: > 3:1 Found {-# but expected a {-EOF-} Indeed, {-# -} is technically a legal comment, and nhc98 is wrong to reject it. (However, {-# is the syntax for introducing a pragma (see appendix E of the Haskell Report), and when used in this way should be terminated with #-} which is why nhc98 rejected it.) > The third one - parser generated by happy fails with "Internal > happy error". I'd rather not include the whole parser with this > letter - the file size is 120KB. As far as I can tell, Happy is a ghc-specific tool. I have never been able to get any Happy-generated parser to work with nhc98. > module Main where > import A > f :: Either Int Int > f = do > Left 5 > Right 5 > module A where > instance Monad (Either a) where > return v = Right v > p >>= f = case p of > Left a -> Left a > Right a -> f a > Fail: The class Prelude.Monad has no instance for the type Prelude.Either. > Possible sources for the problem are:7:9 This is a fairly obscure bug in the way nhc98 treats interface-files. To avoid clutter, it tries to eliminate lots of redundant information about the prelude which would otherwise appear in .hi files. Unfortunately, in this case it has wrongly eliminated the only definition in module A! You can work around this bug by forcing the compiler to keep all prelude information in the .hi file: just give the -prelude flag, e.g. nhc98 -c -prelude A.hs Regards, Malcolm


About this list Date view Thread view Subject view Author view