Skip to content

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:

@Frotty Frotty force-pushed the master branch 2 times, most recently from 1c4a76c to ca47830 Compare June 24, 2025 16:48
@Frotty Frotty force-pushed the master branch 2 times, most recently from 3bbfe78 to fdcd03d Compare October 18, 2025 09:02
@Frotty Frotty force-pushed the master branch 2 times, most recently from e640e98 to 5535ed8 Compare October 30, 2025 10:45
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.

3 participants