diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2024-09-28 19:53:42 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2024-09-28 20:08:00 +0200 |
commit | 9b947899eea2852e9855fa30595e7a3176b70875 (patch) | |
tree | 5af0eb8659c9c6694126e2ad5b30a21b6458dd7c /src/Parser/Core.hs | |
parent | f91ff15b9551cd0d325dbd03f066d48dfd70ed25 (diff) |
Optional arguments and "flush" as a builtin
Diffstat (limited to 'src/Parser/Core.hs')
-rw-r--r-- | src/Parser/Core.hs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Parser/Core.hs b/src/Parser/Core.hs index f40889a..cb66529 100644 --- a/src/Parser/Core.hs +++ b/src/Parser/Core.hs @@ -139,13 +139,14 @@ unifyExpr off pa expr = if showType ( Just (ArgumentKeyword kw), SomeArgumentType atype ) = "`" <> kw <> " <" <> textExprType atype <> ">'" err = parseError . FancyError off . S.singleton . ErrorFail . T.unpack - defaults <- forM (M.toAscList remaining) $ \case - arg@(_, SomeArgumentType NoDefault) -> err $ "missing " <> showType arg <> " argument" - (kw, SomeArgumentType (ExprDefault def)) -> return (kw, SomeExpr def) + defaults <- fmap catMaybes $ forM (M.toAscList remaining) $ \case + arg@(_, SomeArgumentType RequiredArgument) -> err $ "missing " <> showType arg <> " argument" + (_, SomeArgumentType OptionalArgument) -> return Nothing + (kw, SomeArgumentType (ExprDefault def)) -> return $ Just ( kw, SomeExpr def ) (kw, SomeArgumentType atype@ContextDefault) -> do SomeExpr context <- gets testContext context' <- unifyExpr off atype context - return (kw, SomeExpr context') + return $ Just ( kw, SomeExpr context' ) return (FunctionEval $ ArgsApp (FunctionArguments $ M.fromAscList defaults) expr) | Just (Refl :: DynamicType :~: b) <- eqT |