@@ -28,7 +28,7 @@
2828--
2929-- The 'capture' function allows the user to get access to the elements captured
3030-- by the capture elements in a glob or regex pattern.
31−{-# LANGUAGE CPP #-}
31+{-# OPTIONS_GHC -fno-warn-orphans #-}
3232module Hakyll.Core.Identifier.Pattern
3333 ( -- * The pattern type
3434 Pattern
@@ -58,80 +58,22 @@ module Hakyll.Core.Identifier.Pattern
5858
5959
6060--------------------------------------------------------------------------------
61−import Control.Arrow ((&&&), (>>>))
62−import Control.Monad (msum)
63−import Data.Binary (Binary (..), getWord8, putWord8)
64−import Data.List (inits, isPrefixOf, tails)
65−import Data.Maybe (isJust)
66−#if MIN_VERSION_base(4,9,0)
67−import Data.Semigroup (Semigroup (..))
68−#endif
69−import Data.Set (Set)
70−import qualified Data.Set as S
61+import Control.Arrow ((&&&), (>>>))
62+import Control.Monad (msum)
63+import Data.List (inits, isPrefixOf,
64+ tails)
65+import Data.Maybe (isJust)
66+import qualified Data.Set as S
7167
7268
7369--------------------------------------------------------------------------------
74−import GHC.Exts (IsString, fromString)
75−import Text.Regex.TDFA ((=~))
70+import GHC.Exts (IsString, fromString)
71+import Text.Regex.TDFA ((=~))
7672
7773
7874--------------------------------------------------------------------------------
7975import Hakyll.Core.Identifier
80−
81−
82−--------------------------------------------------------------------------------
83−-- | Elements of a glob pattern
84−data GlobComponent
85− = Capture
86− | CaptureMany
87− | Literal String
88− deriving (Eq, Show)
89−
90−
91−--------------------------------------------------------------------------------
92−instance Binary GlobComponent where
93− put Capture = putWord8 0
94− put CaptureMany = putWord8 1
95− put (Literal s) = putWord8 2 >> put s
96−
97− get = getWord8 >>= \t -> case t of
98− 0 -> pure Capture
99− 1 -> pure CaptureMany
100− 2 -> Literal <$> get
101− _ -> error "Data.Binary.get: Invalid GlobComponent"
102−
103−
104−--------------------------------------------------------------------------------
105−-- | Type that allows matching on identifiers
106−data Pattern
107− = Everything
108− | Complement Pattern
109− | And Pattern Pattern
110− | Glob [GlobComponent]
111− | List (Set Identifier)
112− | Regex String
113− | Version (Maybe String)
114− deriving (Show)
115−
116−
117−--------------------------------------------------------------------------------
118−instance Binary Pattern where
119− put Everything = putWord8 0
120− put (Complement p) = putWord8 1 >> put p
121− put (And x y) = putWord8 2 >> put x >> put y
122− put (Glob g) = putWord8 3 >> put g
123− put (List is) = putWord8 4 >> put is
124− put (Regex r) = putWord8 5 >> put r
125− put (Version v) = putWord8 6 >> put v
126−
127− get = getWord8 >>= \t -> case t of
128− 0 -> pure Everything
129− 1 -> Complement <$> get
130− 2 -> And <$> get <*> get
131− 3 -> Glob <$> get
132− 4 -> List <$> get
133− 5 -> Regex <$> get
134− _ -> Version <$> get
76+import Hakyll.Core.Identifier.Pattern.Internal
13577
13678
13779--------------------------------------------------------------------------------
@@ -139,21 +81,6 @@ instance IsString Pattern where
13981 fromString = fromGlob
14082
14183
142−--------------------------------------------------------------------------------
143−#if MIN_VERSION_base(4,9,0)
144−instance Semigroup Pattern where
145− (<>) = (.&&.)
146−
147−instance Monoid Pattern where
148− mempty = Everything
149− mappend = (<>)
150−#else
151−instance Monoid Pattern where
152− mempty = Everything
153− mappend = (.&&.)
154−#endif
155−
156−
15784--------------------------------------------------------------------------------
15885-- | Parse a pattern from a string
15986fromGlob :: String -> Pattern