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

Add type system #13

Merged
merged 22 commits into from
Aug 27, 2017
Merged

Add type system #13

merged 22 commits into from
Aug 27, 2017

Conversation

smpoulsen
Copy link
Owner

@smpoulsen smpoulsen commented Aug 16, 2017

screen shot 2017-08-17 at 22 31 21

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.
@smpoulsen
Copy link
Owner Author

screen shot 2017-08-26 at 14 40 24

Alpha-conversion so that results read e.g. `(((a -> b) -> a) -> b)` instead of
`(((c -> d) -> c) -> d)`
@smpoulsen smpoulsen merged commit dfa8201 into master Aug 27, 2017
@smpoulsen smpoulsen deleted the add-types branch August 27, 2017 02:31
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.

1 participant