composite-dhall: Dhall instances for composite records.

[ composite, data, dhall, library, mit ] [ Propose Tags ]

Dhall instances for composite records.

[Skip to Readme]


[Index] [Quick Jump]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS],,,,,,,
Change log
Dependencies base (>=4.7 && <5), composite-base (>= && <0.8), dhall (>=1.34.0 && <1.40), text (>=1.0 && <1.4), vinyl [details]
License MIT
Copyright 2021 Daniel Firth
Author Daniel Firth
Category Dhall
Source repo head: git clone
Uploaded by locallycompact at 2021-08-09T13:09:29Z
Downloads 915 total (19 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
All reported builds failed as of 2021-08-09 [all 1 reports]

Readme for composite-dhall-

[back to package description]


ToDhall and FromDhall instances for composite records.

You can deserialise a normal dhall record such as

{ a = "foo"
, b = +5 }

using a Record like:

    type A = "a" :-> Text

    type B = "b" :-> Int

type MyRec = Record '[A, B]

Similarly you can use a contravariant function as the base functor to parse a collection of templates for different types.

{ a = \(x : Text) -> "Hello ${x}."
, b = \(y : Integer) -> "You are ${Integer/show y} years old."

We use a DerivingVia to avoid overlapping instances in composite:

newtype Template a = Template (Op Text a)
  deriving newtype (FromDhall)

newtype Templates = Templates {unTemplates :: Rec Template '[A, B]}
  deriving (FromDhall) via (Rec (Op Text) '[A, B])