colonnade-1.0.0: Generic types and functions for columnar encoding and decoding

Safe HaskellNone
LanguageHaskell2010

Colonnade.Encode

Description

Most users of this library do not need this module. The functions here are used to build functions that apply a Colonnade to a collection of values, building a table from them. Ultimately, a function that applies a Colonnade Headed MyCell a to data will have roughly the following type:

myTableRenderer :: Foldable g => Colonnade Headed MyCell a -> g a -> MyContent

In the companion packages yesod-colonnade and reflex-dom-colonnade, functions with similar type signatures are readily available. These packages use the functions provided here in the implementations of their rendering functions. It is recommended that users who believe they may need this module look at the source of the companion packages to see an example of how this module's functions are used. Other backends are encouraged to use these functions to build monadic or monoidal content from a Colonnade.

The functions exported here take a Colonnade and convert it to a fragment of content. The functions whose names start with row take at least a Colonnade f c a and an a value to generate a row of content. The functions whose names start with header need the Colonnade f c a but not an a value since a value is not needed to build a header.

Synopsis

Documentation

row :: (c1 -> c2) -> Colonnade f c1 a -> a -> Vector c2 Source #

Consider providing a variant the produces a list instead. It may allow more things to get inlined in to a loop.

rowMonadic :: (Monad m, Monoid b) => Colonnade f content a -> (content -> m b) -> a -> m b Source #

rowMonadic_ :: Monad m => Colonnade f content a -> (content -> m b) -> a -> m () Source #

rowMonadicWith :: Monad m => b -> (b -> b -> b) -> Colonnade f content a -> (content -> m b) -> a -> m b Source #

rowMonoidal :: Monoid m => Colonnade h c a -> (c -> m) -> a -> m Source #

header :: (c1 -> c2) -> Colonnade Headed c1 a -> Vector c2 Source #

headerMonadic :: (Monad m, Monoid b) => Colonnade Headed content a -> (content -> m b) -> m b Source #

headerMonadic_ :: Monad m => Colonnade Headed content a -> (content -> m b) -> m () Source #

headerMonadicGeneral :: (Monad m, Monoid b, Foldable h) => Colonnade h content a -> (content -> m b) -> m b Source #

This function is a helper for abusing Foldable to optionally render a header. Its future is uncertain.

headerMonadicGeneral_ :: (Monad m, Foldable h) => Colonnade h content a -> (content -> m b) -> m () Source #

headerMonoidalGeneral :: (Monoid m, Foldable h) => Colonnade h c a -> (c -> m) -> m Source #

bothMonadic_ :: Monad m => Colonnade Headed content a -> (content -> content -> m b) -> a -> m () Source #