on master help sign in
Type-safe identifiers
commit758e0beaaa2f9f97bb22fa4067d75efda4dbd31b authorJasper Van der Jeugt <jaspervdj@gmail.com> dateTue 24 May 2011, 11:58 (15 years ago) parent41b7f37
14 files changed+104−87
src/Hakyll/Core/Compiler.hs+14−12 src/Hakyll/Core/Compiler/Internal.hs+12−12 src/Hakyll/Core/Identifier.hs+21−8 src/Hakyll/Core/Identifier/Pattern.hs+11−10 src/Hakyll/Core/Resource.hs+2−2 src/Hakyll/Core/Routes.hs+6−5 src/Hakyll/Core/Rules.hs+10−10 src/Hakyll/Core/Rules/Internal.hs+2−2 src/Hakyll/Core/Run.hs+5−5 src/Hakyll/Core/Store.hs+3−3 src/Hakyll/Core/Writable.hs+2−2 src/Hakyll/Web/Pandoc.hs+9−9 src/Hakyll/Web/Tags.hs+6−6 src/Hakyll/Web/Template.hs+1−1
src/Hakyll/Core/Compiler.hs+14−12
@@ -142,9 +142,9 @@ import Hakyll.Core.Logger
142142-- version of 'runCompilerJob' also stores the result
143143--
144144runCompiler :: Compiler () CompileRule -- ^ Compiler to run
145− -> Identifier -- ^ Target identifier
145+ -> Identifier () -- ^ Target identifier
146146 -> ResourceProvider -- ^ Resource provider
147− -> [Identifier] -- ^ Universe
147+ -> [Identifier ()] -- ^ Universe
148148 -> Routes -- ^ Route
149149 -> Store -- ^ Store
150150 -> Bool -- ^ Was the resource modified?
@@ -161,7 +161,8 @@ runCompiler compiler id' provider universe routes store modified logger = do
161161 -- before we return control. This makes sure the compiled item can later
162162 -- be accessed by e.g. require.
163163 Right (CompileRule (CompiledItem x)) ->
164− storeSet store "Hakyll.Core.Compiler.runCompiler" id' x
164+ storeSet store "Hakyll.Core.Compiler.runCompiler"
165+ (castIdentifier id') x
165166
166167 -- Otherwise, we do nothing here
167168 _ -> return ()
@@ -170,8 +171,9 @@ runCompiler compiler id' provider universe routes store modified logger = do
170171
171172-- | Get the identifier of the item that is currently being compiled
172173--
173−getIdentifier :: Compiler a Identifier
174−getIdentifier = fromJob $ const $ CompilerM $ compilerIdentifier <$> ask
174+getIdentifier :: Compiler a (Identifier b)
175+getIdentifier = fromJob $ const $ CompilerM $
176+ castIdentifier . compilerIdentifier <$> ask
175177
176178-- | Get the route we are using for this item
177179--
@@ -180,7 +182,7 @@ getRoute = getIdentifier >>> getRouteFor
180182
181183-- | Get the route for a specified item
182184--
183−getRouteFor :: Compiler Identifier (Maybe FilePath)
185+getRouteFor :: Compiler (Identifier a) (Maybe FilePath)
184186getRouteFor = fromJob $ \identifier -> CompilerM $ do
185187 routes <- compilerRoutes <$> ask
186188 return $ runRoutes routes identifier
@@ -212,7 +214,7 @@ getResourceWith reader = fromJob $ \resource -> CompilerM $ do
212214-- | Auxiliary: get a dependency
213215--
214216getDependency :: (Binary a, Writable a, Typeable a)
215− => Identifier -> CompilerM a
217+ => Identifier a -> CompilerM a
216218getDependency id' = CompilerM $ do
217219 store <- compilerStore <$> ask
218220 result <- liftIO $ storeGet store "Hakyll.Core.Compiler.runCompiler" id'
@@ -233,7 +235,7 @@ getDependency id' = CompilerM $ do
233235-- | Variant of 'require' which drops the current value
234236--
235237require_ :: (Binary a, Typeable a, Writable a)
236− => Identifier
238+ => Identifier a
237239 -> Compiler b a
238240require_ identifier =
239241 fromDependency identifier >>> fromJob (const $ getDependency identifier)
@@ -242,7 +244,7 @@ require_ identifier =
242244-- dependencies
243245--
244246require :: (Binary a, Typeable a, Writable a)
245− => Identifier
247+ => Identifier a
246248 -> (b -> a -> c)
247249 -> Compiler b c
248250require identifier = requireA identifier . arr . uncurry
@@ -250,7 +252,7 @@ require identifier = requireA identifier . arr . uncurry
250252-- | Arrow-based variant of 'require'
251253--
252254requireA :: (Binary a, Typeable a, Writable a)
253− => Identifier
255+ => Identifier a
254256 -> Compiler (b, a) c
255257 -> Compiler b c
256258requireA identifier = (id &&& require_ identifier >>>)
@@ -262,7 +264,7 @@ requireAll_ :: (Binary a, Typeable a, Writable a)
262264 -> Compiler b [a]
263265requireAll_ pattern = fromDependencies (const getDeps) >>> fromJob requireAll_'
264266 where
265− getDeps = filterMatches pattern
267+ getDeps = map castIdentifier . filterMatches pattern . map castIdentifier
266268 requireAll_' = const $ CompilerM $ do
267269 deps <- getDeps . compilerUniverse <$> ask
268270 mapM (unCompilerM . getDependency) deps
@@ -290,7 +292,7 @@ cached :: (Binary a, Typeable a, Writable a)
290292 -> Compiler Resource a
291293cached name (Compiler d j) = Compiler d $ const $ CompilerM $ do
292294 logger <- compilerLogger <$> ask
293− identifier <- compilerIdentifier <$> ask
295+ identifier <- castIdentifier . compilerIdentifier <$> ask
294296 store <- compilerStore <$> ask
295297 modified <- compilerResourceModified <$> ask
296298 report logger $ "Checking cache: " ++ if modified then "modified" else "OK"
src/Hakyll/Core/Compiler/Internal.hs+12−12
@@ -33,26 +33,26 @@ import Hakyll.Core.Logger
3333
3434-- | A set of dependencies
3535--
36−type Dependencies = Set Identifier
36+type Dependencies = Set (Identifier ())
3737
3838-- | Environment in which the dependency analyzer runs
3939--
4040data DependencyEnvironment = DependencyEnvironment
4141 { -- | Target identifier
42− dependencyIdentifier :: Identifier
42+ dependencyIdentifier :: Identifier ()
4343 , -- | List of available identifiers we can depend upon
44− dependencyUniverse :: [Identifier]
44+ dependencyUniverse :: [Identifier ()]
4545 }
4646
4747-- | Environment in which a compiler runs
4848--
4949data CompilerEnvironment = CompilerEnvironment
5050 { -- | Target identifier
51− compilerIdentifier :: Identifier
51+ compilerIdentifier :: Identifier ()
5252 , -- | Resource provider
5353 compilerResourceProvider :: ResourceProvider
5454 , -- | List of all known identifiers
55− compilerUniverse :: [Identifier]
55+ compilerUniverse :: [Identifier ()]
5656 , -- | Site routes
5757 compilerRoutes :: Routes
5858 , -- | Compiler store
@@ -107,9 +107,9 @@ instance ArrowChoice Compiler where
107107-- | Run a compiler, yielding the resulting target
108108--
109109runCompilerJob :: Compiler () a -- ^ Compiler to run
110− -> Identifier -- ^ Target identifier
110+ -> Identifier () -- ^ Target identifier
111111 -> ResourceProvider -- ^ Resource provider
112− -> [Identifier] -- ^ Universe
112+ -> [Identifier ()] -- ^ Universe
113113 -> Routes -- ^ Route
114114 -> Store -- ^ Store
115115 -> Bool -- ^ Was the resource modified?
@@ -129,8 +129,8 @@ runCompilerJob compiler id' provider universe route store modified logger =
129129 }
130130
131131runCompilerDependencies :: Compiler () a
132− -> Identifier
133− -> [Identifier]
132+ -> Identifier ()
133+ -> [Identifier ()]
134134 -> Dependencies
135135runCompilerDependencies compiler identifier universe =
136136 runReader (compilerDependencies compiler) env
@@ -144,7 +144,7 @@ fromJob :: (a -> CompilerM b)
144144 -> Compiler a b
145145fromJob = Compiler (return S.empty)
146146
147−fromDependencies :: (Identifier -> [Identifier] -> [Identifier])
147+fromDependencies :: (Identifier () -> [Identifier ()] -> [Identifier ()])
148148 -> Compiler b b
149149fromDependencies collectDeps = flip Compiler return $ do
150150 DependencyEnvironment identifier universe <- ask
@@ -152,5 +152,5 @@ fromDependencies collectDeps = flip Compiler return $ do
152152
153153-- | Wait until another compiler has finished before running this compiler
154154--
155−fromDependency :: Identifier -> Compiler a a
156−fromDependency = fromDependencies . const . const . return
155+fromDependency :: Identifier a -> Compiler b b
156+fromDependency = fromDependencies . const . const . return . castIdentifier
src/Hakyll/Core/Identifier.hs+21−8
@@ -23,6 +23,7 @@
2323{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable #-}
2424module Hakyll.Core.Identifier
2525 ( Identifier (..)
26+ , castIdentifier
2627 , parseIdentifier
2728 , toFilePath
2829 , setGroup
@@ -40,30 +41,42 @@ import Data.Typeable (Typeable)
4041
4142-- | An identifier used to uniquely identify a value
4243--
43−data Identifier = Identifier
44+-- The @a@ is used to denote the type that the identifier points to. It is a
45+-- phantom type parameter, meaning you can safely change this if you know what
46+-- you are doing.
47+--
48+-- If the @a@ type is not known, Hakyll traditionally uses @Identifier ()@.
49+--
50+data Identifier a = Identifier
4451 { identifierGroup :: Maybe String
4552 , identifierPath :: String
4653 } deriving (Eq, Ord, Typeable)
4754
48−instance Monoid Identifier where
55+instance Monoid (Identifier a) where
4956 mempty = Identifier Nothing ""
5057 Identifier g1 p1 `mappend` Identifier g2 p2 =
5158 Identifier (g1 `mplus` g2) (p1 `mappend` p2)
5259
53−instance Binary Identifier where
60+instance Binary (Identifier a) where
5461 put (Identifier g p) = put g >> put p
5562 get = Identifier <$> get <*> get
5663
57−instance Show Identifier where
64+instance Show (Identifier a) where
5865 show i@(Identifier Nothing _) = toFilePath i
5966 show i@(Identifier (Just g) _) = toFilePath i ++ " (" ++ g ++ ")"
6067
61−instance IsString Identifier where
68+instance IsString (Identifier a) where
6269 fromString = parseIdentifier
6370
71+-- | Discard the phantom type parameter of an identifier
72+--
73+castIdentifier :: Identifier a -> Identifier b
74+castIdentifier (Identifier g p) = Identifier g p
75+{-# INLINE castIdentifier #-}
76+
6477-- | Parse an identifier from a string
6578--
66−parseIdentifier :: String -> Identifier
79+parseIdentifier :: String -> Identifier a
6780parseIdentifier = Identifier Nothing
6881 . intercalate "/" . filter (not . null) . split'
6982 where
@@ -73,10 +86,10 @@ parseIdentifier = Identifier Nothing
7386
7487-- | Convert an identifier to a relative 'FilePath'
7588--
76−toFilePath :: Identifier -> FilePath
89+toFilePath :: Identifier a -> FilePath
7790toFilePath = identifierPath
7891
7992-- | Set the identifier group for some identifier
8093--
81−setGroup :: Maybe String -> Identifier -> Identifier
94+setGroup :: Maybe String -> Identifier a -> Identifier a
8295setGroup g (Identifier _ p) = Identifier g p
src/Hakyll/Core/Identifier/Pattern.hs+11−10
@@ -66,8 +66,8 @@ data GlobComponent = Capture
6666-- | Type that allows matching on identifiers
6767--
6868data Pattern a = Glob [GlobComponent]
69− | Predicate (Identifier -> Bool)
70− | List [Identifier]
69+ | Predicate (Identifier a -> Bool)
70+ | List [Identifier a]
7171
7272instance IsString (Pattern a) where
7373 fromString = parseGlob
@@ -80,8 +80,9 @@ instance Monoid (Pattern a) where
8080--
8181castPattern :: Pattern a -> Pattern b
8282castPattern (Glob g) = Glob g
83−castPattern (Predicate p) = Predicate p
84−castPattern (List l) = List l
83+castPattern (Predicate p) = Predicate $ p . castIdentifier
84+castPattern (List l) = List $ map castIdentifier l
85+{-# INLINE castPattern #-}
8586
8687-- | Parse a pattern from a string
8788--
@@ -102,7 +103,7 @@ parseGlob = Glob . parse'
102103--
103104-- > predicate (\i -> matches "foo/*" i && not (matches "foo/bar" i))
104105--
105−predicate :: (Identifier -> Bool) -> Pattern a
106+predicate :: (Identifier a -> Bool) -> Pattern a
106107predicate = Predicate
107108
108109-- | Create a 'Pattern' from a regex
@@ -122,14 +123,14 @@ inGroup group = predicate $ (== group) . identifierGroup
122123
123124-- | Check if an identifier matches a pattern
124125--
125−matches :: Pattern a -> Identifier -> Bool
126+matches :: Pattern a -> Identifier a -> Bool
126127matches (Glob p) = isJust . capture (Glob p)
127128matches (Predicate p) = (p $)
128129matches (List l) = (`elem` l)
129130
130131-- | Given a list of identifiers, retain only those who match the given pattern
131132--
132−filterMatches :: Pattern a -> [Identifier] -> [Identifier]
133+filterMatches :: Pattern a -> [Identifier a] -> [Identifier a]
133134filterMatches = filter . matches
134135
135136-- | Split a list at every possible point, generate a list of (init, tail)
@@ -140,7 +141,7 @@ splits = inits &&& tails >>> uncurry zip >>> reverse
140141
141142-- | Match a glob against a pattern, generating a list of captures
142143--
143−capture :: Pattern a -> Identifier -> Maybe [String]
144+capture :: Pattern a -> Identifier a -> Maybe [String]
144145capture (Glob p) (Identifier _ i) = capture' p i
145146capture _ _ = Nothing
146147
@@ -172,13 +173,13 @@ capture' (CaptureMany : ms) str =
172173--
173174-- > "tags/foo"
174175--
175−fromCapture :: Pattern a -> String -> Identifier
176+fromCapture :: Pattern a -> String -> Identifier a
176177fromCapture pattern = fromCaptures pattern . repeat
177178
178179-- | Create an identifier from a pattern by filling in the captures with the
179180-- given list of strings
180181--
181−fromCaptures :: Pattern a -> [String] -> Identifier
182+fromCaptures :: Pattern a -> [String] -> Identifier a
182183fromCaptures (Glob p) = Identifier Nothing . fromCaptures' p
183184fromCaptures _ = error $
184185 "Hakyll.Core.Identifier.Pattern.fromCaptures: fromCaptures only works " ++
src/Hakyll/Core/Resource.hs+2−2
@@ -15,10 +15,10 @@ newtype Resource = Resource {unResource :: String}
1515
1616-- | Create a resource from an identifier
1717--
18−fromIdentifier :: Identifier -> Resource
18+fromIdentifier :: Identifier a -> Resource
1919fromIdentifier = Resource . toFilePath
2020
2121-- | Map the resource to an identifier. Note that the group will not be set!
2222--
23−toIdentifier :: Resource -> Identifier
23+toIdentifier :: Resource -> Identifier a
2424toIdentifier = parseIdentifier . unResource
src/Hakyll/Core/Routes.hs+6−5
@@ -25,6 +25,7 @@
2525--
2626-- * If an item matches multiple routes, the first rule will be chosen.
2727--
28+{-# LANGUAGE Rank2Types #-}
2829module Hakyll.Core.Routes
2930 ( Routes
3031 , runRoutes
@@ -46,7 +47,7 @@ import Hakyll.Core.Util.String
4647
4748-- | Type used for a route
4849--
49−newtype Routes = Routes {unRoutes :: Identifier -> Maybe FilePath}
50+newtype Routes = Routes {unRoutes :: forall a. Identifier a -> Maybe FilePath}
5051
5152instance Monoid Routes where
5253 mempty = Routes $ const Nothing
@@ -54,7 +55,7 @@ instance Monoid Routes where
5455
5556-- | Apply a route to an identifier
5657--
57−runRoutes :: Routes -> Identifier -> Maybe FilePath
58+runRoutes :: Routes -> Identifier a -> Maybe FilePath
5859runRoutes = unRoutes
5960
6061-- | A route that uses the identifier as filepath. For example, the target with
@@ -90,13 +91,13 @@ setExtension extension = Routes $ fmap (`replaceExtension` extension)
9091--
9192matchRoute :: Pattern a -> Routes -> Routes
9293matchRoute pattern (Routes route) = Routes $ \id' ->
93− if matches pattern id' then route id' else Nothing
94+ if matches pattern (castIdentifier id') then route id' else Nothing
9495
9596-- | Create a custom route. This should almost always be used with
9697-- 'matchRoute'
9798--
98−customRoute :: (Identifier -> FilePath) -> Routes
99−customRoute f = Routes $ Just . f
99+customRoute :: (Identifier a -> FilePath) -> Routes
100+customRoute f = Routes $ Just . f . castIdentifier
100101
101102-- | Create a gsub route
102103--
src/Hakyll/Core/Rules.hs+10−10
@@ -31,7 +31,7 @@ module Hakyll.Core.Rules
3131import Control.Applicative ((<$>))
3232import Control.Monad.Writer (tell)
3333import Control.Monad.Reader (ask, local)
34−import Control.Arrow (second, (>>>), arr, (>>^), (***))
34+import Control.Arrow ((>>>), arr, (>>^), (***))
3535import Control.Monad.State (get, put)
3636import Data.Monoid (mempty, mappend)
3737import qualified Data.Set as S
@@ -58,13 +58,13 @@ tellRoute route' = RulesM $ tell $ RuleSet route' mempty mempty
5858-- | Add a number of compilers
5959--
6060tellCompilers :: (Binary a, Typeable a, Writable a)
61− => [(Identifier, Compiler () a)]
61+ => [(Identifier a, Compiler () a)]
6262 -> Rules
6363tellCompilers compilers = RulesM $ do
6464 -- We box the compilers so they have a more simple type, and we apply the
6565 -- current group to the corresponding identifiers
66− group' <- rulesGroup <$> ask
67− let compilers' = map (setGroup group' *** boxCompiler) compilers
66+ g <- rulesGroup <$> ask
67+ let compilers' = map (setGroup g . castIdentifier *** boxCompiler) compilers
6868 tell $ RuleSet mempty compilers' mempty
6969 where
7070 boxCompiler = (>>> arr compiledItem >>> arr CompileRule)
@@ -143,7 +143,7 @@ compile compiler = do
143143-- actual content itself.
144144--
145145create :: (Binary a, Typeable a, Writable a)
146− => Identifier -> Compiler () a -> Rules
146+ => Identifier a -> Compiler () a -> Rules
147147create identifier compiler = tellCompilers [(identifier, compiler)]
148148
149149-- | Add a route.
@@ -160,7 +160,7 @@ route route' = RulesM $ do
160160
161161-- | Get a list of resources matching the current pattern
162162--
163−resources :: RulesM [Identifier]
163+resources :: RulesM [Identifier a]
164164resources = RulesM $ do
165165 pattern <- rulesPattern <$> ask
166166 provider <- rulesResourceProvider <$> ask
@@ -197,7 +197,7 @@ resources = RulesM $ do
197197-- which items must be rendered.
198198--
199199metaCompile :: (Binary a, Typeable a, Writable a)
200− => Compiler () [(Identifier, Compiler () a)]
200+ => Compiler () [(Identifier a, Compiler () a)]
201201 -- ^ Compiler generating the other compilers
202202 -> Rules
203203 -- ^ Resulting rules
@@ -217,9 +217,9 @@ metaCompile compiler = RulesM $ do
217217-- the metacompiler.
218218--
219219metaCompileWith :: (Binary a, Typeable a, Writable a)
220− => Identifier
220+ => Identifier ()
221221 -- ^ Identifier for this compiler
222− -> Compiler () [(Identifier, Compiler () a)]
222+ -> Compiler () [(Identifier a, Compiler () a)]
223223 -- ^ Compiler generating the other compilers
224224 -> Rules
225225 -- ^ Resulting rules
@@ -229,7 +229,7 @@ metaCompileWith identifier compiler = RulesM $ do
229229 let -- Set the correct group on the identifier
230230 id' = setGroup group' identifier
231231 -- Function to box an item into a rule
232− makeRule = MetaCompileRule . map (second box)
232+ makeRule = MetaCompileRule . map (castIdentifier *** box)
233233 -- Entire boxing function
234234 box = (>>> fromDependency id' >>^ CompileRule . compiledItem)
235235 -- Resulting compiler list
src/Hakyll/Core/Rules/Internal.hs+2−2
@@ -35,7 +35,7 @@ import Hakyll.Core.CompiledItem
3535-- added to the runtime if possible, since other items might depend upon them.
3636--
3737data CompileRule = CompileRule CompiledItem
38− | MetaCompileRule [(Identifier, Compiler () CompileRule)]
38+ | MetaCompileRule [(Identifier (), Compiler () CompileRule)]
3939
4040-- | A collection of rules for the compilation process
4141--
@@ -43,7 +43,7 @@ data RuleSet = RuleSet
4343 { -- | Routes used in the compilation structure
4444 rulesRoutes :: Routes
4545 , -- | Compilation rules
46− rulesCompilers :: [(Identifier, Compiler () CompileRule)]
46+ rulesCompilers :: [(Identifier (), Compiler () CompileRule)]
4747 , -- | A list of the used resources
4848 rulesResources :: Set Resource
4949 }
src/Hakyll/Core/Run.hs+5−5
@@ -89,8 +89,8 @@ data RuntimeEnvironment = RuntimeEnvironment
8989 }
9090
9191data RuntimeState = RuntimeState
92− { hakyllAnalyzer :: DependencyAnalyzer Identifier
93− , hakyllCompilers :: Map Identifier (Compiler () CompileRule)
92+ { hakyllAnalyzer :: DependencyAnalyzer (Identifier ())
93+ , hakyllCompilers :: Map (Identifier ()) (Compiler () CompileRule)
9494 }
9595
9696newtype Runtime a = Runtime
@@ -99,7 +99,7 @@ newtype Runtime a = Runtime
9999
100100-- | Add a number of compilers and continue using these compilers
101101--
102−addNewCompilers :: [(Identifier, Compiler () CompileRule)]
102+addNewCompilers :: [(Identifier (), Compiler () CompileRule)]
103103 -- ^ Compilers to add
104104 -> Runtime ()
105105addNewCompilers newCompilers = Runtime $ do
@@ -157,14 +157,14 @@ stepAnalyzer = Runtime $ do
157157
158158-- | Dump cyclic error and quit
159159--
160−dumpCycle :: [Identifier] -> Runtime ()
160+dumpCycle :: [Identifier ()] -> Runtime ()
161161dumpCycle cycle' = Runtime $ do
162162 logger <- hakyllLogger <$> ask
163163 section logger "Dependency cycle detected! Conflict:"
164164 forM_ (zip cycle' $ drop 1 cycle') $ \(x, y) ->
165165 report logger $ show x ++ " -> " ++ show y
166166
167−build :: Identifier -> Runtime ()
167+build :: Identifier () -> Runtime ()
168168build id' = Runtime $ do
169169 logger <- hakyllLogger <$> ask
170170 routes <- hakyllRoutes <$> ask
src/Hakyll/Core/Store.hs+3−3
@@ -60,7 +60,7 @@ addToMap store path value =
6060
6161-- | Create a path
6262--
63−makePath :: Store -> String -> Identifier -> FilePath
63+makePath :: Store -> String -> Identifier a -> FilePath
6464makePath store name identifier = storeDirectory store </> name
6565 </> group </> toFilePath identifier </> "hakyllstore"
6666 where
@@ -69,7 +69,7 @@ makePath store name identifier = storeDirectory store </> name
6969-- | Store an item
7070--
7171storeSet :: (Binary a, Typeable a)
72− => Store -> String -> Identifier -> a -> IO ()
72+ => Store -> String -> Identifier a -> a -> IO ()
7373storeSet store name identifier value = do
7474 makeDirectories path
7575 encodeFile path value
@@ -80,7 +80,7 @@ storeSet store name identifier value = do
8080-- | Load an item
8181--
8282storeGet :: forall a. (Binary a, Typeable a)
83− => Store -> String -> Identifier -> IO (StoreGet a)
83+ => Store -> String -> Identifier a -> IO (StoreGet a)
8484storeGet store name identifier = do
8585 -- First check the in-memory map
8686 map' <- readMVar $ storeMap store
src/Hakyll/Core/Writable.hs+2−2
@@ -38,5 +38,5 @@ instance Writable [Word8] where
3838instance Writable Html where
3939 write p html = write p $ renderHtml html
4040
41−instance Writable Identifier where
42− write p i = write p $ show i
41+instance Writable (Identifier a) where
42+ write p = write p . show
src/Hakyll/Web/Pandoc.hs+9−9
@@ -33,19 +33,19 @@ import Hakyll.Web.Page.Internal
3333
3434-- | Read a string using pandoc, with the default options
3535--
36−readPandoc :: FileType -- ^ File type, determines how parsing happens
37− -> Maybe Identifier -- ^ Optional, for better error messages
38− -> String -- ^ String to read
39− -> Pandoc -- ^ Resulting document
36+readPandoc :: FileType -- ^ Determines how parsing happens
37+ -> Maybe (Identifier a) -- ^ Optional, for better error messages
38+ -> String -- ^ String to read
39+ -> Pandoc -- ^ Resulting document
4040readPandoc = readPandocWith defaultHakyllParserState
4141
4242-- | Read a string using pandoc, with the supplied options
4343--
44−readPandocWith :: ParserState -- ^ Parser options
45− -> FileType -- ^ File type, determines parsing method
46− -> Maybe Identifier -- ^ Optional, for better error messages
47− -> String -- ^ String to read
48− -> Pandoc -- ^ Resulting document
44+readPandocWith :: ParserState -- ^ Parser options
45+ -> FileType -- ^ Determines parsing method
46+ -> Maybe (Identifier a) -- ^ Optional, for better error messages
47+ -> String -- ^ String to read
48+ -> Pandoc -- ^ Resulting document
4949readPandocWith state fileType' id' = case fileType' of
5050 Html -> readHtml state
5151 LaTeX -> readLaTeX state
src/Hakyll/Web/Tags.hs+6−6
@@ -111,7 +111,7 @@ readCategory = readTagsWith getCategory
111111
112112-- | Render tags in HTML
113113--
114−renderTags :: (String -> Identifier)
114+renderTags :: (String -> Identifier a)
115115 -- ^ Produce a link
116116 -> (String -> String -> Int -> Int -> Int -> String)
117117 -- ^ Produce a tag item: tag, url, count, min count, max count
@@ -141,7 +141,7 @@ renderTags makeUrl makeItem concatItems = proc (Tags tags) -> do
141141
142142-- | Render a tag cloud in HTML
143143--
144−renderTagCloud :: (String -> Identifier) -- ^ Produce a link for a tag
144+renderTagCloud :: (String -> Identifier a) -- ^ Produce a link for a tag
145145 -> Double -- ^ Smallest font size, in percent
146146 -> Double -- ^ Biggest font size, in percent
147147 -> Compiler (Tags a) String -- ^ Tag cloud renderer
@@ -162,7 +162,7 @@ renderTagCloud makeUrl minSize maxSize =
162162
163163-- | Render a simple tag list in HTML, with the tag count next to the item
164164--
165−renderTagList :: (String -> Identifier) -> Compiler (Tags a) (String)
165+renderTagList :: (String -> Identifier a) -> Compiler (Tags a) (String)
166166renderTagList makeUrl = renderTags makeUrl makeLink (intercalate ", ")
167167 where
168168 makeLink tag url count _ _ = renderHtml $
@@ -172,7 +172,7 @@ renderTagList makeUrl = renderTags makeUrl makeLink (intercalate ", ")
172172--
173173renderTagsFieldWith :: (Page a -> [String]) -- ^ Function to get the tags
174174 -> String -- ^ Destination key
175− -> (String -> Identifier) -- ^ Create a link for a tag
175+ -> (String -> Identifier a) -- ^ Create a link for a tag
176176 -> Compiler (Page a) (Page a) -- ^ Resulting compiler
177177renderTagsFieldWith tags destination makeUrl =
178178 id &&& arr tags >>> setFieldA destination renderTags'
@@ -192,13 +192,13 @@ renderTagsFieldWith tags destination makeUrl =
192192-- | Render tags with links
193193--
194194renderTagsField :: String -- ^ Destination key
195− -> (String -> Identifier) -- ^ Create a link for a tag
195+ -> (String -> Identifier a) -- ^ Create a link for a tag
196196 -> Compiler (Page a) (Page a) -- ^ Resulting compiler
197197renderTagsField = renderTagsFieldWith getTags
198198
199199-- | Render the category in a link
200200--
201201renderCategoryField :: String -- ^ Destination key
202− -> (String -> Identifier) -- ^ Create a category link
202+ -> (String -> Identifier a) -- ^ Create a category link
203203 -> Compiler (Page a) (Page a) -- ^ Resulting compiler
204204renderCategoryField = renderTagsFieldWith getCategory
src/Hakyll/Web/Template.hs+1−1
@@ -104,6 +104,6 @@ templateCompilerWith settings =
104104 -- Hakyll template
105105 else readTemplate string
106106
107−applyTemplateCompiler :: Identifier -- ^ Template
107+applyTemplateCompiler :: Identifier Template -- ^ Template
108108 -> Compiler (Page String) (Page String) -- ^ Compiler
109109applyTemplateCompiler identifier = require identifier (flip applyTemplate)