proposal: spec: unions as sigma types
<!-- Our process for evaluating language changes can be found here: https://go.googlesource.com/proposal/+/refs/heads/master#language-changes --> ## Author background - **Would you consider yourself a novice, intermediate, or experienced Go programmer?** Experienced. - **What other languages do you have experience with?** C, Java, Rust, Python, MATLAB, Haskell, TypeScript, various flavors of assembly ## Related proposals - **Has this idea, or one like it, been proposed before?** I previously proposed a less refined form as an invested April fools' joke at #52096; this is intended to be a serious proposal. It resembles sum types (#19412) or typed enums (#19814, #28438, #28987) in the capability of the type system, although it is more general. - **If so, how does this proposal differ?** The types proposed are more general than sum types, which are in turn more general than typed enums. In particular, the mechanisms in this proposal would greatly simplify certain scenarios encountered in marshaling and unmarshaling when compared to sum types. ## Proposal Introduce a restricted version of sigma types into Go. Formally, sigma types are pairs `(a: T, b: B(a))` where `a` is a value of type `T` and `B` is a function that constructs the type of `b` from the value of `a`. Less formally, they can be considered tagged unions where the tag is an accessible value of a type the programmer can select. Sigma types are a central feature of dependent type systems, which make it possibl
Posted by zephyrtronium on Aug 26, 2022, 5:07 AM
Tags
Related issues
- struct's lifetime requirements can be bypassed via covariant field assignment
- Proposal to Reorganize the Moderation Team and Review Moderation Policies
- Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
- proposal: container/...: generic collection types
- Better Custom Endpoint BYOK
- A concrete policy for backward compatibility until Godot 5.0
Raise real-world problems, find people facing the same issue, and discuss solutions.2,500 issues0 comments
github (Other)
struct's lifetime requirements can be bypassed via covariant field assignment
Proposal to Reorganize the Moderation Team and Review Moderation Policies
Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
proposal: container/...: generic collection types
Better Custom Endpoint BYOK
A concrete policy for backward compatibility until Godot 5.0
New MTP models not supported
Tracking: 429 / Capacity Issues
proposal: spec: unions as sigma types
<!-- Our process for evaluating language changes can be found here: https://go.googlesource.com/proposal/+/refs/heads/master#language-changes --> ## Author background - **Would you consider yourself a novice, intermediate, or experienced Go programmer?** Experienced. - **What other languages do you have experience with?** C, Java, Rust, Python, MATLAB, Haskell, TypeScript, various flavors of assembly ## Related proposals - **Has this idea, or one like it, been proposed before?** I previously proposed a less refined form as an invested April fools' joke at #52096; this is intended to be a serious proposal. It resembles sum types (#19412) or typed enums (#19814, #28438, #28987) in the capability of the type system, although it is more general. - **If so, how does this proposal differ?** The types proposed are more general than sum types, which are in turn more general than typed enums. In particular, the mechanisms in this proposal would greatly simplify certain scenarios encountered in marshaling and unmarshaling when compared to sum types. ## Proposal Introduce a restricted version of sigma types into Go. Formally, sigma types are pairs `(a: T, b: B(a))` where `a` is a value of type `T` and `B` is a function that constructs the type of `b` from the value of `a`. Less formally, they can be considered tagged unions where the tag is an accessible value of a type the programmer can select. Sigma types are a central feature of dependent type systems, which make it possibl
Comments (0)
No comments yet. Start the discussion.