Skip to content

Commit 41af101

Browse files
committed
nar: pattern match instead of head
1 parent 7bde7a8 commit 41af101

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

hnix-store-nar/src/System/Nix/Nar/Parser.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ parseSymlink = do
211211
currentDirectoryAndFile :: Monad m => NarParser m (FilePath, FilePath)
212212
currentDirectoryAndFile = do
213213
dirStack <- State.gets directoryStack
214-
pure (List.foldr1 (</>) (List.reverse $ drop 1 dirStack), head dirStack)
214+
case dirStack of
215+
(x:xs) -> pure (List.foldr1 (</>) (List.reverse xs), x)
216+
_ -> error "currentDirectoryAndFile: empty dirStack"
215217

216218
-- | Internal data type representing symlinks encountered in the NAR
217219
data LinkInfo = LinkInfo

0 commit comments

Comments
 (0)