From e1ad06383425f46703a26aafc0d1bdc8ddc90a18 Mon Sep 17 00:00:00 2001 From: "Joseph C. Sible" <josephcsible@users.noreply.github.com> Date: Sun, 31 Dec 2023 01:59:53 -0500 Subject: [PATCH] Implement getPath in terms of unfoldr --- src/ShellCheck/ASTLib.hs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/ShellCheck/ASTLib.hs b/src/ShellCheck/ASTLib.hs index cf55498..5b3ffd8 100644 --- a/src/ShellCheck/ASTLib.hs +++ b/src/ShellCheck/ASTLib.hs @@ -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