summaryrefslogtreecommitdiff
path: root/src/Parser.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2026-08-26 21:29:08 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2026-08-27 23:04:38 +0200
commit4145e966859dccc5bf7fac1f1c74b3efd8b6b7e9 (patch)
treeea18363a09f6bc6c014437ad8a9569a431ddf203 /src/Parser.hs
parenta9d6eacb3aaa0e7acc5abc931061e07549f1c20e (diff)
Use closure instead of failing with ambiguous type for argument types with free variables
Diffstat (limited to 'src/Parser.hs')
-rw-r--r--src/Parser.hs9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/Parser.hs b/src/Parser.hs
index 928dd88..62549eb 100644
--- a/src/Parser.hs
+++ b/src/Parser.hs
@@ -102,13 +102,8 @@ parseDefinition href = label "symbol definition" $ do
modify $ \s -> s { testVars = ( name, ( GlobalVarName (testCurrentModuleName s) name, someExprType expr )) : testVars s }
return def
where
- getInferredTypes atypes = forM atypes $ \( off, vname, tvar@(TypeVar tvarname) ) -> do
- let err msg = do
- registerParseError . FancyError off . S.singleton . ErrorFail $ T.unpack msg
- return ( vname, SomeArgumentType OptionalArgument (ExprTypeForall (TypeVar "a") (ExprTypeVar (TypeVar "a"))) )
- gets (M.lookup tvar . testTypeUnif) >>= \case
- Just t -> return ( vname, SomeArgumentType RequiredArgument t )
- Nothing -> err $ "ambiguous type for ‘" <> textVarName vname <> " : " <> tvarname <> "’"
+ getInferredTypes atypes = forM atypes $ \( _, vname, tvar ) -> do
+ ( vname, ) . SomeArgumentType OptionalArgument <$> typeClosure (ExprTypeVar tvar)
replaceDynArgs :: forall a. Expr a -> TestParser (Expr a)
replaceDynArgs expr = do