-
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 type system #13
Merged
Add type system #13
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
Owner
smpoulsen
commented
Aug 16, 2017
•
edited
Loading
edited
Not completely built out, but basic functionality is present. Good save spot.
Was set as Int -> Int -> Int; should have been a - b -> Int
The inferred types weren't getting substituted properly, resulting in general types being provided as output instead of the more specific when one was found.
Type inference wasn't substituting the inferred type
This section of the massive case statement is perhaps uglier than the rest; no reference for this one, just found something that worked. Needs a refactor, much like the rest of it.
Makes more sense to pack type into a tuple than intersperse it into the list.
Generating fresh type vars is moved into a GenServer that maintains its own index state. Will have to think a little about when to reset it. This ultimately results in the eval_env state not having to be threaded through every function in the module.
So that type errors don't crash the host, propagates them as {:ok, type} | {:error, e} return values.
Almost right; just getting two variables that should be different
Tested by type-checking foldl; types are inferred properly now. Changes the `str` for function types to wrap each fn in parens. It does make it a little harder to read, but it's also true to semantics since functions are all curried.
Alpha-conversion so that results read e.g. `(((a -> b) -> a) -> b)` instead of `(((c -> d) -> c) -> d)`
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.