elm/src/Types/Types.hs

35 lines
798 B
Haskell
Raw Normal View History

2012-04-19 06:32:10 +00:00
module Types where
import Data.List (intercalate)
import qualified Data.Set as Set
type X = Int
2012-04-19 06:32:10 +00:00
data Type = IntT
| StringT
| CharT
| BoolT
| LambdaT Type Type
| VarT X
2012-04-19 06:32:10 +00:00
| AppT String [Type]
| ADT String [Type]
deriving (Eq, Ord)
data Scheme = Forall (Set.Set X) Type deriving (Eq, Ord, Show)
2012-04-19 06:32:10 +00:00
data Constructor = Constructor String [Type] deriving (Eq, Show)
instance Show Type where
show t =
case t of
{ IntT -> "Int"
; StringT -> "String"
; CharT -> "Char"
; BoolT -> "Bool"
; LambdaT t1 t2 -> show t1 ++ " -> " ++ show t2
; VarT x -> show x
2012-04-28 07:26:46 +00:00
; AppT name args -> name ++ " " ++ unwords (map show args)
; ADT name constrs -> name
2012-04-19 06:32:10 +00:00
}