From 54db7e27ef5e37ef99440e951a42a4ae6ca1da85 Mon Sep 17 00:00:00 2001 From: rhiannon morris Date: Thu, 21 Dec 2023 17:53:46 +0100 Subject: [PATCH] make #[fail] run in the current namespace --- lib/Quox/Parser/FromParser.idr | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Quox/Parser/FromParser.idr b/lib/Quox/Parser/FromParser.idr index b252f73..5907663 100644 --- a/lib/Quox/Parser/FromParser.idr +++ b/lib/Quox/Parser/FromParser.idr @@ -45,7 +45,8 @@ FromParserIO = FromParserPure ++ [LoadFile] export -fromParserPure : NameSuf -> Definitions -> +fromParserPure : {default [<] ns : Mods} -> + NameSuf -> Definitions -> Eff FromParserPure a -> Either Error (a, NameSuf, Definitions) fromParserPure suf defs act = runSTErr $ do @@ -54,7 +55,7 @@ fromParserPure suf defs act = runSTErr $ do res <- runEff act $ with Union.(::) [handleExcept (\e => stLeft e), handleStateSTRef defs, - handleStateSTRef !(liftST $ newSTRef [<]), + handleStateSTRef !(liftST $ newSTRef ns), handleStateSTRef suf] pure (res, !(liftST $ readSTRef suf), !(liftST $ readSTRef defs)) @@ -375,7 +376,7 @@ data HasFail = NoFail | AnyFail | FailWith String export covering expectFail : Loc -> Eff FromParserPure a -> Eff FromParserPure Error expectFail loc act = - case fromParserPure !(getAt GEN) !(getAt DEFS) act of + case fromParserPure !(getAt GEN) !(getAt DEFS) {ns = !(getAt NS)} act of Left err => pure err Right _ => throw $ ExpectedFail loc