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

[WIP] Type classes #931

Draft
wants to merge 52 commits into
base: master
Choose a base branch
from
Draft

[WIP] Type classes #931

wants to merge 52 commits into from

Conversation

peq
Copy link
Collaborator

@peq peq commented Jan 31, 2020

This branch contains an implementation of type classes as described in the new generics design in #679.

TODO list:

  • Instance Declarations
  • Basic Type Bounds
  • Type bounds in classes
  • Dependent type classes
  • Efficient search + namespacing (only search for instances in imported packages)
  • implicit instances for classes: ToIndex, FromIndex (maybe: TableKey, TableValue, Hashable)
  • Type Check: All functions implemented correctly
  • Add check for diverging instance search
  • Also search for supertypes
  • Also search for methods in extended interfaces
  • Overloads with extension methods / type classes should not give error.

Maybe add:

  • Complex inference (see Iterable example)
  • Translate casting to int using ToIndex and FromIndex type classes (better backwards compatibility)
  • Use type classes for iterators (for-loops)
  • Use type classes for operator overloading
  • Add an expression (or magic function) for obtaining type class instances and calling methods on them, like (implicitly<Show>.toString(42))
  • Automatically use existing methods and extension functions in instance declarations

@peq peq mentioned this pull request Jan 31, 2020
@Frotty
Copy link
Member

Frotty commented Jan 31, 2020

Nice 👍
I'm not too sure about the name instance since we frequently use it in the documentation to refer to a class instance.

@peq
Copy link
Collaborator Author

peq commented Jan 31, 2020

Yeah, will probably change it as it also introduces a new keyword and thus breaks StdLib tests.

Maybe just implements Show<int> or for <T: Show> implements Show<List<T>>?

@peq peq mentioned this pull request Feb 13, 2020
@Frotty
Copy link
Member

Frotty commented Feb 15, 2020

I get this error when trying to compile forest defense:

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

Successfully merging this pull request may close these issues.

2 participants