我无法使用以下实例:
newtype ParseState a = ParseState {
state :: a
} deriving (Show)
newtype Parse m a b = Parse { -- In monad m, parsing from state a to b
runParse :: ParseState a -> m (b,ParseState a)
}
instance Monad m => Monad (Parse m a) where
parser >>= f = Parse $ \s -> do
(result,s') <- runParse parser s
runParse (f result) s'
instance {-# OVERLAPPING #-} (Monad m, Show a) => Monad (Parse m a) where
(>>=) = -- same definition as above
fail err = Parse $ \s ->
fail $ "Parsing error while at" ++ (show s) ++ " : " ++ err
GHC给我错误“重复实例声明”。 Section 7.6.3.4 of GHC manual似乎允许这种构造,不是吗?
如果没有,我该如何解决?