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.
This commit is contained in:
parent
dadfdfde97
commit
5f1c969546
|
@ -240,8 +240,9 @@ getParentTree t =
|
||||||
where
|
where
|
||||||
pre t = modify (first ((:) t))
|
pre t = modify (first ((:) t))
|
||||||
post t = do
|
post t = do
|
||||||
(_:rest, map) <- get
|
(x, map) <- get
|
||||||
case rest of [] -> put (rest, map)
|
case x of
|
||||||
|
_:rest -> case rest of [] -> put (rest, map)
|
||||||
(x:_) -> put (rest, Map.insert (getId t) x map)
|
(x:_) -> put (rest, Map.insert (getId t) x map)
|
||||||
|
|
||||||
-- Given a root node, make a map from Id to Token
|
-- Given a root node, make a map from Id to Token
|
||||||
|
|
Loading…
Reference in New Issue