我有这样的功能:
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
Run Code Online (Sandbox Code Playgroud)
我想用一种where用法重写它。我可以做吗?但是模式匹配应该留在这段代码中。谢谢!