Skip to content
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

Extensible Type Classes #56

Closed
orangeduck opened this issue Sep 10, 2013 · 1 comment
Closed

Extensible Type Classes #56

orangeduck opened this issue Sep 10, 2013 · 1 comment

Comments

@orangeduck
Copy link
Owner

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.

@orangeduck
Copy link
Owner Author

Added on 02a55d2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant