Skip to content

Commit

Permalink
Implement getPath in terms of unfoldr
Browse files Browse the repository at this point in the history
  • Loading branch information
josephcsible committed Dec 31, 2023
1 parent 980e7d3 commit e1ad063
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/ShellCheck/ASTLib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -897,10 +897,9 @@ getUnmodifiedParameterExpansion t =
_ -> Nothing

--- A list of the element and all its parents up to the root node.
getPath tree t = t :
case Map.lookup (getId t) tree of
Nothing -> []
Just parent -> getPath tree parent
getPath tree t = t : unfoldr go t
where
go s = (\x -> (x,x)) <$> Map.lookup (getId s) tree

isClosingFileOp op =
case op of
Expand Down

0 comments on commit e1ad063

Please sign in to comment.