summaryrefslogtreecommitdiff
path: root/src/Parser
diff options
context:
space:
mode:
Diffstat (limited to 'src/Parser')
-rw-r--r--src/Parser/Core.hs15
-rw-r--r--src/Parser/Expr.hs9
2 files changed, 13 insertions, 11 deletions
diff --git a/src/Parser/Core.hs b/src/Parser/Core.hs
index 1b049c8..c317067 100644
--- a/src/Parser/Core.hs
+++ b/src/Parser/Core.hs
@@ -207,6 +207,14 @@ unifyExpr off pa expr = if
-> return expr
| DynVariable stype sline name <- expr
+ , ExprTypeForall qvar itype <- stype
+ -> do
+ tvar <- newTypeVar
+ _ <- unify off (ExprTypePrim (Proxy :: Proxy a)) $ renameVarInType qvar tvar itype
+ rtype <- M.lookup tvar <$> gets testTypeUnif
+ return $ TypeApp (Variable sline name) $ fromMaybe (ExprTypeVar tvar) rtype
+
+ | DynVariable stype sline name <- expr
-> do
_ <- unify off (ExprTypePrim (Proxy :: Proxy a)) stype
return $ Variable sline name
@@ -215,12 +223,7 @@ unifyExpr off pa expr = if
-> do
unifyExpr off pa expr'
- | TypeQuant qvar expr' <- expr
- -> do
- tvar <- newTypeVar
- unifyExpr off pa $ renameTypeVar qvar tvar expr'
-
- | TypeLambda t tvar f <- expr
+ | TypeLambda tvar t f <- expr
-> do
_ <- unify off (ExprTypePrim (Proxy :: Proxy a)) t
Just (ExprTypePrim pt) <- M.lookup tvar <$> gets testTypeUnif
diff --git a/src/Parser/Expr.hs b/src/Parser/Expr.hs
index 5e27457..c57aa97 100644
--- a/src/Parser/Expr.hs
+++ b/src/Parser/Expr.hs
@@ -189,11 +189,10 @@ list = label "list" $ do
[do symbol "]"
tvar <- newTypeVar
return $ SomeExpr $
- TypeQuant tvar $
- TypeLambda (ExprTypeApp (ExprTypeConstr1 (Proxy :: Proxy [])) [ ExprTypeVar tvar ]) tvar $
- \case
- (ExprTypePrim (Proxy :: Proxy a)) -> HideType $ Pure ([] :: [ a ])
- _ -> Undefined "incomplete type"
+ TypeLambda tvar (ExprTypeApp (ExprTypeConstr1 (Proxy :: Proxy [])) [ ExprTypeVar tvar ]) $
+ \case
+ (ExprTypePrim (Proxy :: Proxy a)) -> HideType $ Pure ([] :: [ a ])
+ _ -> Undefined "incomplete type"
,do SomeExpr x <- someExpr
let enumErr off = parseError $ FancyError off $ S.singleton $ ErrorFail $ T.unpack $