UnionPayloadStyleUnion

PackageReified.Schema

UnionPayloadStyle

UnionPayloadStyle controls how a case's authored fields are represented inside adjacent or external union tagging. It is the payloadStyle argument of UnionRepresentation.Adjacent and UnionRepresentation.External, and the PayloadStyle argument of [<DeriveUnion>].

Style JSON for a two-field case JSON for a one-field case
UnionPayloadStyle.Named { "x": 10, "y": 20 } { "amount": 12.5 }
UnionPayloadStyle.Positional [10, 20] [12.5]
UnionPayloadStyle.UnwrappedSingle invalid for two fields 12.5
UnionPayloadStyle.NamedWithUnwrappedSingle { "x": 10, "y": 20 } 12.5
UnionPayloadStyle.PositionalWithUnwrappedSingle [10, 20] 12.5

UnwrappedSingle requires every payload case to contain exactly one field. The adaptive styles (NamedWithUnwrappedSingle, PositionalWithUnwrappedSingle) unwrap only one-field cases and retain named objects or positional arrays for larger cases.

See Advanced Union Handling for JSON examples of each style.

Specification

Kind
Union
Members
10
Examples
0
IsNamedSignature
this.IsNamed
IsUnwrappedSingleSignature
this.IsUnwrappedSingle
IsPositionalWithUnwrappedSingleSignature
this.IsPositionalWithUnwrappedSingle
IsPositionalSignature
this.IsPositional
IsNamedWithUnwrappedSingleSignature
this.IsNamedWithUnwrappedSingle

Summary

NameSignatureSynopsis
Union cases
IsNamedthis.IsNamedNo description available.
IsUnwrappedSinglethis.IsUnwrappedSingleNo description available.
IsPositionalWithUnwrappedSinglethis.IsPositionalWithUnwrappedSingleNo description available.
IsPositionalthis.IsPositionalNo description available.
IsNamedWithUnwrappedSinglethis.IsNamedWithUnwrappedSingleNo description available.
NamedNamedNo description available.
PositionalPositionalNo description available.
UnwrappedSingleUnwrappedSingleNo description available.
NamedWithUnwrappedSingleNamedWithUnwrappedSingleNo description available.
PositionalWithUnwrappedSinglePositionalWithUnwrappedSingleNo description available.

Union cases

kind:member

IsNamed

this.IsNamed
Member

Returns

bool
kind:member

IsUnwrappedSingle

this.IsUnwrappedSingle
Member

Returns

bool
kind:member

IsPositionalWithUnwrappedSingle

this.IsPositionalWithUnwrappedSingle
Member

Returns

bool
kind:member

IsPositional

this.IsPositional
Member

Returns

bool
kind:member

IsNamedWithUnwrappedSingle

this.IsNamedWithUnwrappedSingle
Member

Returns

bool
kind:member

Named

Named
Member

Returns

unit
kind:member

Positional

Positional
Member

Returns

unit
kind:member

UnwrappedSingle

UnwrappedSingle
Member

Returns

unit
kind:member

NamedWithUnwrappedSingle

NamedWithUnwrappedSingle
Member

Returns

unit
kind:member

PositionalWithUnwrappedSingle

PositionalWithUnwrappedSingle
Member

Returns

unit