on master help sign in
Move the Environment.hs and Fragment.hs files down a directory.
commitb87b84556c3be0f62473140ba0b20eae1564c0b0 authorEvan Czaplicki <evan@Evans-MacBook-Air.local> dateSun 7 Jul 2013, 12:54 (13 years ago) parentca8441f
6 files changed+40−14
compiler/Type/Constrain/Expression.hs+2−2 compiler/Type/Constrain/Literal.hs+2−2 compiler/Type/Constrain/Pattern.hs+2−2 compiler/Type/Environment.hs+1−1 compiler/Type/Fragment.hs+1−1 compiler/Type/Solve.hs+32−6
compiler/Type/Constrain/Expression.hs+2−2
@@ -11,8 +11,8 @@ import SourceSyntax.Location as Loc
1111import SourceSyntax.Pattern (Pattern(PVar))
1212import SourceSyntax.Expression
1313import Type.Type hiding (Descriptor(..))
14−import Type.Constrain.Fragment
15−import Type.Constrain.Environment as Env
14+import Type.Fragment
15+import Type.Environment as Env
1616import qualified Type.Constrain.Literal as Literal
1717import qualified Type.Constrain.Pattern as Pattern
1818
compiler/Type/Constrain/Literal.hs+2−2
@@ -5,8 +5,8 @@ import qualified Data.Map as Map
55
66import SourceSyntax.Literal
77import Type.Type
8−import Type.Constrain.Fragment
9−import Type.Constrain.Environment as Env
8+import Type.Fragment
9+import Type.Environment as Env
1010
1111constrain :: Environment -> Literal -> Type -> TypeConstraint
1212constrain env literal tipe =
compiler/Type/Constrain/Pattern.hs+2−2
@@ -10,8 +10,8 @@ import qualified Data.Map as Map
1010
1111import SourceSyntax.Pattern
1212import Type.Type
13−import Type.Constrain.Fragment
14−import Type.Constrain.Environment as Env
13+import Type.Fragment
14+import Type.Environment as Env
1515import qualified Type.Constrain.Literal as Literal
1616
1717
compiler/Type/Environment.hs+1−1
@@ -1,4 +1,4 @@
1−module Type.Constrain.Environment where
1+module Type.Environment where
22
33import qualified Data.Map as Map
44import Data.Map ((!))
compiler/Type/Fragment.hs+1−1
@@ -1,4 +1,4 @@
1−module Type.Constrain.Fragment where
1+module Type.Fragment where
22
33import qualified Data.List as List
44import qualified Data.Map as Map
compiler/Type/Solve.hs+32−6
@@ -4,11 +4,11 @@ module Type.Solve where
44import Control.Monad
55import qualified Data.UnionFind.IO as UF
66import qualified Data.Array.IO as Array
7−import qualified Data.Map as Map
7+import Data.Map as Map
88import qualified Data.Maybe as Maybe
99import Type.Type
1010import Type.Unify
11−import Type.Environment
11+import Type.Environment as Env
1212
1313-- Pool
1414-- Holds a bunch of variables
@@ -88,6 +88,11 @@ traverse young visited k variable =
8888
8989success = return []
9090
91+chop = undefined
92+addTo = undefined
93+newPool = undefined
94+introduce = undefined
95+
9196solve env pool constraint =
9297 case constraint of
9398 CTrue -> success
@@ -100,12 +105,33 @@ solve env pool constraint =
100105 return (concat results)
101106
102107 CLet schemes constraint' -> do
103− env' <- foldM (\env' scheme -> (++) env' `liftM` solveScheme env pool scheme) env schemes
108+ env' <- foldM (\env' scheme -> addTo env' `liftM` solveScheme env pool scheme) env schemes
104109 solve env' pool constraint'
105110
106111 CInstance name term -> do
107− let inst = instance' pool (Env.get env value name)
108− t = chop pool term
112+ let instance' = undefined
113+ inst = instance' pool (Env.get env value name)
114+ t <- chop pool term
109115 unify pool inst t
110116
111−solveScheme = undefined
117+solveScheme env pool scheme =
118+ case scheme of
119+ Scheme [] [] constraint header -> do
120+ solve env pool constraint
121+ mapM (\(n,t) -> (,) n `liftM` chop pool t) (Map.toList header)
122+
123+ Scheme rigidQuantifiers flexibleQuantifiers constraint header -> do
124+ let quantifiers = rigidQuantifiers ++ flexibleQuantifiers
125+ pool' <- newPool pool
126+ mapM (introduce pool') rigidQuantifiers
127+ mapM (introduce pool') flexibleQuantifiers
128+ header' <- mapM (\(n,t) -> (,) n `liftM` chop pool t) (Map.toList header)
129+ solve env pool' constraint
130+ generalize pool pool'
131+ mapM isGeneric rigidQuantifiers
132+ return header'
133+
134+isGeneric var =
135+ do desc <- UF.descriptor var
136+ undefined
137+