hakyll-4.13.4.0: A static website compiler library

Safe Haskell | None
Language | Haskell2010

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 ()
- noResult :: String -> Compiler a
- withErrorMessage :: String -> Compiler a -> Compiler a

# Documentation

data Compiler a Source #

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

#### Instances

Instances details

Monad Compiler Source # |
Instance details Defined in Hakyll.Core.Compiler.Internal Methods (>>=) :: Compiler a -> (a -> Compiler b) -> Compiler b Source # (>>) :: Compiler a -> Compiler b -> Compiler b Source # return :: a -> Compiler a Source #
Functor Compiler Source # |
Instance details Defined in Hakyll.Core.Compiler.Internal Methods fmap :: (a -> b) -> Compiler a -> Compiler b Source # (<$) :: a -> Compiler b -> Compiler a Source #
MonadFail Compiler Source # |
Instance details Defined in Hakyll.Core.Compiler.Internal Methods fail :: String -> Compiler a Source #
Applicative Compiler Source # |
Instance details Defined in Hakyll.Core.Compiler.Internal Methods pure :: a -> Compiler a Source # (<*>) :: Compiler (a -> b) -> Compiler a -> Compiler b Source # liftA2 :: (a -> b -> c) -> Compiler a -> Compiler b -> Compiler c Source # (*>) :: Compiler a -> Compiler b -> Compiler b Source # (<*) :: Compiler a -> Compiler b -> Compiler a Source #
Alternative Compiler Source # | Trying alternative compilers if the first fails, regardless whether through `fail`, `throwError` or `noResult`. Aggregates error messages if all fail.
Instance details Defined in Hakyll.Core.Compiler.Internal Methods empty :: Compiler a Source # (<|>) :: Compiler a -> Compiler a -> Compiler a Source # some :: Compiler a -> Compiler [a] Source # many :: Compiler a -> Compiler [a] Source #
MonadMetadata Compiler Source # | Access provided metadata from anywhere
Instance details Defined in Hakyll.Core.Compiler.Internal Methods getMetadata :: Identifier -> Compiler Metadata Source # getMatches :: Pattern -> Compiler [Identifier] Source # getAllMetadata :: Pattern -> Compiler [(Identifier, Metadata)] Source #
MonadError [String] Compiler Source # | Compilation may fail with multiple error messages. `catchError` handles errors from `throwError`, `fail` and `noResult`
Instance details Defined in Hakyll.Core.Compiler.Internal Methods throwError :: [String] -> Compiler a Source # catchError :: Compiler a -> ([String] -> Compiler a) -> Compiler a Source #

getUnderlying :: Compiler Identifier Source #

Get the underlying identifier.

getUnderlyingExtension :: Compiler String Source #

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

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

Create an item from the underlying identifier and a given value.

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

Get the route for a specified item

getResourceBody :: Compiler (Item String) Source #

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

getResourceString :: Compiler (Item String) Source #

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

getResourceLBS :: Compiler (Item ByteString) Source #

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

getResourceFilePath :: Compiler FilePath Source #

Get the file path of the resource we are compiling

type Snapshot = String Source #

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) Source #

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) Source #

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) Source #

Require a specific snapshot of an item.

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

A shortcut for only requiring the body of an item.

    loadBody = fmap itemBody . load

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

A shortcut for only requiring the body for a specific snapshot of an item

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

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

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

Load a specific snapshot for each of dynamic list of items

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

Turn on caching for a compilation value to avoid recomputing it on subsequent Hakyll runs. The storage key consists of the underlying identifier of the compiled ressource and the given name.

unsafeCompiler :: IO a -> Compiler a Source #

Run an IO computation without dependencies in a Compiler

debugCompiler :: String -> Compiler () Source #

Compiler for debugging purposes. Passes a message to the debug logger that is printed in verbose mode.

noResult :: String -> Compiler a Source #

Fail so that it is treated as non-defined in an `$if()$` branching Hakyll.Web.Template macro, and alternative `Context`s are tried

Since: 4.13.0

withErrorMessage :: String -> Compiler a -> Compiler a Source #

Prepend an error line to the error, if there is one. This allows you to add helpful context to error messages.

Since: 4.13.0