bosatsu
bosatsu copied to clipboard
type aliases
there is currently no direct syntax for type aliases. This could be a pain when you want to put type annotations.
One idea would be to allow binds of capital names to be type aliases:
def foo[a](in) -> Int:
ListA = List[a]
in1: ListA = in
0
Something like this. Since all bindable names have to be lower case, this isn't ambiguous. One ambiguity does exist: for struct
we conflate the type name and the constructor. If you have a type alias for a struct, you might want to use it in a pattern match. Maybe that should simply be an error, but you can imagine usefulness of aliasing constructors as well.
Finally, maybe we would want to allow exports of aliases as transparent aliases to the underlying types.
If we want opaque aliases, I think single item structs are still the right way to go.