From 237ffea2943fe27f47e8536b5123a414fc0ada25 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Wed, 4 Apr 2018 19:07:03 +1000 Subject: [PATCH] alternate with End in putRubyLocals --- src/Assigning/Assignment.hs | 6 ++++-- src/Language/Ruby/Assignment.hs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Assigning/Assignment.hs b/src/Assigning/Assignment.hs index 8c845f922..676b9af40 100644 --- a/src/Assigning/Assignment.hs +++ b/src/Assigning/Assignment.hs @@ -147,8 +147,10 @@ location = tracing Location `Then` return getRubyLocals :: HasCallStack => Assignment ast grammar [ByteString] getRubyLocals = tracing GetRubyLocals `Then` return -putRubyLocals :: HasCallStack => [ByteString] -> Assignment ast grammar () -putRubyLocals l = tracing (PutRubyLocals l) `Then` return +putRubyLocals :: (HasCallStack, Enum grammar, Eq1 ast, Ix grammar) => [ByteString] -> Assignment ast grammar () +putRubyLocals l = mk (PutRubyLocals l) <|> mk End + where + mk a = tracing a `Then` return -- | Zero-width production of the current node. currentNode :: HasCallStack => Assignment ast grammar (TermF ast (Node grammar) ()) diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index 0203cb119..729616a4e 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -147,14 +147,14 @@ expressions = makeTerm'' <$> location <*> many expression parenthesizedExpressions :: Assignment parenthesizedExpressions = makeTerm'' <$> symbol ParenthesizedStatements <*> children (Syntax.Paren <$> expressions) -withExtendedScope :: Assignment.Assignment ast grammar a -> Assignment.Assignment ast grammar a +withExtendedScope :: (Enum grammar, Ix grammar, Eq1 ast) => Assignment.Assignment ast grammar a -> Assignment.Assignment ast grammar a withExtendedScope inner = do locals <- getRubyLocals result <- inner putRubyLocals locals pure result -withNewScope :: Assignment.Assignment ast grammar a -> Assignment.Assignment ast grammar a +withNewScope :: (Enum grammar, Ix grammar, Eq1 ast) => Assignment.Assignment ast grammar a -> Assignment.Assignment ast grammar a withNewScope inner = withExtendedScope $ do putRubyLocals [] inner