You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are a few reasons to support sum types in FTL, but one of the primary motivations is mapping FTL types to JSON. JSON very frequently supports multiple types for a single key. eg. both of these might be valid keys:
{
"depends": "foo"
}
and
{
"depends": ["foo", "bar"]
}
We'll need to ensure that however we implement this, it's relatively simple to express sum types in each language, even languages like Go and Kotlin that don't provide first-class support for sum types.
How are sum types represented in ingress JSON? {"kind": "Scalar", "value": "foo"}? In the example above this is probably redundant because we can tell from the type, but for data structures we wouldn't be able to. Though it might still be ambiguous in the case of eg. Bytes | String because Bytes is represented as a string, so probably better to be explicit.
How are sum types represented in ingress JSON? {"kind": "Scalar", "value": "foo"}? In the example above this is probably redundant because we can tell from the type, but for data structures we wouldn't be able to. Though it might still be ambiguous in the case of eg. Bytes | String because Bytes is represented as a string, so probably better to be explicit.
yeah a lot to unpack here, updated the design with discussion around encoding/a proposed strategy
json.(Un)Marshaler
/encoding.Text(Un)Marshaler
on user-defined types #1247main.go
is updated with schema changes duringftl dev
#1451Design
There are a few reasons to support sum types in FTL, but one of the primary motivations is mapping FTL types to JSON. JSON very frequently supports multiple types for a single key. eg. both of these might be valid keys:
and
We'll need to ensure that however we implement this, it's relatively simple to express sum types in each language, even languages like Go and Kotlin that don't provide first-class support for sum types.
eg. in Go this might look like:
The text was updated successfully, but these errors were encountered: