tomland-0.4.0: Bidirectional TOML parser

Safe HaskellNone
LanguageHaskell2010

Toml.Bi.Combinators

Contents

Description

Contains TOML-specific combinators for converting between TOML and user data types.

Synopsis

Toml codecs

bool :: Key -> BiToml Bool Source #

Parser for boolean values.

int :: Key -> BiToml Int Source #

Parser for integer values.

integer :: Key -> BiToml Integer Source #

Parser for integer values.

double :: Key -> BiToml Double Source #

Parser for floating values.

text :: Key -> BiToml Text Source #

Parser for string values.

arrayOf :: forall a. Typeable a => BiMap AnyValue a -> Key -> BiToml [a] Source #

Parser for array of values. Takes converter for single array element and returns list of values.

Combinators

match :: forall a. Typeable a => BiMap AnyValue a -> Key -> BiToml a Source #

General function to create bidirectional converters for values.

maybeT :: forall a. (Key -> BiToml a) -> Key -> BiToml (Maybe a) Source #

Bidirectional converter for Maybe smth values.

table :: forall a. BiToml a -> Key -> BiToml a Source #

Parser for tables. Use it when when you have nested objects.

wrapper :: forall b a. Coercible a b => (Key -> BiToml a) -> Key -> BiToml b Source #

Used for newtype wrappers.

dimapNum :: forall n r w. (Integral n, Functor r, Functor w) => Bi r w Integer -> Bi r w n Source #

Helper dimapper to turn integer parser into parser for Int, Natural, Word, etc.

mdimap Source #

Arguments

:: (Monad r, Monad w, MonadError DecodeException r) 
=> (c -> d)

Convert from safe to unsafe value

-> (a -> Maybe b)

Parser for more type safe value

-> Bijection r w d a

Source Bijection object

-> Bijection r w c b 

Almost same as dimap. Useful when you want to have fields like this inside your configuration:

data GhcVer = Ghc7103 | Ghc802 | Ghc822 | Ghc842

showGhcVer  :: GhcVer -> Text
parseGhcVer :: Text -> Maybe GhcVer

When you specify couple of functions of the following types:

show  :: a -> Text
parse :: Text -> Maybe a

they should satisfy property parse . show == Just if you want to use your converter for pretty-printing.