I have a module that looks like thisrunEval :: (Show a) => Env -> Eval a -> Either String arunEval = ...data Value = IntVal Integermain :: IO ()main = dolet env = Map.fromList [("x",IntVal 3)]result <- runEval env (eval (Plus (Var "x") (Lit 2)))case result ofLeft err -> putStrLn "Error: "++errRight (IntVal i) -> print iwhen I call runEval from ghci I get back a result just finelet env = Map.fromList [("x",IntVal 3)]runEval env (eval (Plus (Var "x") (Lit 2)))This outputs "Right (IntVal 5)" as I would expect. But when I try and compile my main method I get the following error.Couldn't match expected type `Value'with actual type `Either t1 Value'In the pattern: Right (IntVal i)In a case alternative: Right (IntVal i) -> print iIn a stmt of a 'do' block:case result of {Left err -> print errRight (IntVal i) -> print i }I also tried using (putStrLn . either show show) result, but this gave me the following error.Couldn't match expected type `Either a0 b0'with actual type `Value'In the first argument of `putStrLn . either show show', namely`result'In a stmt of a 'do' block: (putStrLn . either show show) resultIn the expression:do { let env = Map.fromList ...;result <- runEval3 env (eval3 (Plus (Var "x") (Lit 2)));(putStrLn . either show show) result }Why is it when I try and pattern match on Either String Value it says result is of type "Value", but when I try and use either it says result is of type "Either String Value"?Matt P.
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners