| Copyright | Joseph Abrahamson 2014 |
|---|---|
| License | MIT |
| Maintainer | me@jspha.com |
| Stability | experimental |
| Portability | unknown |
| Safe Haskell | None |
| Language | Haskell2010 |
Text.Template.Inserts.Internal
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.
- newtype Template = Template {}
- data TemplateC
- data Got a
- = Miss (DList ByteString)
- | Got a
- gotEither :: Got a -> Either [ByteString] a
- runTemplate :: (ByteString -> Maybe ByteString) -> Template -> Either [ByteString] ByteString
- showTemplate :: Template -> ByteString
- parseTemplate :: ByteString -> Either String Template
- templateParser :: Parser Template
Major types
Constructors
| Template | |
Fields | |
Constructors
| Literal Builder | |
| Hole ByteString |
The purely-Applicative Either
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 |
gotEither :: Got a -> Either [ByteString] a Source
Template functions
runTemplate :: (ByteString -> Maybe ByteString) -> Template -> Either [ByteString] ByteString Source
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 -> ByteString Source
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.
parseTemplate :: ByteString -> Either String Template Source
Try to parse a ByteString as a Template.