inserts-0.1.1: Stupid simple bytestring templates.

Portabilityunknown
Stabilityexperimental
Maintainerme@jspha.com
Safe HaskellNone

Text.Template.Inserts.Internal

Contents

Description

The internal workings of inserts. In most cases you don't want to be digging around in this module, but it's useful if you want to somehow analyze or transform the Template type.

The usual caveat applies: this module is not a public API and is subject to modification without warning.

Synopsis

Major types

newtype Template Source

Constructors

Template 

Instances

Show Template 
IsString Template

Template literals can be embedded directly in Haskell files.

Monoid Template

O(1) appends

data TemplateC Source

Template chunks are either Literals or Holes to be filled by a runtime key lookup later.

Instances

The purely-Applicative Either

data Got a Source

Got is the "purely Applicative" Either with [S.ByteString] as its Left type. When both the left and right arguments to '(*)' are Miss their errors are mappended together.

Constructors

Miss (DList ByteString) 
Got a 

Instances

Template functions

runTemplate :: (ByteString -> Maybe ByteString) -> Template -> Either [ByteString] ByteStringSource

Outputs either the successfully interpolated template or the list of missing keys. For fast operation, try building the lookup function using unordered-containers HashMaps.

showTemplate :: Template -> ByteStringSource

We can build a lazy ByteString much more quickly, so if you need to quickly show your templates then this might be nicer than using show directly.

templateParser :: Parser TemplateSource

An attoparsec Parser for Templates. This is useful if you'd like to embed Templates into a more sophisticated, parseable type of your own.