HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduletoml-parser-2.0.0.0Haskell2010

Toml.Schema.ToValue

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.Schema.Generic can be used to derive instances of ToTable automatically for record types and ToValue for array types.

  • 3 classes
  • 3 values
classclass ToValue a where
#

Class for types that can be embedded into Value

Methods

  • toValue :: a -> Value

    Embed a single thing into a TOML value.

  • toValueList :: [a] -> Value

    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.

Instances31ToValue, …
  • ToValue IntegerDefined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue NaturalDefined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue Int16Defined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue Int32Defined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue Int64Defined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue Int8Defined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue Word16Defined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue Word32Defined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue Word64Defined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue Word8Defined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue BoolDefined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue CharDefined in toml-parser-2.0.0.0 · Toml.Schema.ToValue

    Single characters are encoded as singleton strings. Lists of characters are encoded as a single string value.

  • ToValue DoubleDefined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue FloatDefined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue IntDefined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue WordDefined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue TextDefined in toml-parser-2.0.0.0 · Toml.Schema.ToValue

    Encodes as string literal

  • ToValue TextDefined in toml-parser-2.0.0.0 · Toml.Schema.ToValue

    Encodes as string literal

  • ToValue DayDefined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue LocalTimeDefined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue TimeOfDayDefined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue ZonedTimeDefined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue ValueDefined in toml-parser-2.0.0.0 · Toml.Schema.ToValue

    Identity function

  • Integral a => ToValue (Ratio a)Defined in toml-parser-2.0.0.0 · Toml.Schema.ToValue

    TOML represents floating point numbers with Double. This operation lose precision and can overflow to infinity.

  • ToValue (Table' a)Defined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToValue a => ToValue (Seq a)Defined in toml-parser-2.0.0.0 · Toml.Schema.ToValue

    Converts to list and encodes that to value

  • ToValue a => ToValue (NonEmpty a)Defined in toml-parser-2.0.0.0 · Toml.Schema.ToValue

    Converts to list and encodes that to value

  • ToValue a => ToValue [a]Defined in toml-parser-2.0.0.0 · Toml.Schema.ToValue

    This instance defers to the list element's toValueList implementation.

  • (Generic a, GToArray (Rep a)) => ToValue (GenericTomlArray a)Defined in toml-parser-2.0.0.0 · Toml.Schema.Generic

    Instance derived using genericToArray

  • (Generic a, GToTable (Rep a)) => ToValue (GenericTomlTable a)Defined in toml-parser-2.0.0.0 · Toml.Schema.Generic

    Instance derived from ToTable instance using defaultTableToValue

  • (ToKey k, ToValue v) => ToValue (Map k v)Defined in toml-parser-2.0.0.0 · Toml.Schema.ToValue

Table construction

5 declarations
classclass ToValue a => ToTable a where
#

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

Methods

Instances3ToTable
classclass ToKey a where
#

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.

Methods

Instances3ToKey
  • ToKey TextDefined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • ToKey TextDefined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
  • Char ~ a => ToKey [a]Defined in toml-parser-2.0.0.0 · Toml.Schema.ToValue
valuetable :: [(Text, Value)] -> Table
#

Build a Table from a list of key-value pairs.

Use .= for a convenient way to build the pairs.