Open osa1 opened 2 months ago
The PhD thesis "Type Safe Extensible Programming" describes a similar system where exception handling is represented using row types in function types.
Section 3.1.3 "Exception handlers as extensible cases" gives a few examples of what their type system accepts.
However it doesn't give examples of function subtyping examples above, so I'm not sure if the type system supports it. The examples it gives:
raise
has matching handle
in the same function.handle
.map
reflects the exceptions its funciton argument raises.
(Original post in https://gist.github.com/osa1/38fd51abe5247462eddb7d014f320cd2)
Fir should have convenient handling of error values, using polymorphic variants.
Fir won't have subtyping for named types, but if necessary (and can be done while maintaining soundness) we can have subtyping for records and variants.
The type system should support these use cases:
Questions:
Can you think of any other use cases that the type system should support, to make error handling via anonymous variants convenient and expressive?
Note: I'm not asking about syntax features. We can make it less verbose/nicer once we have a type system that is expressive enough.
Can
f6
be expressed in a system with subtyping instead of row polymorphism? How?Can function subtyping examples work in a system with row polymorphism? How?
Assuming both are possible, what do I win/lose by chosing one or the other?
Note: the choice of row poly. or subtyping will only apply to anonymous variants and records. The language already has parametric poly. with typeclasses and won't have subtyping for named types.