on master help sign in
Name changes for simpler Type representation

This should be cosmetic. No serious changes in how the code is written.

commitd5b0b432f50fe0ed3103a496a1dac5d3ab5fedf0 authorEvan Czaplicki <evancz@users.noreply.github.com> dateThu 1 Jun 2017, 20:10 (9 years ago) parent9593f00
7 files changed+34−34
src/Type/Constrain/Effects.hs+4−4 src/Type/Constrain/Expression.hs+19−19 src/Type/Constrain/Literal.hs+1−1 src/Type/Constrain/Pattern.hs+3−3 src/Type/Environment.hs+2−2 src/Type/Inference.hs+1−1 src/Type/Solve.hs+4−4
src/Type/Constrain/Effects.hs+4−4
@@ -11,8 +11,8 @@ import qualified Reporting.Annotation as A
1111import qualified Reporting.Error.Type as Error
1212import qualified Type.Environment as Env
1313import Type.Type
14− ( Variable, Type, TypeConstraint, Constraint(..), Scheme(Scheme)
15− , TermN(VarN), (==>), (<|), mkVar
14+ ( Variable, Type(VarN), Constraint(..), Scheme(Scheme)
15+ , (==>), (<|), mkVar
1616 )
1717
1818
@@ -20,7 +20,7 @@ import Type.Type
2020-- CONSTRAIN EFFECTS
2121
2222
23−constrain :: Env.Env -> ModuleName.Canonical -> Effects.Canonical -> IO TypeConstraint
23+constrain :: Env.Env -> ModuleName.Canonical -> Effects.Canonical -> IO Constraint
2424constrain env moduleName effects =
2525 case effects of
2626 Effects.None ->
@@ -33,7 +33,7 @@ constrain env moduleName effects =
3333 constrainHelp env moduleName info
3434
3535
36−constrainHelp :: Env.Env -> ModuleName.Canonical -> Effects.Info -> IO TypeConstraint
36+constrainHelp :: Env.Env -> ModuleName.Canonical -> Effects.Info -> IO Constraint
3737constrainHelp env moduleName (Effects.Info tagRegion r0 r1 r2 managerType) =
3838 let
3939 task t =
src/Type/Constrain/Expression.hs+19−19
@@ -24,7 +24,7 @@ import Type.Type hiding (Descriptor(..))
2424
2525
2626
27−constrain :: Env.Env -> C.Expr -> Type -> IO TypeConstraint
27+constrain :: Env.Env -> C.Expr -> Type -> IO Constraint
2828constrain env annotatedExpr@(A.A region expression) tipe =
2929 case expression of
3030 C.Literal lit ->
@@ -64,11 +64,11 @@ constrain env annotatedExpr@(A.A region expression) tipe =
6464 if Map.null decls then
6565 baseRec
6666 else
67− record (Map.map glToType decls) baseRec
67+ RecordN (Map.map glToType decls) baseRec
6868
6969 attribute = makeRec Lit.attribute attr
7070 uniform = makeRec Lit.uniform unif
71− varying = makeRec Lit.varying (TermN EmptyRecord1)
71+ varying = makeRec Lit.varying EmptyRecordN
7272 in
7373 return (CEqual Error.Shader region (shaderTipe attribute uniform varying) tipe)
7474
@@ -117,7 +117,7 @@ constrain env annotatedExpr@(A.A region expression) tipe =
117117 exists $ \ext ->
118118 do recordCon <- constrain env expr recordType
119119 let maybeBody = C.collectFields expr
120− let desiredType = record (Map.singleton field tipe) ext
120+ let desiredType = RecordN (Map.singleton field tipe) ext
121121 let fieldCon = CEqual (Error.Access maybeBody field) region recordType desiredType
122122 return $ recordCon /\ fieldCon
123123
@@ -125,11 +125,11 @@ constrain env annotatedExpr@(A.A region expression) tipe =
125125 exists $ \t ->
126126 do oldVars <- mapM (\_ -> mkVar Nothing) fields
127127 let oldFields = Map.fromList (zip (map fst fields) (map VarN oldVars))
128− cOld <- ex oldVars <$> constrain env expr (record oldFields t)
128+ cOld <- ex oldVars <$> constrain env expr (RecordN oldFields t)
129129
130130 newVars <- mapM (\_ -> mkVar Nothing) fields
131131 let newFields = Map.fromList (zip (map fst fields) (map VarN newVars))
132− let cNew = CEqual Error.Record region (record newFields t) tipe
132+ let cNew = CEqual Error.Record region (RecordN newFields t) tipe
133133
134134 cs <- Monad.zipWithM (constrain env) (map snd fields) (map VarN newVars)
135135
@@ -143,7 +143,7 @@ constrain env annotatedExpr@(A.A region expression) tipe =
143143 (map snd fields)
144144 (map VarN vars)
145145 let fields' = Map.fromList (zip (map fst fields) (map VarN vars))
146− let recordType = record fields' (TermN EmptyRecord1)
146+ let recordType = RecordN fields' EmptyRecordN
147147 return (ex vars (CAnd (fieldCons ++ [CEqual Error.Record region recordType tipe])))
148148
149149 C.Let defs body ->
@@ -171,7 +171,7 @@ constrainApp
171171 -> C.Expr
172172 -> [C.Expr]
173173 -> Type
174− -> IO TypeConstraint
174+ -> IO Constraint
175175constrainApp env region f args tipe =
176176 do funcVar <- mkVar Nothing
177177 funcCon <- constrain env f (VarN funcVar)
@@ -202,7 +202,7 @@ argConstraints
202202 -> Variable
203203 -> Int
204204 -> [C.Expr]
205− -> IO ([Variable], [TypeConstraint], [TypeConstraint], [TypeConstraint], Maybe R.Region, Variable)
205+ -> IO ([Variable], [Constraint], [Constraint], [Constraint], Maybe R.Region, Variable)
206206argConstraints env name region totalArgs overallVar index args =
207207 case args of
208208 [] ->
@@ -255,7 +255,7 @@ constrainBinop
255255 -> C.Expr
256256 -> C.Expr
257257 -> Type
258− -> IO TypeConstraint
258+ -> IO Constraint
259259constrainBinop env region op leftExpr@(A.A leftRegion _) rightExpr@(A.A rightRegion _) tipe =
260260 do leftVar <- mkVar Nothing
261261 rightVar <- mkVar Nothing
@@ -284,7 +284,7 @@ constrainBinop env region op leftExpr@(A.A leftRegion _) rightExpr@(A.A rightReg
284284-- CONSTRAIN LISTS
285285
286286
287−constrainList :: Env.Env -> R.Region -> [C.Expr] -> Type -> IO TypeConstraint
287+constrainList :: Env.Env -> R.Region -> [C.Expr] -> Type -> IO Constraint
288288constrainList env region exprs tipe =
289289 do (exprInfo, exprCons) <-
290290 unzip <$> mapM elementConstraint exprs
@@ -312,7 +312,7 @@ constrainIf
312312 -> [(C.Expr, C.Expr)]
313313 -> C.Expr
314314 -> Type
315− -> IO TypeConstraint
315+ -> IO Constraint
316316constrainIf env region branches finally tipe =
317317 do let (conditions, branchExprs) =
318318 second (++ [finally]) (unzip branches)
@@ -371,7 +371,7 @@ constrainCase
371371 -> C.Expr
372372 -> [(P.Canonical, C.Expr)]
373373 -> Type
374− -> IO TypeConstraint
374+ -> IO Constraint
375375constrainCase env region expr branches tipe =
376376 do exprVar <- mkVar Nothing
377377 exprCon <- constrain env expr (VarN exprVar)
@@ -411,9 +411,9 @@ data Pair = Pair
411411pairCons
412412 :: R.Region
413413 -> (Int -> R.Region -> Error.Hint)
414− -> (Variable -> TypeConstraint)
414+ -> (Variable -> Constraint)
415415 -> [(Variable, R.Region)]
416− -> IO ([Variable], [TypeConstraint])
416+ -> IO ([Variable], [Constraint])
417417pairCons region pairHint varToCon items =
418418 let
419419 pairToCon (Pair index var1 var2 subregion) =
@@ -488,12 +488,12 @@ expandPattern def@(C.Def facts lpattern expr maybeType) =
488488
489489data Info =
490490 Info
491− { iSchemes :: [TypeScheme]
491+ { iSchemes :: [Scheme]
492492 , iRigid :: [Variable]
493493 , iFlex :: [Variable]
494494 , iHeaders :: Map.Map Text (A.Located Type)
495− , iC2 :: TypeConstraint
496− , iC1 :: TypeConstraint
495+ , iC2 :: Constraint
496+ , iC1 :: Constraint
497497 }
498498
499499
@@ -566,7 +566,7 @@ data ArgInfo =
566566 }
567567
568568
569−constrainAnnDefHelp :: C.Expr -> ST.Canonical -> ArgInfo -> IO TypeConstraint
569+constrainAnnDefHelp :: C.Expr -> ST.Canonical -> ArgInfo -> IO Constraint
570570constrainAnnDefHelp expr tipe (ArgInfo name defRegion env args vars) =
571571 case (expr, tipe) of
572572 (A.A _ (C.Lambda arg result), ST.Lambda argType resultType) ->
src/Type/Constrain/Literal.hs+1−1
@@ -13,7 +13,7 @@ import qualified Type.Environment as Env
1313-- CONSTRAIN LITERALS
1414
1515
16−constrain :: Env.Env -> R.Region -> L.Literal -> T.Type -> IO T.TypeConstraint
16+constrain :: Env.Env -> R.Region -> L.Literal -> T.Type -> IO T.Constraint
1717constrain env region literal tipe =
1818 do definiteType <- litType
1919 return (T.CEqual (Error.Literal name) region definiteType tipe)
src/Type/Constrain/Pattern.hs+3−3
@@ -24,7 +24,7 @@ data Info =
2424 Info
2525 { _headers :: Map.Map Text (A.Located Type)
2626 , _vars :: [Variable]
27− , _cons :: TypeConstraint
27+ , _cons :: Constraint
2828 }
2929
3030
@@ -47,7 +47,7 @@ joinInfos infos =
4747 List.foldl' (flip joinInfo) emptyInfo infos
4848
4949
50−infoToScheme :: Info -> Scheme Type Variable
50+infoToScheme :: Info -> Scheme
5151infoToScheme (Info headers vars cons) =
5252 Scheme [] vars cons headers
5353
@@ -116,7 +116,7 @@ constrain env (A.A region pattern) tipe =
116116 Map.map A.drop tenv
117117
118118 con <- exists $ \t ->
119− return (equal Error.PRecord tipe (record unannotatedTenv t))
119+ return (equal Error.PRecord tipe (RecordN unannotatedTenv t))
120120
121121 return $ Info
122122 { _headers = tenv
src/Type/Environment.hs+2−2
@@ -255,9 +255,9 @@ instantiatorHelp flex env aliasVars sourceType =
255255 text <-
256256 case ext of
257257 Nothing ->
258− return $ TermN EmptyRecord1
258+ return EmptyRecordN
259259
260260 Just extType ->
261261 go extType
262262
263− return $ TermN (Record1 tfields text)
263+ return $ RecordN tfields text
src/Type/Inference.hs+1−1
@@ -44,7 +44,7 @@ infer interfaces modul =
4444genConstraints
4545 :: Module.Interfaces
4646 -> Module.Canonical
47− -> IO (Map.Map Text T.Type, T.TypeConstraint)
47+ -> IO (Map.Map Text T.Type, T.Constraint)
4848genConstraints interfaces modul =
4949 do env <-
5050 Env.initialize (canonicalizeUnions interfaces modul)
src/Type/Solve.hs+4−4
@@ -7,7 +7,6 @@ import Control.Monad.Except (ExceptT, liftIO, throwError)
77import qualified Data.Foldable as F
88import qualified Data.Map as Map
99import qualified Data.Text as Text
10−import qualified Data.UnionFind.IO as UF
1110
1211import qualified AST.Module.Name as ModuleName
1312import qualified Reporting.Annotation as A
@@ -15,6 +14,7 @@ import qualified Reporting.Error.Type as Error
1514import qualified Type.State as TS
1615import Type.Type as Type
1716import Type.Unify
17+import qualified Type.UnionFind as UF
1818
1919
2020
@@ -150,7 +150,7 @@ adjustRankContent youngMark visitedMark groupRank content =
150150-- SOLVER
151151
152152
153−solve :: TypeConstraint -> ExceptT [A.Located Error.Error] IO TS.State
153+solve :: Constraint -> ExceptT [A.Located Error.Error] IO TS.State
154154solve constraint =
155155 {-# SCC elm_compiler_type_solve #-}
156156 do state <- liftIO (TS.run (actuallySolve constraint))
@@ -161,7 +161,7 @@ solve constraint =
161161 throwError errors
162162
163163
164−actuallySolve :: TypeConstraint -> TS.Solver ()
164+actuallySolve :: Constraint -> TS.Solver ()
165165actuallySolve constraint =
166166 case constraint of
167167 CTrue ->
@@ -210,7 +210,7 @@ actuallySolve constraint =
210210 unify (Error.Instance name) region freshCopy t
211211
212212
213−solveScheme :: TypeScheme -> TS.Solver TS.Env
213+solveScheme :: Scheme -> TS.Solver TS.Env
214214solveScheme scheme =
215215 let
216216 flatten (A.A region term) =