From f09e9d9fa29284bd9ae872efe5ba1d526e349011 Mon Sep 17 00:00:00 2001 From: pacien Date: Wed, 26 Feb 2020 22:13:00 +0100 Subject: compiler: add tag inclusion and exclusion globs GitHub: closes #30 --- compiler/src/Input.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'compiler/src/Input.hs') diff --git a/compiler/src/Input.hs b/compiler/src/Input.hs index 75d1ed3..6ed7471 100644 --- a/compiler/src/Input.hs +++ b/compiler/src/Input.hs @@ -19,7 +19,7 @@ module Input ( decodeYamlFile , Sidecar(..) - , InputTree(..), readInputTree + , InputTree(..), readInputTree, filterInputTree ) where @@ -132,3 +132,14 @@ readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root findThumbnail :: [FSNode] -> Maybe Path findThumbnail = (fmap Files.path) . (find isThumbnail) + +-- | Filters an InputTree. The root is always returned. +filterInputTree :: (InputTree -> Bool) -> InputTree -> InputTree +filterInputTree cond = filterNode + where + filterNode :: InputTree -> InputTree + filterNode inputFile@InputFile{} = inputFile + filterNode inputDir@InputDir{items} = + filter cond items + & map filterNode + & \curatedItems -> inputDir { items = curatedItems } :: InputTree -- cgit v1.2.3