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

  • 12 types
  • 3 classes
  • 29 values

FromValue

3 declarations
classclass FromValue a where
#

Class for types that can be decoded from a TOML value.

Methods

Instances31FromValue, …
  • FromValue IntegerDefined in toml-parser-2.0.0.0 · Toml.Schema.FromValue

    Matches integer values

  • FromValue NaturalDefined in toml-parser-2.0.0.0 · Toml.Schema.FromValue

    Matches non-negative integer values

  • FromValue Int16Defined in toml-parser-2.0.0.0 · Toml.Schema.FromValue
  • FromValue Int32Defined in toml-parser-2.0.0.0 · Toml.Schema.FromValue
  • FromValue Int64Defined in toml-parser-2.0.0.0 · Toml.Schema.FromValue
  • FromValue Int8Defined in toml-parser-2.0.0.0 · Toml.Schema.FromValue
  • FromValue Word16Defined in toml-parser-2.0.0.0 · Toml.Schema.FromValue
  • FromValue Word32Defined in toml-parser-2.0.0.0 · Toml.Schema.FromValue
  • FromValue Word64Defined in toml-parser-2.0.0.0 · Toml.Schema.FromValue
  • FromValue Word8Defined in toml-parser-2.0.0.0 · Toml.Schema.FromValue
  • FromValue BoolDefined in toml-parser-2.0.0.0 · Toml.Schema.FromValue

    Matches true and false

  • FromValue CharDefined in toml-parser-2.0.0.0 · Toml.Schema.FromValue

    Matches single-character strings with fromValue and arbitrary strings with listFromValue to support String

  • FromValue DoubleDefined in toml-parser-2.0.0.0 · Toml.Schema.FromValue

    Matches floating-point and integer values

  • FromValue FloatDefined in toml-parser-2.0.0.0 · Toml.Schema.FromValue

    Matches floating-point and integer values

  • FromValue IntDefined in toml-parser-2.0.0.0 · Toml.Schema.FromValue
  • FromValue WordDefined in toml-parser-2.0.0.0 · Toml.Schema.FromValue
  • FromValue TextDefined in toml-parser-2.0.0.0 · Toml.Schema.FromValue

    Matches string literals

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

    Matches string literals

  • FromValue DayDefined in toml-parser-2.0.0.0 · Toml.Schema.FromValue

    Matches local date literals

  • FromValue LocalTimeDefined in toml-parser-2.0.0.0 · Toml.Schema.FromValue

    Matches local date-time literals

  • FromValue TimeOfDayDefined in toml-parser-2.0.0.0 · Toml.Schema.FromValue

    Matches local time literals

  • FromValue ZonedTimeDefined in toml-parser-2.0.0.0 · Toml.Schema.FromValue

    Matches offset date-time literals

  • FromValue TableDefined in toml-parser-2.0.0.0 · Toml.Schema.FromValue
  • FromValue ValueDefined in toml-parser-2.0.0.0 · Toml.Schema.FromValue

    Matches all values, used for pass-through

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

    Matches floating-point and integer values.

    TOML specifies Floats should be implemented as IEEE 754 binary64 values. so note that the given Rational will be converted from a double representation and will often be an approximation rather than the exact value.

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

    Matches arrays

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

    Matches non-empty arrays or reports an error.

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

    Implemented in terms of listFromValue

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

    Instance derived using genericFromArray

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

    Instance derived using genericParseTable

  • (Ord k, FromKey k, FromValue v) => FromValue (Map k v)Defined in toml-parser-2.0.0.0 · Toml.Schema.FromValue
valuemapOf
  1. :: Ord k
  2. => (l -> Text -> Matcher l k)

    key matcher

  3. -> (Text -> Value' l -> Matcher l v)

    value matcher

  4. -> Value' l
  5. -> Matcher l (Map k v)
#

Table matching function used to help implement fromValue for tables. Key matching function is given the annotation of the key for error reporting. Value matching function is given the key in case values can depend on their keys.

valuelistOf :: (Int -> Value' l -> Matcher l a) -> Value' l -> Matcher l [a]
#

List matching function used to help implemented fromValue for arrays. The element matching function is given the list index in case values can depend on their index.

Matcher

newtypenewtype Matcher l a
#

Computations that result in a Result and which track a list of nested contexts to assist in generating warnings and error messages.

Use withScope to run a Matcher in a new, nested scope.

Instances6Monad, Functor, MonadFail, Applicative, Alternative, MonadPlus
  • Monad (Matcher a)Defined in toml-parser-2.0.0.0 · Toml.Schema.Matcher
  • Functor (Matcher a)Defined in toml-parser-2.0.0.0 · Toml.Schema.Matcher
  • MonadFail (Matcher a)Defined in toml-parser-2.0.0.0 · Toml.Schema.Matcher

    Fail with an error message without an annotation.

  • Applicative (Matcher a)Defined in toml-parser-2.0.0.0 · Toml.Schema.Matcher
  • Alternative (Matcher a)Defined in toml-parser-2.0.0.0 · Toml.Schema.Matcher
  • MonadPlus (Matcher a)Defined in toml-parser-2.0.0.0 · Toml.Schema.Matcher
datadata Result e a
#

Computation outcome with error and warning messages. Multiple error messages can occur when multiple alternatives all fail. Resolving any one of the error messages could allow the computation to succeed.

Constructors

Instances4Eq, Ord, Read, Show
  • (Eq e, Eq a) => Eq (Result e a)Defined in toml-parser-2.0.0.0 · Toml.Schema.Matcher

    Default instance

  • (Ord e, Ord a) => Ord (Result e a)Defined in toml-parser-2.0.0.0 · Toml.Schema.Matcher

    Default instance

  • (Read e, Read a) => Read (Result e a)Defined in toml-parser-2.0.0.0 · Toml.Schema.Matcher

    Default instance

  • (Show e, Show a) => Show (Result e a)Defined in toml-parser-2.0.0.0 · Toml.Schema.Matcher

    Default instance

datadata MatchMessage a
#

A message emitted while matching a TOML value. The message is paired with the path to the value that was in focus when the message was generated. These message get used for both warnings and errors.

For a convenient way to render these to a string, see Toml.Pretty.prettyMatchMessage.

Constructors

Instances7Functor, Foldable, Traversable, Eq, Ord, Read, …
datadata Scope
#

Scopes for TOML message.

Constructors

Instances4Eq, Ord, Read, Show
  • Eq ScopeDefined in toml-parser-2.0.0.0 · Toml.Schema.Matcher

    Default instance

  • Ord ScopeDefined in toml-parser-2.0.0.0 · Toml.Schema.Matcher

    Default instance

  • Read ScopeDefined in toml-parser-2.0.0.0 · Toml.Schema.Matcher

    Default instance

  • Show ScopeDefined in toml-parser-2.0.0.0 · Toml.Schema.Matcher

    Default instance

valuefailAt :: l -> String -> Matcher l a
#

Terminate the match with an error mentioning the given annotation.

Tables

newtypenewtype ParseTable l a
#

Parser that tracks a current set of unmatched key-value pairs from a table.

Use Toml.Schema.optKey and Toml.Schema.reqKey to extract keys.

Use getTable and setTable to override the table and implement other primitives.

Instances6Monad, Functor, MonadFail, Applicative, Alternative, MonadPlus
valuepickKey :: [KeyAlt l a] -> ParseTable l a
#

Take the first option from a list of table keys and matcher functions. This operation will commit to the first table key that matches. If the associated matcher fails, only that error will be propagated and the other alternatives will not be matched.

If no keys match, an error message is generated explaining which keys would have been accepted.

This is provided as an alternative to chaining multiple Toml.Schema.reqKey cases together with Alternative which will fall-through as a result of any failure to the next case.

datadata KeyAlt l a
#

Key and value matching function

Constructors

ToValue

5 declarations
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
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
valuetable :: [(Text, Value)] -> Table
#

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

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

Types

14 declarations
datadata Value' a
#

Semantic TOML value with all table assignments resolved.

Instances9Functor, Foldable, Traversable, FromValue, ToValue, Eq, …
  • Functor Value'Defined in toml-parser-2.0.0.0 · Toml.Semantics.Types

    Derived

  • Foldable Value'Defined in toml-parser-2.0.0.0 · Toml.Semantics.Types

    Derived

  • Traversable Value'Defined in toml-parser-2.0.0.0 · Toml.Semantics.Types

    Derived

  • FromValue ValueDefined in toml-parser-2.0.0.0 · Toml.Schema.FromValue

    Matches all values, used for pass-through

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

    Identity function

  • Eq a => Eq (Value' a)Defined in toml-parser-2.0.0.0 · Toml.Semantics.Types

    Nearly default instance except ZonedTime doesn't have an Eq instance. ZonedTime values are equal if their times and time-zones are both equal.

  • Read a => Read (Value' a)Defined in toml-parser-2.0.0.0 · Toml.Semantics.Types

    Default instance

  • Show a => Show (Value' a)Defined in toml-parser-2.0.0.0 · Toml.Semantics.Types

    Default instance

  • () ~ a => IsString (Value' a)Defined in toml-parser-2.0.0.0 · Toml.Semantics.Types

    Constructs a TOML string literal.

    fromString = String
    
newtypenewtype Table' a
#

A table with annotated keys and values.

Constructors

Instances9Functor, Foldable, Traversable, FromValue, Eq, Read, …
  • Functor Table'Defined in toml-parser-2.0.0.0 · Toml.Semantics.Types

    Derived

  • Foldable Table'Defined in toml-parser-2.0.0.0 · Toml.Semantics.Types

    Derived

  • Traversable Table'Defined in toml-parser-2.0.0.0 · Toml.Semantics.Types

    Derived

  • FromValue TableDefined in toml-parser-2.0.0.0 · Toml.Schema.FromValue
  • Eq a => Eq (Table' a)Defined in toml-parser-2.0.0.0 · Toml.Semantics.Types

    Default instance

  • Read a => Read (Table' a)Defined in toml-parser-2.0.0.0 · Toml.Semantics.Types

    Default instance

  • Show a => Show (Table' a)Defined in toml-parser-2.0.0.0 · Toml.Semantics.Types

    Default instance

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

Generics

6 declarations
newtypenewtype GenericTomlArray a
#

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

Constructors

Instances2FromValue, ToValue
newtypenewtype GenericTomlTable a
#

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

Constructors

Instances3FromValue, ToTable, ToValue