Hakyll.Core.Rules

hakyll-4.9.1.0: A static website compiler library

Safe Haskell | None
Language | Haskell98

Hakyll.Core.Rules

Contents

- Advanced usage

Description

This module provides a declarative DSL in which the user can specify the different rules used to run the compilers.

The convention is to just list all items in the `Rules` monad, routes and compilation rules.

A typical usage example would be:

    main = hakyll $ do
        match "posts/*" $ do
            route   (setExtension "html")
            compile someCompiler
        match "css/*" $ do
            route   idRoute
            compile compressCssCompiler

Synopsis

- data Rules a
- match :: Pattern -> Rules () -> Rules ()
- matchMetadata :: Pattern -> (Metadata -> Bool) -> Rules () -> Rules ()
- create :: [Identifier] -> Rules () -> Rules ()
- version :: String -> Rules () -> Rules ()
- compile :: (Binary a, Typeable a, Writable a) => Compiler (Item a) -> Rules ()
- route :: Routes -> Rules ()
- preprocess :: IO a -> Rules a
- data Dependency
  - = PatternDependency Pattern (Set Identifier)
  - | IdentifierDependency Identifier
- rulesExtraDependencies :: [Dependency] -> Rules a -> Rules a

# Documentation

data Rules a #

The monad used to compose rules

Instances

Monad Rules # |
Methods (>>=) :: Rules a -> (a -> Rules b) -> Rules b # (>>) :: Rules a -> Rules b -> Rules b # return :: a -> Rules a # fail :: String -> Rules a #
Functor Rules # |
Methods fmap :: (a -> b) -> Rules a -> Rules b # (<$) :: a -> Rules b -> Rules a #
Applicative Rules # |
Methods pure :: a -> Rules a # (<*>) :: Rules (a -> b) -> Rules a -> Rules b # (*>) :: Rules a -> Rules b -> Rules b # (<*) :: Rules a -> Rules b -> Rules a #
MonadMetadata Rules # |
Methods getMetadata :: Identifier -> Rules Metadata # getMatches :: Pattern -> Rules [Identifier] # getAllMetadata :: Pattern -> Rules [(Identifier, Metadata)] #

match :: Pattern -> Rules () -> Rules () #

matchMetadata :: Pattern -> (Metadata -> Bool) -> Rules () -> Rules () #

create :: [Identifier] -> Rules () -> Rules () #

version :: String -> Rules () -> Rules () #

compile :: (Binary a, Typeable a, Writable a) => Compiler (Item a) -> Rules () #

Add a compilation rule to the rules.

This instructs all resources to be compiled using the given compiler.

route :: Routes -> Rules () #

Add a route.

This adds a route for all items matching the current pattern.

# Advanced usage

preprocess :: IO a -> Rules a #

Execute an `IO` action immediately while the rules are being evaluated. This should be avoided if possible, but occasionally comes in useful.

data Dependency #

Constructors

PatternDependency Pattern (Set Identifier) |
IdentifierDependency Identifier |

Instances

Show Dependency # |
Methods showsPrec :: Int -> Dependency -> ShowS # show :: Dependency -> String # showList :: [Dependency] -> ShowS #
Binary Dependency # |
Methods put :: Dependency -> Put # get :: Get Dependency # putList :: [Dependency] -> Put #

rulesExtraDependencies :: [Dependency] -> Rules a -> Rules a #

Advanced usage: add extra dependencies to compilers. Basically this is needed when you're doing unsafe tricky stuff in the rules monad, but you still want correct builds.

A useful utility for this purpose is `makePatternDependency`.