simple-text-format-0.1: Simple text based format strings with named identifiers.

Copyright(c) Justus Adam 2017. All Rights Reserved.
LicenseBSD3
Maintainerdev@justus.science
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Data.Text.Format.Simple

Description

 

Synopsis

Documentation

format :: Text -> SubMap -> Either String (Text, [Name]) Source #

Compile a string to a format string and substitute the identifiers from the provided function into it.

Fails if the string canno be parsed. Retuns the rendered string and a list of names which were used in the string but could not be resolved by the function.

format' :: Text -> SubMap -> Text Source #

Compile a string to a format string and substitute the identifiers from the provided function into it.

All errors are ignored. Parse failure is thrown as an error and the missing names are discarded.

formatC :: Compiled -> SubMap -> (Text, [Name]) Source #

Like format but with the string already compiled

formatC' :: Compiled -> SubMap -> Text Source #

Like format' but with the string already compiled

type SubMap = Name -> Maybe Text Source #

Resolver for names.

data Compiled Source #

A precompiled format string. Can be used to render several times.

type Name = Text Source #

The name of a referenced variable.