I believe I've found a bug in the way Hugs 971106 reports certain
errors (the behavior was also present in Hugs 970719).
Consider the following module.
--------------------------------------------------
module Bug2 where
newtype StateMonad m s a = MkStateMonad (s -> (m (s, a)))
instance Monad m => Monad (StateMonad m s) where
(>>=) (MkStateMonad fn1) f
= MkStateMonad (\st -> (do res <- fn1 st
case res of
(st', res') -> extrStateMonad (f res') st'))
return val = MkStateMonad (\st -> (return (st, val)))
extrStateMonad (MkStateMonad f) = f
getState :: Monad m => StateMonad m s s
getState = MkStateMonad (\st -> return (st, st))
-- popIndentList :: StateMonad IO Int ()
popIndentList =
(do getState
return ())
--------------------------------------------------
When you try to load this into Hugs, it prints:
ERROR "Bug2.hs" (line 18): Unresolved top-level overloading
*** Binding : popIndentList
*** Outstanding context : (Monad (StateMonad b b), Monad b)
That context doesn't make any sense; in particular, (StateMonad b b)
is not well-kinded. I would expect a context like
(Monad (StateMonad a b), Monad a)
(which of course reduces to (Monad a)).
Also, it would have been easier for me to understand the above error
message if it had included the words "monomorphism restriction".
Carl Witty
[EMAIL PROTECTED]