Copyright | (c) Eric Mertens 2024 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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 Coord 1 2
.
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
.
Synopsis
- newtype GenericTomlTable a = GenericTomlTable a
- newtype GenericTomlArray a = GenericTomlArray a
Documentation
newtype GenericTomlTable a Source #
Helper type to use GHC's DerivingVia extension to derive
ToValue
, ToTable
, FromValue
for records.
Since: 1.3.2.0
Instances
(Generic a, GParseTable (Rep a)) => FromValue (GenericTomlTable a) Source # | Instance derived using |
Defined in Toml.Generic fromValue :: Value -> Matcher (GenericTomlTable a) Source # listFromValue :: Value -> Matcher [GenericTomlTable a] Source # | |
(Generic a, GToTable (Rep a)) => ToTable (GenericTomlTable a) Source # | Instance derived using |
Defined in Toml.Generic toTable :: GenericTomlTable a -> Table Source # | |
(Generic a, GToTable (Rep a)) => ToValue (GenericTomlTable a) Source # | Instance derived from |
Defined in Toml.Generic toValue :: GenericTomlTable a -> Value Source # toValueList :: [GenericTomlTable a] -> Value Source # |
newtype GenericTomlArray a Source #
Helper type to use GHC's DerivingVia extension to derive
ToValue
, ToTable
, FromValue
for any product type.
Since: 1.3.2.0
Instances
(Generic a, GFromArray (Rep a)) => FromValue (GenericTomlArray a) Source # | Instance derived using |
Defined in Toml.Generic fromValue :: Value -> Matcher (GenericTomlArray a) Source # listFromValue :: Value -> Matcher [GenericTomlArray a] Source # | |
(Generic a, GToArray (Rep a)) => ToValue (GenericTomlArray a) Source # | Instance derived using |
Defined in Toml.Generic toValue :: GenericTomlArray a -> Value Source # toValueList :: [GenericTomlArray a] -> Value Source # |