Copyright | (c) Eric Mertens 2023 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Toml.ToValue
Contents
Description
The ToValue
class provides a conversion function from
application-specific to TOML values.
Because the top-level TOML document is always a table,
the ToTable
class is for types that specifically support
conversion to a Table
.
Toml.ToValue.Generic can be used to derive instances of ToTable
automatically for record types.
Synopsis
Documentation
class ToValue a where Source #
Class for types that can be embedded into Value
Minimal complete definition
Methods
toValue :: a -> Value Source #
Embed a single thing into a TOML value.
toValueList :: [a] -> Value Source #
Helper for converting a list of things into a value. This is typically left to be defined by its default implementation and exists to help define the encoding for TOML arrays.
Instances
ToValue Int16 Source # | |
Defined in Toml.ToValue | |
ToValue Int32 Source # | |
Defined in Toml.ToValue | |
ToValue Int64 Source # | |
Defined in Toml.ToValue | |
ToValue Int8 Source # | |
Defined in Toml.ToValue | |
ToValue Word16 Source # | |
Defined in Toml.ToValue | |
ToValue Word32 Source # | |
Defined in Toml.ToValue | |
ToValue Word64 Source # | |
Defined in Toml.ToValue | |
ToValue Word8 Source # | |
Defined in Toml.ToValue | |
ToValue Text Source # | Encodes as string literal Since: 1.2.1.0 |
Defined in Toml.ToValue | |
ToValue Text Source # | Encodes as string literal Since: 1.2.1.0 |
Defined in Toml.ToValue | |
ToValue Day Source # | |
Defined in Toml.ToValue | |
ToValue LocalTime Source # | |
Defined in Toml.ToValue | |
ToValue TimeOfDay Source # | |
Defined in Toml.ToValue | |
ToValue ZonedTime Source # | |
Defined in Toml.ToValue | |
ToValue Value Source # | Identity function |
ToValue Integer Source # | |
Defined in Toml.ToValue | |
ToValue Natural Source # | |
Defined in Toml.ToValue | |
ToValue Bool Source # | |
Defined in Toml.ToValue | |
ToValue Char Source # | Single characters are encoded as singleton strings. Lists of characters are encoded as a single string value. |
Defined in Toml.ToValue | |
ToValue Double Source # | |
Defined in Toml.ToValue | |
ToValue Float Source # | |
Defined in Toml.ToValue | |
ToValue Int Source # | |
Defined in Toml.ToValue | |
ToValue Word Source # | |
Defined in Toml.ToValue | |
Integral a => ToValue (Ratio a) Source # | Converts to a Since: 1.3.0.0 |
Defined in Toml.ToValue | |
ToValue a => ToValue (Seq a) Source # | Converts to list and encodes that to value Since: 1.3.0.0 |
Defined in Toml.ToValue | |
(Generic a, GToArray (Rep a)) => ToValue (GenericTomlArray a) Source # | Instance derived using |
Defined in Toml.Generic Methods toValue :: GenericTomlArray a -> Value Source # toValueList :: [GenericTomlArray a] -> Value Source # | |
(Generic a, GToTable (Rep a)) => ToValue (GenericTomlTable a) Source # | Instance derived from |
Defined in Toml.Generic Methods toValue :: GenericTomlTable a -> Value Source # toValueList :: [GenericTomlTable a] -> Value Source # | |
ToValue a => ToValue (NonEmpty a) Source # | Converts to list and encodes that to value Since: 1.3.0.0 |
Defined in Toml.ToValue | |
ToValue a => ToValue [a] Source # | This instance defers to the list element's |
Defined in Toml.ToValue | |
(ToKey k, ToValue v) => ToValue (Map k v) Source # | Since: 1.0.1.0 |
Defined in Toml.ToValue |
Table construction
class ToValue a => ToTable a where Source #
Class for things that can be embedded into a TOML table.
Implement this for things that always embed into a Table
and then
the ToValue
instance can be derived with defaultTableToValue
.
instance ToValue Example where toValue = defaultTableToValue -- Option 1: Manual instance instance ToTable Example where toTable x =table
["field1".=
field1 x, "field2".=
field2 x] -- Option 2: GHC.Generics derived instance using Toml.ToValue.Generic instance ToTable Example where toTable = genericToTable
Instances
(Generic a, GToTable (Rep a)) => ToTable (GenericTomlTable a) Source # | Instance derived using |
Defined in Toml.Generic Methods toTable :: GenericTomlTable a -> Table Source # | |
(ToKey k, ToValue v) => ToTable (Map k v) Source # | Since: 1.0.1.0 |
Defined in Toml.ToValue |
Convert to a table key. This class enables various string types to be
used as the keys of a Map
when converting into TOML tables.
Since: 1.3.0.0
Instances
ToKey Text Source # | toKey = unpack Since: 1.3.0.0 |
Defined in Toml.ToValue | |
ToKey Text Source # | toKey = unpack Since: 1.3.0.0 |
Defined in Toml.ToValue | |
Char ~ a => ToKey [a] Source # | toKey = id Since: 1.3.0.0 |
Defined in Toml.ToValue |
defaultTableToValue :: ToTable a => a -> Value Source #
Convenience function for building ToValue
instances.