HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Moduletomland-1.3.3.3Haskell2010

Toml.Codec.Types

SPDX-License-Identifier : MPL-2.0 Maintainer : Kowainik xrom.xkov@gmail.com Stability : Stable Portability : Portable

Contains general underlying monad for bidirectional conversion.

Contents
  1. Toml Codec
  2. Toml Environment
  3. Toml State
  4. Codec
  5. Function alternative
Synopsis
  • Packagetomland-1.3.3.3
  • Exports6
  • LanguageHaskell2010
  • LicenceMPL-2.0
  • SourceTypes.hs

Toml Codec

typetype TomlCodec a = Codec a a

Specialied Codec type alias for bidirectional TOML serialization. Keeps TOML object as both environment and state.

Toml Environment

Toml State

newtypenewtype TomlState a

Mutable context for TOML conversion. We are introducing our own implemetation of state with MonadState instance due to some limitation in the design connected to the usage of State.

This newtype is equivalent to the following transformer:

MaybeT (State TOML)

Constructors

Instances5Monad, Functor, Applicative, Alternative, MonadState

Codec

datadata Codec i o

Monad for bidirectional conversion. Contains pair of functions:

  1. How to read value of type o (out) from immutable environment context (TomlEnv)?

  2. How to store a value of type i (in) in stateful context (TomlState) and return a value of type o?

This approach with the bunch of utility functions allows to have single description for from/to TOML conversion.

In practice this type will always be used in the following way:

type TomlCodec a = Codec a a

Type parameter i if fictional. Here some trick is used. This trick is implemented in the codec package and described in more details in related blog post: https://blog.poisson.chat/posts/2016-10-12-bidirectional-serialization.html.

Constructors

  • Codec
    • codecRead :: TomlEnv o

      Extract value of type o from monadic context TomlEnv.

    • codecWrite :: i -> TomlState o

      Store value of type i inside monadic context TomlState and returning value of type o. Type of this function actually should be o -> TomlState () but with such type it's impossible to have Monad and other instances.

Instances3Functor, Applicative, Alternative

Function alternative

value(<!>) :: Alternative f => (a -> f x) -> (a -> f x) -> a -> f x

Alternative instance for function arrow but without empty.