0
votes
data CError = EA Int | EB String
   deriving (Eq, Show)

type Env = [(VName, Value)]

newtype Test a = Test {runTest :: Env -> (Either CError a, [String]) }

I am learning haskell, and now trying to define a monad, but encounters this error and couldn't find the way to fix it.

My code below:

instance Monad Test where
  return a = Test $ \e -> (Right a, mempty)
  
  m >>= f = Test $ \env -> case runTest m env of
    (Right a, s) -> runTest (f a) env
    (Left error) -> Left error

Currently, this line "(Left error) -> Left error" displays an exception "Couldn't match expected type: (Either CError b, [String]) with actual type: Either a0 b1". Can someone help me with this? Thank you