Hakyll.Core.Compiler

hakyll-4.9.5.1: A static website compiler library

Safe Haskell | None
Language | Haskell98

Hakyll.Core.Compiler

Synopsis

- data Compiler a
- getUnderlying :: Compiler Identifier
- getUnderlyingExtension :: Compiler String
- makeItem :: a -> Compiler (Item a)
- getRoute :: Identifier -> Compiler (Maybe FilePath)
- getResourceBody :: Compiler (Item String)
- getResourceString :: Compiler (Item String)
- getResourceLBS :: Compiler (Item ByteString)
- getResourceFilePath :: Compiler FilePath
- type Snapshot = String
- saveSnapshot :: (Binary a, Typeable a) => Snapshot -> Item a -> Compiler (Item a)
- load :: (Binary a, Typeable a) => Identifier -> Compiler (Item a)
- loadSnapshot :: (Binary a, Typeable a) => Identifier -> Snapshot -> Compiler (Item a)
- loadBody :: (Binary a, Typeable a) => Identifier -> Compiler a
- loadSnapshotBody :: (Binary a, Typeable a) => Identifier -> Snapshot -> Compiler a
- loadAll :: (Binary a, Typeable a) => Pattern -> Compiler [Item a]
- loadAllSnapshots :: (Binary a, Typeable a) => Pattern -> Snapshot -> Compiler [Item a]
- cached :: (Binary a, Typeable a) => String -> Compiler a -> Compiler a
- unsafeCompiler :: IO a -> Compiler a
- debugCompiler :: String -> Compiler ()

# Documentation

data Compiler a #

A monad which lets you compile items and takes care of dependency tracking for you.

Instances

Monad Compiler # |
Methods (>>=) :: Compiler a -> (a -> Compiler b) -> Compiler b # (>>) :: Compiler a -> Compiler b -> Compiler b # return :: a -> Compiler a # fail :: String -> Compiler a #
Functor Compiler # |
Methods fmap :: (a -> b) -> Compiler a -> Compiler b # (<$) :: a -> Compiler b -> Compiler a #
Applicative Compiler # |
Methods pure :: a -> Compiler a # (<*>) :: Compiler (a -> b) -> Compiler a -> Compiler b # (*>) :: Compiler a -> Compiler b -> Compiler b # (<*) :: Compiler a -> Compiler b -> Compiler a #
Alternative Compiler # |
Methods empty :: Compiler a # (<|>) :: Compiler a -> Compiler a -> Compiler a # some :: Compiler a -> Compiler [a] # many :: Compiler a -> Compiler [a] #
MonadMetadata Compiler # |
Methods getMetadata :: Identifier -> Compiler Metadata # getMatches :: Pattern -> Compiler [Identifier] # getAllMetadata :: Pattern -> Compiler [(Identifier, Metadata)] #
MonadError [String] Compiler # |
Methods throwError :: [String] -> Compiler a # catchError :: Compiler a -> ([String] -> Compiler a) -> Compiler a #

getUnderlying :: Compiler Identifier #

Get the underlying identifier.

getUnderlyingExtension :: Compiler String #

Get the extension of the underlying identifier. Returns something like `".html"`

makeItem :: a -> Compiler (Item a) #

getRoute :: Identifier -> Compiler (Maybe FilePath) #

Get the route for a specified item

getResourceBody :: Compiler (Item String) #

Get the full contents of the matched source file as a string, but without metadata preamble, if there was one.

getResourceString :: Compiler (Item String) #

Get the full contents of the matched source file as a string.

getResourceLBS :: Compiler (Item ByteString) #

Get the full contents of the matched source file as a lazy bytestring.

getResourceFilePath :: Compiler FilePath #

Get the file path of the resource we are compiling

type Snapshot = String #

Whilst compiling an item, it possible to save multiple snapshots of it, and not just the final result.

saveSnapshot :: (Binary a, Typeable a) => Snapshot -> Item a -> Compiler (Item a) #

Save a snapshot of the item. This function returns the same item, which convenient for building `>>=` chains.

load :: (Binary a, Typeable a) => Identifier -> Compiler (Item a) #

Load an item compiled elsewhere. If the required item is not yet compiled, the build system will take care of that automatically.

loadSnapshot :: (Binary a, Typeable a) => Identifier -> Snapshot -> Compiler (Item a) #

Require a specific snapshot of an item.

loadBody :: (Binary a, Typeable a) => Identifier -> Compiler a #

A shortcut for only requiring the body of an item.

    loadBody = fmap itemBody . load

loadSnapshotBody :: (Binary a, Typeable a) => Identifier -> Snapshot -> Compiler a #

loadAll :: (Binary a, Typeable a) => Pattern -> Compiler [Item a] #

This function allows you to `load` a dynamic list of items

loadAllSnapshots :: (Binary a, Typeable a) => Pattern -> Snapshot -> Compiler [Item a] #

cached :: (Binary a, Typeable a) => String -> Compiler a -> Compiler a #

unsafeCompiler :: IO a -> Compiler a #

debugCompiler :: String -> Compiler () #

Compiler for debugging purposes