dhall-nix-lib/JSON/tagInline.dhall

24 lines
684 B
Text
Raw Normal View History

2022-09-02 09:03:27 +00:00
--| Prepare a union value for JSON- or YAML-encoding with the inline layout
let Nesting = ./Nesting.dhall
let Tagged = ./Tagged.dhall
let tagInline
: Text → ∀(a : Type) → a → Tagged a
= λ(tagFieldName : Text) →
λ(a : Type) →
λ(contents : a) →
{ nesting = Nesting.Inline, field = tagFieldName, contents }
let example0 =
let Example = < Left : { foo : Natural } | Right : { bar : Bool } >
in assert
: tagInline "name" Example (Example.Left { foo = 2 })
≡ { field = "name"
, nesting = Nesting.Inline
, contents = Example.Left { foo = 2 }
}
in tagInline