@@ -1,6 +1,6 @@
11{-# OPTIONS_GHC -Wall #-}
22module Type.Environment
3− ( Environment
3+ ( Env
44 , initialize
55 , getType, freshDataScheme, ctorNames
66 , addValues
@@ -24,18 +24,18 @@ type TypeDict = Map.Map String Type
2424type VarDict = Map.Map String Variable
2525
2626
27−data Environment = Environment
27+data Env = Env
2828 { _constructor :: Map.Map String (IO (Int, [Variable], [Type], Type))
2929 , _types :: TypeDict
3030 , _value :: TypeDict
3131 }
3232
3333
34−initialize :: [Module.CanonicalUnion] -> IO Environment
34+initialize :: [Module.CanonicalUnion] -> IO Env
3535initialize datatypes =
3636 do types <- makeTypes datatypes
3737 let env =
38− Environment
38+ Env
3939 { _constructor = Map.empty
4040 , _value = Map.empty
4141 , _types = types
@@ -72,7 +72,7 @@ makeTypes datatypes =
7272
7373
7474makeConstructors
75− :: Environment
75+ :: Env
7676 -> [Module.CanonicalUnion]
7777 -> Map.Map String (IO (Int, [Variable], [Type], Type))
7878makeConstructors env datatypes =
@@ -100,7 +100,7 @@ makeConstructors env datatypes =
100100
101101
102102ctorToType
103− :: Environment
103+ :: Env
104104 -> (V.Canonical, Module.UnionInfo V.Canonical)
105105 -> [(String, IO (Int, [Variable], [Type], Type))]
106106ctorToType env (name, (tvars, ctors)) =
@@ -123,24 +123,24 @@ ctorToType env (name, (tvars, ctors)) =
123123-- ACCESS TYPES
124124
125125
126−get :: (Environment -> Map.Map String a) -> Environment -> String -> a
126+get :: (Env -> Map.Map String a) -> Env -> String -> a
127127get subDict env key =
128128 Map.findWithDefault (error msg) key (subDict env)
129129 where
130130 msg = "Could not find type constructor `" ++ key ++ "` while checking types."
131131
132132
133−getType :: Environment -> String -> Type
133+getType :: Env -> String -> Type
134134getType =
135135 get _types
136136
137137
138−freshDataScheme :: Environment -> String -> IO (Int, [Variable], [Type], Type)
138+freshDataScheme :: Env -> String -> IO (Int, [Variable], [Type], Type)
139139freshDataScheme =
140140 get _constructor
141141
142142
143−ctorNames :: Environment -> [String]
143+ctorNames :: Env -> [String]
144144ctorNames env =
145145 Map.keys (_constructor env)
146146
@@ -148,7 +148,7 @@ ctorNames env =
148148-- UPDATE ENVIRONMENT
149149
150150
151−addValues :: Environment -> [(String, Variable)] -> Environment
151+addValues :: Env -> [(String, Variable)] -> Env
152152addValues env newValues =
153153 env
154154 { _value =
@@ -163,18 +163,18 @@ addValues env newValues =
163163-- INSTANTIATE TYPES
164164
165165
166−instantiateType :: Environment -> T.Canonical -> VarDict -> IO ([Variable], Type)
166+instantiateType :: Env -> T.Canonical -> VarDict -> IO ([Variable], Type)
167167instantiateType env sourceType dict =
168168 do (tipe, dict') <- State.runStateT (instantiator env sourceType) dict
169169 return (Map.elems dict', tipe)
170170
171171
172−instantiator :: Environment -> T.Canonical -> State.StateT VarDict IO Type
172+instantiator :: Env -> T.Canonical -> State.StateT VarDict IO Type
173173instantiator env sourceType =
174174 instantiatorHelp env Set.empty sourceType
175175
176176
177−instantiatorHelp :: Environment -> Set.Set String -> T.Canonical -> State.StateT VarDict IO Type
177+instantiatorHelp :: Env -> Set.Set String -> T.Canonical -> State.StateT VarDict IO Type
178178instantiatorHelp env aliasVars sourceType =
179179 let
180180 go =