# composite-dhall
`ToDhall` and `FromDhall` instances for
[composite](https://hackage.haskell.org/package/composite-base) records.
You lets you use extensible records over any base functor that is representable
in dhall.
You can parse normal records:
```{.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]
```
This also works for `Rec Maybe` and `Rec []`.
```{.dhall}
{ a = Just "foo"
, b = Just +5 }
```
```{.haskell}
type MyMaybeRec = Rec Maybe '[A, B]
```
Similarly you can use a contravariant functor 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."
}
```
```{.haskell}
newtype TextTemplate a = TextTemplate (Op Text a)
deriving newtype (FromDhall)
newtype TextTemplates = TextTemplates {unTemplates :: Rec Template '[A, B]}
deriving (FromDhall) via (Rec (Op Text) '[A, B])
```