I have such function:
eval :: Expr -> Either ArithmeticError Int
eval (Const a) = Right a
eval (Add a b) = liftM2 (+) ea eb
where
ea = eval a
eb = eval b
eval (Sub a b) = liftM2 (-) ea eb
where
ea = eval a
eb = eval b
I would like to rewrite this with one where usage. Can I do it? But pattern-matching should stay in this code. Thanks!