HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduletoml-parser-2.0.0.0Haskell2010

Toml.Schema.Generic

This module makes it possible to easily derive the TOML classes using the DerivingVia extension.

For example:

data Physical = Physical {
    color :: String,
    shape :: String
    }
    deriving (Eq, Show, Generic)
    deriving (ToTable, ToValue, FromValue) via GenericTomlTable Physical

These derived instances would allow you to match TOML {color="red", shape="round"} to value Physical "red" "round".

data Coord = Coord Int Int
    deriving (Eq, Show, Generic)
    deriving (ToValue, FromValue) via GenericTomlArray Physical

These derived instances would allow you to match TOML [1,2] to value Coord 1 2.

  • 2 types
  • 4 classes
  • 4 values

DerivingVia

2 declarations
newtypenewtype GenericTomlTable a
#

Helper type to use GHC's DerivingVia extension to derive ToValue, ToTable, FromValue for records.

Constructors

Instances3FromValue, ToTable, ToValue
newtypenewtype GenericTomlArray a
#

Helper type to use GHC's DerivingVia extension to derive ToValue, ToTable, FromValue for any product type.

Constructors

Instances2FromValue, ToValue

FromValue

4 declarations
classclass GFromArray (f :: Type -> Type) where
#

Supports conversion of TOML arrays into product-type values.

Instances4GFromArray
classclass GParseTable (f :: Type -> Type) where
#

Supports conversion of TOML tables into record values using field selector names as TOML keys.

Instances6GParseTable
  • GParseTable U1Defined in toml-parser-2.0.0.0 · Toml.Schema.Generic.FromValue

    Emits empty table

  • GParseTable f => GParseTable (C1 ('MetaCons sym fix 'True) f)Defined in toml-parser-2.0.0.0 · Toml.Schema.Generic.FromValue

    Ignores value constructor name - only supports record constructors

  • GParseTable f => GParseTable (D1 c f)Defined in toml-parser-2.0.0.0 · Toml.Schema.Generic.FromValue

    Ignores type constructor name

  • (Selector s, FromValue a) => GParseTable (S1 s (K1 i (Maybe a)))Defined in toml-parser-2.0.0.0 · Toml.Schema.Generic.FromValue

    Omits the key from the table on nothing, includes it on just

  • (Selector s, FromValue a) => GParseTable (S1 s (K1 i a))Defined in toml-parser-2.0.0.0 · Toml.Schema.Generic.FromValue

    Uses record selector name as table key

  • (GParseTable f, GParseTable g) => GParseTable (f :*: g)Defined in toml-parser-2.0.0.0 · Toml.Schema.Generic.FromValue

    Matches left then right component

ToValue

4 declarations
classclass GToArray (f :: Type -> Type) where
#

Convert product types to arrays positionally.

Instances3GToArray
  • ToValue a => GToArray (K1 i a)Defined in toml-parser-2.0.0.0 · Toml.Schema.Generic.ToValue

    Convert fields using ToValue instances

  • (GToArray f, GToArray g) => GToArray (f :*: g)Defined in toml-parser-2.0.0.0 · Toml.Schema.Generic.ToValue

    Convert left and then right

  • GToArray f => GToArray (M1 i c f)Defined in toml-parser-2.0.0.0 · Toml.Schema.Generic.ToValue

    Ignore metadata

classclass GToTable (f :: Type -> Type) where
#

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

Instances7GToTable, …
  • GToTable U1Defined in toml-parser-2.0.0.0 · Toml.Schema.Generic.ToValue

    Emits empty table

  • GToTable V1Defined in toml-parser-2.0.0.0 · Toml.Schema.Generic.ToValue
  • GToTable f => GToTable (C1 c f)Defined in toml-parser-2.0.0.0 · Toml.Schema.Generic.ToValue

    Ignores value constructor names

  • GToTable f => GToTable (D1 c f)Defined in toml-parser-2.0.0.0 · Toml.Schema.Generic.ToValue

    Ignores type constructor names

  • (Selector s, ToValue a) => GToTable (S1 s (K1 i (Maybe a)))Defined in toml-parser-2.0.0.0 · Toml.Schema.Generic.ToValue

    Omits the key from the table on nothing, includes it on just

  • (Selector s, ToValue a) => GToTable (S1 s (K1 i a))Defined in toml-parser-2.0.0.0 · Toml.Schema.Generic.ToValue

    Uses record selector name as table key

  • (GToTable f, GToTable g) => GToTable (f :*: g)Defined in toml-parser-2.0.0.0 · Toml.Schema.Generic.ToValue