module FunType where { -- Monadic Versionのために必要 type M a = a; unitM :: a -> M a; unitM a = a; bindM :: M a -> (a -> M b) -> M b; m `bindM` k = k m; data Value = Num Double | Fun (Value -> M Value); -- Value値を表示するために必要 instance Show Value where { showsPrec p (Num d) = showParen (p>8) (showString "Num ". shows d); showsPrec p (Fun f) = showParen (p>8) (showString "Fun ") }; showValue (Num d) = show d; showValue (Fun _) = ""; -- Exprの抽象構文 type Decl = (String, Expr); data Expr = Mult Expr Expr | Add Expr Expr | Const Value | Let Decl Expr | Var String | Lambda String Expr | App Expr Expr deriving Show; }