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
The advantage of type classes is that they allow for user defined types to work with existing functions.
The disadvantage is that they don't easily allow users to extend existing types to work with new functions (or classes).
In Cello we can provide a way to do the second via some special class field that exists in all Type objects to be called __Parent (there already exists a special field called __Name containing a name string).
By default this field can be set to NULL, but it should be settable to some other value (a Type) at runtime by the user E.G type_parent(Int, IntParent);
The behavior of this field is to act as an extension to an existing type. That is any classes implemented by IntParent will then act as if they were also implemented by Int.
In this way users can register existing types such that they will work with any new type classes they create.
This is not an ideal method as it requires users to write a whole new Parent type and also requires them to add the correct registration at Runtime.
But it is both powerful and flexible and does let the user have some sort of family inheritance for Types if they wish.
The text was updated successfully, but these errors were encountered:
The advantage of type classes is that they allow for user defined types to work with existing functions.
The disadvantage is that they don't easily allow users to extend existing types to work with new functions (or classes).
In Cello we can provide a way to do the second via some special class field that exists in all
Type
objects to be called__Parent
(there already exists a special field called__Name
containing a name string).By default this field can be set to NULL, but it should be settable to some other value (a Type) at runtime by the user E.G
type_parent(Int, IntParent);
The behavior of this field is to act as an extension to an existing type. That is any classes implemented by
IntParent
will then act as if they were also implemented byInt
.In this way users can register existing types such that they will work with any new type classes they create.
This is not an ideal method as it requires users to write a whole new Parent type and also requires them to add the correct registration at Runtime.
But it is both powerful and flexible and does let the user have some sort of family inheritance for Types if they wish.
The text was updated successfully, but these errors were encountered: