我試圖在Haskell中實現以下代碼,以評估算術表達式,不幸的是它給了我錯誤Couldn't match expected type `Integer' against inferred type `Value'
在(IVal (eval c x)) + (IVal (eval c (Prim IntAddOp xs)))).
Plz幫助我一些解。無法匹配期望的類型'Integer'對推斷類型'值'
type Env = GenEnv Value
data Value
= IVal Integer
| BVal Bool
--------------------------------------------------
eval :: Env -> Exp -> Value
eval _ (Num n) = IVal n
eval _ (Prim IntAddOp ((Num x) : (Num y):[])) = IVal (x+y)
eval c (Prim IntAddOp (x: xs)) = IVal ((IVal (eval c x)) + (IVal (eval c
(Prim IntAddOp xs))))
謝謝...