type-inference/app/Terms.hs

17 lines
433 B
Haskell
Raw Normal View History

{-# LANGUAGE InstanceSigs #-}
module Terms where
-- Lambda-Terms
data Term
= Var String
| App Term Term
| Abs String Term
deriving (Eq, Ord)
instance Show Term where
show :: Term -> String
show (Var x) = x
show (App t1 t2) = show t1 ++ " " ++ go t2
where
go (App t3 t4) = "(" ++ show t3 ++ " " ++ go t4 ++ ")"
go t = show t
show (Abs x t) = "\\" ++ x ++ ". " ++ show t