23 lines
684 B
Text
23 lines
684 B
Text
--| 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
|