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
In the above conversation, there was a discussion about an issue with nesting Data.TaggedEnum resulting in a never type. The initial suggestion was to change the definition of TaggedEnum to include a value field instead of intersecting it with { _tag: Tag }. This would allow for easier construction of nested sum types and improve the developer experience.
However, there were different opinions on whether this change is desirable. One argument was that having a nested value field is expected and aligns with the current implementation. Another argument was that it would be more convenient to have a flat structure without the need for a nested value field.
Ultimately, it was suggested to seek input from someone else, such as @gcanti, to make a decision on how to address this issue. Some key takeaways from the discussion include:
The current implementation of TaggedEnum requires a nested value field, which can result in unexpected never types.
There is a desire to improve the developer experience and avoid puzzling never errors at the construction call site.
Different approaches were proposed, including automatically adding a value field or using a different field name based on the tag name.
The trade-offs between convenience and maintaining consistency with the current implementation were discussed.
Ultimately, the decision on how to address this issue will depend on the goals and priorities of the Data.TaggedEnum library.
@Clindbergh It's been a minute since I worked on this, but IIRC the change implemented as part of #1521 was to show users a TypeError if they attempt to nest a TaggedEnum inside another TaggedEnum.
Summary
In the above conversation, there was a discussion about an issue with nesting
Data.TaggedEnum
resulting in anever
type. The initial suggestion was to change the definition ofTaggedEnum
to include avalue
field instead of intersecting it with{ _tag: Tag }
. This would allow for easier construction of nested sum types and improve the developer experience.However, there were different opinions on whether this change is desirable. One argument was that having a nested value field is expected and aligns with the current implementation. Another argument was that it would be more convenient to have a flat structure without the need for a nested value field.
Ultimately, it was suggested to seek input from someone else, such as @gcanti, to make a decision on how to address this issue. Some key takeaways from the discussion include:
TaggedEnum
requires a nested value field, which can result in unexpectednever
types.never
errors at the construction call site.value
field or using a different field name based on the tag name.Ultimately, the decision on how to address this issue will depend on the goals and priorities of the
Data.TaggedEnum
library.Discord thread
https://discord.com/channels/795981131316985866/1159518689972981780
The text was updated successfully, but these errors were encountered: