diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2012-11-25 10:45:55 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2012-11-25 10:45:55 +0100 |
commit | 25b8c8b199082ebbc41d1af03fc19202b798f156 (patch) | |
tree | 93fe71723ce3f7288b465037fb6c9a1198514e22 /src/Hakyll/Core/Compiler | |
parent | cae87891543babe1a0ec989546cfabcb451bd890 (diff) | |
download | hakyll-25b8c8b199082ebbc41d1af03fc19202b798f156.tar.gz |
A bit of cleanup
Diffstat (limited to 'src/Hakyll/Core/Compiler')
-rw-r--r-- | src/Hakyll/Core/Compiler/Internal.hs | 2 | ||||
-rw-r--r-- | src/Hakyll/Core/Compiler/Require.hs | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/Hakyll/Core/Compiler/Internal.hs b/src/Hakyll/Core/Compiler/Internal.hs index 981ddda..8eb950c 100644 --- a/src/Hakyll/Core/Compiler/Internal.hs +++ b/src/Hakyll/Core/Compiler/Internal.hs @@ -82,6 +82,8 @@ data CompilerResult a where -------------------------------------------------------------------------------- +-- | A monad which lets you compile items and takes care of dependency tracking +-- for you. newtype Compiler a = Compiler { unCompiler :: CompilerRead -> IO (CompilerResult a) } diff --git a/src/Hakyll/Core/Compiler/Require.hs b/src/Hakyll/Core/Compiler/Require.hs index 3c6ddfc..f67bf2c 100644 --- a/src/Hakyll/Core/Compiler/Require.hs +++ b/src/Hakyll/Core/Compiler/Require.hs @@ -30,6 +30,8 @@ import qualified Hakyll.Core.Store as Store -------------------------------------------------------------------------------- +-- | Whilst compiling an item, it possible to save multiple snapshots of it, and +-- not just the final result. type Snapshot = String @@ -39,6 +41,8 @@ save store item = saveSnapshot store final item -------------------------------------------------------------------------------- +-- | Save a specific snapshot of an item, so you can load it later using +-- 'requireSnapshot'. saveSnapshot :: (Binary a, Typeable a) => Store -> Snapshot -> Item a -> IO () saveSnapshot store snapshot item = @@ -46,11 +50,14 @@ saveSnapshot store snapshot item = -------------------------------------------------------------------------------- +-- | Load an item compiled elsewhere. If the required item is not yet compiled, +-- the build system will take care of that automatically. require :: (Binary a, Typeable a) => Identifier -> Compiler (Item a) require id' = requireSnapshot id' final -------------------------------------------------------------------------------- +-- | Require a specific snapshot of an item. requireSnapshot :: (Binary a, Typeable a) => Identifier -> Snapshot -> Compiler (Item a) requireSnapshot id' snapshot = do @@ -77,6 +84,9 @@ requireSnapshot id' snapshot = do -------------------------------------------------------------------------------- +-- | A shortcut for only requiring the body of an item. +-- +-- > requireBody = fmap itemBody . require requireBody :: (Binary a, Typeable a) => Identifier -> Compiler a requireBody id' = requireSnapshotBody id' final @@ -88,6 +98,7 @@ requireSnapshotBody id' snapshot = fmap itemBody $ requireSnapshot id' snapshot -------------------------------------------------------------------------------- +-- | This function allows you to 'require' a dynamic list of items requireAll :: (Binary a, Typeable a) => Pattern -> Compiler [Item a] requireAll pattern = requireAllSnapshots pattern final @@ -108,4 +119,4 @@ key identifier snapshot = -------------------------------------------------------------------------------- final :: Snapshot -final = "final" +final = "_final" |