From 5f1c96954674289f3546094ca08bb244ad790911 Mon Sep 17 00:00:00 2001 From: Peter Simons Date: Thu, 27 Sep 2018 17:30:41 +0200 Subject: [PATCH] getParentTree: avoid pattern matching in do notation Pattern matching in "do" requires a MonadFail context, which we don't have in pure code. Instead, we'll use "case-of" to bind the part of the state that we're interested in. --- src/ShellCheck/AnalyzerLib.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ShellCheck/AnalyzerLib.hs b/src/ShellCheck/AnalyzerLib.hs index 5820cc7..de3498d 100644 --- a/src/ShellCheck/AnalyzerLib.hs +++ b/src/ShellCheck/AnalyzerLib.hs @@ -240,9 +240,10 @@ getParentTree t = where pre t = modify (first ((:) t)) post t = do - (_:rest, map) <- get - case rest of [] -> put (rest, map) - (x:_) -> put (rest, Map.insert (getId t) x map) + (x, map) <- get + case x of + _:rest -> case rest of [] -> put (rest, map) + (x:_) -> put (rest, Map.insert (getId t) x map) -- Given a root node, make a map from Id to Token getTokenMap :: Token -> Map.Map Id Token -- GitLab