on master help sign in
Type-safe identifiers in haddocks
commitd3f15b18a537aac6364c27c6e726bcd11c869888 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateSat 28 May 2011, 22:33 (15 years ago) parent3c8f310
3 files changed+15−8
src/Hakyll/Core/Compiler.hs+2−2 src/Hakyll/Core/Identifier.hs+9−6 src/Hakyll/Core/Identifier/Pattern.hs+4
src/Hakyll/Core/Compiler.hs+2−2
@@ -53,7 +53,7 @@
5353-- This illustration can help us understand the type signature of 'require'.
5454--
5555-- > require :: (Binary a, Typeable a, Writable a)
56−-- > => Identifier
56+-- > => Identifier a
5757-- > -> (b -> a -> c)
5858-- > -> Compiler b c
5959--
@@ -64,7 +64,7 @@
6464-- These are constraints for the @a@ type. @a@ (the template) needs to have
6565-- certain properties for it to be required.
6666--
67−-- > Identifier
67+-- > Identifier a
6868--
6969-- This is simply @templates/fancy.html@: the 'Identifier' of the item we want
7070-- to 'require', in other words, the name of the item we want to add to the
src/Hakyll/Core/Identifier.hs+9−6
@@ -20,6 +20,15 @@
2020-- @posts/foo.html@. In this case, the identifier is the name of the source
2121-- file of the page.
2222--
23+-- An `Identifier` carries the type of the value it identifies. This basically
24+-- means that an @Identifier (Page String)@ refers to a page.
25+--
26+-- It is a phantom type parameter, meaning you can safely change this if you
27+-- know what you are doing. You can change the type using the 'castIdentifier'
28+-- function.
29+--
30+-- If the @a@ type is not known, Hakyll traditionally uses @Identifier ()@.
31+--
2332{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable #-}
2433module Hakyll.Core.Identifier
2534 ( Identifier (..)
@@ -41,12 +50,6 @@ import Data.Typeable (Typeable)
4150
4251-- | An identifier used to uniquely identify a value
4352--
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−--
5053data Identifier a = Identifier
5154 { identifierGroup :: Maybe String
5255 , identifierPath :: String
src/Hakyll/Core/Identifier/Pattern.hs+4
@@ -31,6 +31,10 @@
3131-- The 'capture' function allows the user to get access to the elements captured
3232-- by the capture elements in the pattern.
3333--
34+-- Like an 'Identifier', a 'Pattern' also has a type parameter. This is simply
35+-- an extra layer of safety, and can be discarded using the 'castPattern'
36+-- function.
37+--
3438module Hakyll.Core.Identifier.Pattern
3539 ( Pattern
3640 , castPattern