hakyll-4.15.0.1: A static website compiler library
Safe HaskellNone
LanguageHaskell2010

Hakyll.Core.Compiler.Internal

Description

Internally used compiler module

Synopsis

Types

type Snapshot = String Source #

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

data CompilerRead Source #

Environment in which a compiler runs

Constructors

CompilerRead 

Fields

data CompilerErrors a Source #

Distinguishes reasons in a CompilerError

Constructors

CompilationFailure (NonEmpty a)

One or more exceptions occured during compilation

CompilationNoResult [a]

Absence of any result, most notably in template contexts. May still have error messages.

Instances

Instances details
Functor CompilerErrors Source # 
Instance details

Defined in Hakyll.Core.Compiler.Internal

Methods

fmap :: (a -> b) -> CompilerErrors a -> CompilerErrors b #

(<$) :: a -> CompilerErrors b -> CompilerErrors a #

newtype Compiler a Source #

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

Constructors

Compiler 

Instances

Instances details
Monad Compiler Source # 
Instance details

Defined in Hakyll.Core.Compiler.Internal

Methods

(>>=) :: Compiler a -> (a -> Compiler b) -> Compiler b #

(>>) :: Compiler a -> Compiler b -> Compiler b #

return :: a -> Compiler a #

Functor Compiler Source # 
Instance details

Defined in Hakyll.Core.Compiler.Internal

Methods

fmap :: (a -> b) -> Compiler a -> Compiler b #

(<$) :: a -> Compiler b -> Compiler a #

MonadFail Compiler Source # 
Instance details

Defined in Hakyll.Core.Compiler.Internal

Methods

fail :: String -> Compiler a #

Applicative Compiler Source # 
Instance details

Defined in Hakyll.Core.Compiler.Internal

Methods

pure :: a -> Compiler a #

(<*>) :: Compiler (a -> b) -> Compiler a -> Compiler b #

liftA2 :: (a -> b -> c) -> Compiler a -> Compiler b -> Compiler c #

(*>) :: Compiler a -> Compiler b -> Compiler b #

(<*) :: Compiler a -> Compiler b -> Compiler a #

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 #

(<|>) :: Compiler a -> Compiler a -> Compiler a #

some :: Compiler a -> Compiler [a] #

many :: Compiler a -> Compiler [a] #

MonadMetadata Compiler Source #

Access provided metadata from anywhere

Instance details

Defined in Hakyll.Core.Compiler.Internal

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 #

catchError :: Compiler a -> ([String] -> Compiler a) -> Compiler a #

runCompiler :: Compiler a -> CompilerRead -> IO (CompilerResult a) Source #

Like unCompiler but treating IO exceptions as CompilerErrors

Core operations

compilerResult :: CompilerResult a -> Compiler a Source #

Put the result back in a compiler

compilerAsk :: Compiler CompilerRead Source #

Get the current environment

compilerUnsafeIO :: IO a -> Compiler a Source #

Run an IO computation without dependencies in a Compiler

Error operations

compilerThrow :: [String] -> Compiler a Source #

Throw errors in the Compiler.

If no messages are given, this is considered a CompilationNoResult error. Otherwise, it is treated as a proper compilation failure.

compilerNoResult :: [String] -> Compiler a Source #

Put a CompilerError with multiple messages as CompilationNoResult

compilerCatch :: Compiler a -> (CompilerErrors String -> Compiler a) -> Compiler a Source #

Allows you to recover from CompilerErrors. Uses the same parameter order as catchError so that it can be used infix.

c `compilerCatch` f = compilerTry c >>= either f return

compilerTry :: Compiler a -> Compiler (Either (CompilerErrors String) a) Source #

Allows to distinguish CompilerErrors and branch on them with Either

compilerTry = (`compilerCatch` return . Left) . fmap Right

Utilities

compilerDebugEntries :: String -> [String] -> Compiler () Source #

Pass a list of messages with a heading to the debug logger