Add function to construct predicates
commitb7059a0f1a05db0b2e33efae935ece65f97ea3fc
authorJasper Van der Jeugt <jaspervdj@gmail.com>
dateTue 5 Apr 2011, 11:46 (16 years ago)
parent091014a
src/Hakyll/Core/Identifier/Pattern.hs+10
@@ -34,6 +34,7 @@
3434module Hakyll.Core.Identifier.Pattern
3535 ( Pattern
3636 , parseGlob
37+ , predicate
3738 , matches
3839 , filterMatches
3940 , capture
@@ -80,6 +81,15 @@ parseGlob = Glob . parse'
8081 ('*' : xs) -> Literal chunk : Capture : parse' xs
8182 xs -> Literal chunk : Literal xs : []
8283
84+-- | Create a 'Pattern' from an arbitrary predicate
85+--
86+-- Example:
87+--
88+-- > predicate (\i -> matches "foo/*" i && not (matches "foo/bar" i))
89+--
90+predicate :: (Identifier -> Bool) -> Pattern
91+predicate = Predicate
92+
8393-- | Check if an identifier matches a pattern
8494--
8595matches :: Pattern -> Identifier -> Bool