# composite-dhall
`ToDhall` and `FromDhall` instances for
[composite](https://hackage.haskell.org/package/composite-base) records.
You can deserialise a normal dhall record such as
```{.dhall}
{ a = "foo"
, b = +5 }
```
using a `Record` like:
```{.haskell}
withLensesAndProxies
[d|
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.
```{.dhall}
{ 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])
```