data Result a = Ok a String | Err deriving (Eq, Show) {- https://hub.darcs.net/ppk/calculator/browse/src/Parser.hs -} data Op = Plus | Mult data Ast = Val Int | Expr Op Ast Ast opDe :: Op -> (Int -> Int -> Int) opDe Plus = (+) opDe Mult = (*) astDe :: Ast -> Int astDe (Val n) = n astDe (Expr op e1 e2) = (opDe op) (astDe e1) (astDe e2) eg1 = Expr Plus (Val 2) (Expr Mult (Val 3) (Val 2)) a = astDe eg1