-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tagged Union Syntax #13
Comments
type Shape
= Circle (radius: Float)
| Rectangle (height: Float, width: Float)
| None
area: (shape: Shape) -> (result: Float) := {
(shape = Circle(radius)) ->
radius.square.multiple(by:= pi),
(shape = Rectangle(height, width)) ->
height.multiple(by:= width),
(shape = None) ->
0
}
ps. I think we need to think the type system first. #17 |
If we make ADT cases an individual constructor, the BAD thing is that it might be confusing for some cases, because user might not know which type does the constructor belongs to, but the GOOD thing is the code is shorter. Example:
===
If we use ADT cases as individual constructor, we need to prevent this type of clashing by using prefixes:
The BAD thing is of course the resulting code will be noisier. Example:
|
Q: Do we support pattern matching over the anonymous tagged union. so here's how Rust does it: let x: None | Some(i32) = Some(100) the compiler creates an invisible enum, it's just like pattern matching against normal enums. (1) Q: How do rec-Nat and recursion works? Q: Can we make the pattern matching case into the polymorphic record, so that we can compose cases. References |
Things do discussed:
The text was updated successfully, but these errors were encountered: