From 2adf4ee765bea81dca33fff2a87b5bc3354ed1c8 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Sat, 22 Jul 2017 16:59:38 -0400 Subject: [PATCH] =?UTF-8?q?Use=20Either=E2=80=99s=20MonadError=20instance?= =?UTF-8?q?=20to=20backtrack.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Data/Syntax/Assignment.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Data/Syntax/Assignment.hs b/src/Data/Syntax/Assignment.hs index 5e6a1c6ed..3481229ae 100644 --- a/src/Data/Syntax/Assignment.hs +++ b/src/Data/Syntax/Assignment.hs @@ -256,9 +256,9 @@ runAssignment toNode source assignment state = go assignment state >>= requireEx atEnd nodeError = case assignment of Location -> yield (Info.Range (stateOffset state) (stateOffset state) :. Info.Span (statePos state) (statePos state) :. Nil) state Many rule -> uncurry yield (runMany rule state) - Alt a b -> either (yield b . setStateError state . Just) Right (yield a state) + Alt a b -> yield a state `catchError` (yield b . setStateError state . Just) Throw e -> Left e - Catch during handler -> either (flip yield state . handler) Right (yield during state) + Catch during handler -> yield during state `catchError` (flip yield state . handler) _ -> Left (fromMaybe (Error (statePos state) expectedSymbols Nothing) nodeError) state | not (null expectedSymbols), all ((== Regular) . symbolType) expectedSymbols = dropAnonymous initialState