Toml.FromValue.Generic

toml-parser-1.3.0.0: TOML 1.0.0 parser

Copyright | (c) Eric Mertens 2023
License | ISC
Maintainer | emertens@gmail.com
Safe Haskell | Safe-Inferred
Language | Haskell2010

Toml.FromValue.Generic

Description

Use `genericParseTable` to derive a `ParseTable` using the field names of a record. This can be combined with `parseTableFromValue` to derive a `FromValue` instance.

Synopsis

- class GParseTable f where
  - gParseTable :: (f a -> ParseTable b) -> ParseTable b
- genericParseTable :: (Generic a, GParseTable (Rep a)) => ParseTable a

# Documentation

class GParseTable f where #

Supports conversion of product types with field selector names to TOML values.

Since: 1.0.2.0

Methods

gParseTable :: (f a -> ParseTable b) -> ParseTable b #

Convert a value and apply the continuation to the result.

#### Instances

Instances details

GParseTable (U1 :: Type -> Type) # | Emits empty table
Instance details Defined in Toml.FromValue.Generic Methods gParseTable :: (U1 a -> ParseTable b) -> ParseTable b #
(GParseTable f, GParseTable g) => GParseTable (f :*: g) # | Matches left then right component
Instance details Defined in Toml.FromValue.Generic Methods gParseTable :: ((f :*: g) a -> ParseTable b) -> ParseTable b #
GParseTable f => GParseTable (C1 c f) # | Ignores value constructor name
Instance details Defined in Toml.FromValue.Generic Methods gParseTable :: (C1 c f a -> ParseTable b) -> ParseTable b #
GParseTable f => GParseTable (D1 c f) # | Ignores type constructor name
Instance details Defined in Toml.FromValue.Generic Methods gParseTable :: (D1 c f a -> ParseTable b) -> ParseTable b #
(Selector s, FromValue a) => GParseTable (S1 s (K1 i (Maybe a) :: Type -> Type)) # | Omits the key from the table on nothing, includes it on just
Instance details Defined in Toml.FromValue.Generic Methods gParseTable :: (S1 s (K1 i (Maybe a)) a0 -> ParseTable b) -> ParseTable b #
(Selector s, FromValue a) => GParseTable (S1 s (K1 i a :: Type -> Type)) # | Uses record selector name as table key
Instance details Defined in Toml.FromValue.Generic Methods gParseTable :: (S1 s (K1 i a) a0 -> ParseTable b) -> ParseTable b #

genericParseTable :: (Generic a, GParseTable (Rep a)) => ParseTable a #

Match a `Table` using the field names in a record.

Since: 1.2.0.0