-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add typeclasses #27
Open
smpoulsen
wants to merge
19
commits into
main
Choose a base branch
from
add-type-classes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add typeclasses #27
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Still needs work, but testing with a basic Num type class and implementation for Int, seems to be mostly working. It is still rough around the edges, is likely inefficient, and has dead code/compiler warnings.
Need to implement type classes before merging this, as operations involving numbers don't type check.
Adds a test helper to import the prelude. This kills performance and should not be a long term solution.
The code in this system is very messy and needs cleaned up prior to merging. Typeclasses are working, at least for the Num, Functor, and Monoid implementations that are included here. Needs further testing still.
Corrects the substitution for instances of a typeclass
The parenthesized arrow types are "more-lisp-like" at the expense of being more difficult to read. This changes them to follow more of an infix string representation. E.g: Old: :t map = Functor f => (-> (-> a b) (-> [f a] [f b])) New: :t map = Functor f => (a -> b) -> [f a] -> [f b]
Typeclasses seem solid now. There is still no way to constrain an implementation to depend on another typeclass, so it is up to the user to make sure that instances are defined. Because there is no hoisting/two stage eval, import order still matters.
This loads the prelude (currently typeclasses mostly) when starting the repl, evaluating files, and running tests. This is already affecting performance; starting to optimize should be a next step.
Loading the prelude once, when tests start, and passing that environment to the test functions is more efficient than loading the prelude for each file/directory. This cuts more than half the run-time off from prior to this change.
smpoulsen
force-pushed
the
add-type-classes
branch
from
October 10, 2017 12:20
1730d1f
to
4b53ce6
Compare
Merge main back into type class branch
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Typeclasses provide a means for ad hoc polymorphism.
Currently blocked pending addition of term rewriting when using typeclass-defined functions implemented in terms of other typeclass-defined functions.