@@ -1,40 +1,33 @@
1--------------------------------------------------------------------------------
1--------------------------------------------------------------------------------
2−-- | Module providing pattern matching and capturing on 'Identifier's.
2+-- | As 'Identifier' is used to specify a single item, a 'Pattern' is used to
3−-- 'Pattern's come in two kinds:
3+-- specify a list of items.
5−-- * Simple glob patterns, like @foo\/*@;
5+-- In most cases, globs are used for patterns.
7−-- * Custom, arbitrary predicates of the type @Identifier -> Bool@.
9−-- They both have advantages and disadvantages. By default, globs are used,
10−-- unless you construct your 'Pattern' using the 'predicate' function.
12−-- A very simple pattern could be, for example, @foo\/bar@. This pattern will
7+-- A very simple pattern of such a pattern is @\"foo\/bar\"@. This pattern will
13-- only match the exact @foo\/bar@ identifier.
8-- only match the exact @foo\/bar@ identifier.
15-- To match more than one identifier, there are different captures that one can
10-- To match more than one identifier, there are different captures that one can
18−-- * @*@: matches at most one element of an identifier;
13+-- * @\"*\"@: matches at most one element of an identifier;
20−-- * @**@: matches one or more elements of an identifier.
15+-- * @\"**\"@: matches one or more elements of an identifier.
22-- Some examples:
17-- Some examples:
24−-- * @foo\/*@ will match @foo\/bar@ and @foo\/foo@, but not @foo\/bar\/qux@;
19+-- * @\"foo\/*\"@ will match @\"foo\/bar\"@ and @\"foo\/foo\"@, but not
20+-- @\"foo\/bar\/qux\"@;
26−-- * @**@ will match any identifier;
22+-- * @\"**\"@ will match any identifier;
28−-- * @foo\/**@ will match @foo\/bar@ and @foo\/bar\/qux@, but not @bar\/foo@;
24+-- * @\"foo\/**\"@ will match @\"foo\/bar\"@ and @\"foo\/bar\/qux\"@, but not
30−-- * @foo\/*.html@ will match all HTML files in the @foo\/@ directory.
27+-- * @\"foo\/*.html\"@ will match all HTML files in the @\"foo\/\"@ directory.
32-- The 'capture' function allows the user to get access to the elements captured
29-- The 'capture' function allows the user to get access to the elements captured
33-- by the capture elements in the pattern.
30-- by the capture elements in the pattern.
35−-- Like an 'Identifier', a 'Pattern' also has a type parameter. This is simply
36−-- an extra layer of safety, and can be discarded using the 'castPattern'
38module Hakyll.Core.Identifier.Pattern
31module Hakyll.Core.Identifier.Pattern
39 ( -- * The pattern type
32 ( -- * The pattern type
@@ -213,8 +206,8 @@ withVersion p v = optimize $ And p $ fromVersion $ Just v
215--------------------------------------------------------------------------------
208--------------------------------------------------------------------------------
216−-- | Check if a pattern is a literal. @"*.markdown"@ is not a literal but
209+-- | Check if a pattern is a literal. @\"*.markdown\"@ is not a literal but
217−-- @"posts.markdown"@ is.
210+-- @\"posts.markdown\"@ is.
218fromLiteral :: Pattern -> Maybe Identifier
211fromLiteral :: Pattern -> Maybe Identifier
219fromLiteral pattern = case pattern of
212fromLiteral pattern = case pattern of
220 Glob p -> fmap fromFilePath $ foldr fromLiteral' (Just "") p
213 Glob p -> fmap fromFilePath $ foldr fromLiteral' (Just "") p