@@ -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+