@@ -20,8 +20,12 @@ import qualified Type.Environment as Env
20import qualified Type.Constrain.Literal as Literal
20import qualified Type.Constrain.Literal as Literal
21import qualified Type.Constrain.Pattern as Pattern
21import qualified Type.Constrain.Pattern as Pattern
23−constrain :: Env.Environment -> Canonical.Expr -> Type
25+ :: Env.Environment
24− -> ErrorT [PP.Doc] IO TypeConstraint
28+ -> ErrorT [PP.Doc] IO TypeConstraint
25constrain env (A region expr) tipe =
29constrain env (A region expr) tipe =
26 let list t = Env.get env Env.types "List" <| t
30 let list t = Env.get env Env.types "List" <| t
27 and = A region . CAnd
31 and = A region . CAnd
@@ -37,7 +41,7 @@ constrain env (A region expr) tipe =
37 exists $ \attr ->
41 exists $ \attr ->
38 exists $ \unif ->
42 exists $ \unif ->
40− shaderTipe a u v = Env.get env Env.types "Graphics.WebGL.Shader" <| a <| u <| v
44+ shaderTipe a u v = Env.get env Env.types "WebGL.Shader" <| a <| u <| v
41 glTipe = Env.get env Env.types . Lit.glTipeName
45 glTipe = Env.get env Env.types . Lit.glTipeName
42 makeRec accessor baseRec =
46 makeRec accessor baseRec =
43 let decls = accessor gltipe
47 let decls = accessor gltipe
@@ -166,6 +170,7 @@ constrain env (A region expr) tipe =
166 PortOut _ _ signal ->
170 PortOut _ _ signal ->
167 constrain env signal tipe
171 constrain env signal tipe
169constrainDef env info (Canonical.Definition pattern expr maybeTipe) =
174constrainDef env info (Canonical.Definition pattern expr maybeTipe) =
170 let qs = [] -- should come from the def, but I'm not sure what would live there...
175 let qs = [] -- should come from the def, but I'm not sure what would live there...
171 (schemes, rigidQuantifiers, flexibleQuantifiers, headers, c2, c1) = info
176 (schemes, rigidQuantifiers, flexibleQuantifiers, headers, c2, c1) = info
@@ -205,6 +210,7 @@ constrainDef env info (Canonical.Definition pattern expr maybeTipe) =
206 _ -> error ("problem in constrainDef with " ++ show pattern)
211 _ -> error ("problem in constrainDef with " ++ show pattern)
208expandPattern :: Canonical.Def -> [Canonical.Def]
214expandPattern :: Canonical.Def -> [Canonical.Def]
209expandPattern def@(Canonical.Definition pattern lexpr@(A r _) maybeType) =
215expandPattern def@(Canonical.Definition pattern lexpr@(A r _) maybeType) =
210 case pattern of
216 case pattern of
@@ -216,9 +222,10 @@ expandPattern def@(Canonical.Definition pattern lexpr@(A r _) maybeType) =
216 mkVar = A r . localVar
222 mkVar = A r . localVar
217 toDef y = Canonical.Definition (P.Var y) (A r $ Case (mkVar x) [(pattern, mkVar y)]) Nothing
223 toDef y = Canonical.Definition (P.Var y) (A r $ Case (mkVar x) [(pattern, mkVar y)]) Nothing
219try :: Region -> ErrorT (Region -> PP.Doc) IO a -> ErrorT [PP.Doc] IO a
226try :: Region -> ErrorT (Region -> PP.Doc) IO a -> ErrorT [PP.Doc] IO a
220−try region computation = do
227+try region computation =
221− result <- liftIO $ runErrorT computation
228+ do result <- liftIO $ runErrorT computation
222− case result of
229+ case result of
223− Left err -> throwError [err region]
230+ Left err -> throwError [err region]
224− Right value -> return value
231+ Right value -> return value