Commit Graph

13 Commits (master)

Author SHA1 Message Date
James T. Martin 960297e3b5
Name the language Ivo. 2021-03-26 12:31:55 -07:00
James T. Martin 9e0754daf6
Added support for Hindley-Milner type inference!
I also generalized substitution to *all* expressions (and types),
which itself involved a rewrite of the substitution function I already had.
(In hindsight, I wish I'd done that in a separate commit.)

The last four days have all been working up to this,
so I'm glad I've finally managed to integrate it into this project!
(I wrote the algorithm 4 days ago, but the infrastructure
just wasn't there to add it here.)
2021-03-18 00:00:43 -07:00
James T. Martin 74d2e26646
Make `callcc` into a proper primitive rather than a hardcoded "variable". 2021-03-16 19:03:02 -07:00
James T. Martin a543981b67
Combine expression representations using the 'trees that grow' design pattern.
Trees that grow introduces a lot of boilerplate but is bound to be essentially necessary
when I add in the type checker and all sorts of builtin data types.
(I know this because I already *implemented* those things;
it's mostly a matter of trying to merge it all into this codebase).

Accomplishing this also involved restructuring the project
and rewriting a few algorithms in the process,
but those changes are fundamentally intwined with this one.
2021-03-16 18:25:42 -07:00
James T. Martin 1321c7f54e
Remove dead code in preparation for future changes. 2021-03-15 18:31:54 -07:00
James T. Martin d7ae1f1294
Add support for call/cc (though the implementation's kinda hacky). 2021-03-05 23:38:21 -08:00
James T. Martin f73e78fcdb
Cleanup: fix warnings, fix indentation, upgrade dependencies. 2021-03-05 19:04:06 -08:00
James T. Martin 59a55acdc6
Make the parser produce a subtly better AST.
This is done by requiring applications to be at least 2 terms,
and making grouping a syntactic feature instead of a feature of applications.

I also made the code a bit more clear by handling whitespace a bit more cleanly;
now, each parser is responsible for its own trailing whitespace,
and whitespace handling is pushed down to the token level
to avoid cluttering high-level definitions with whitespace stuff.

This all also had the effect of improving error messages,
in part due to me labelling many of the parsers.
2020-11-03 15:52:04 -08:00
James T. Martin 79e054700b
Make the printer smarter, separate intermediate AST data type.
* The expression printer now knows how to use `let`, multi-argument lambdas and applications, and block arguments when appropriate.
* There is a separate type, AbstractSyntax, which separates parsing/printing logic from removing/reintroducing the more advanced syntax described above.
* Expression is now its own module because its 'show' depends on AbstractSyntax,
  and I don't want the ast2expr/expr2ast stuff to be in the same module as the real lambda calculus stuff.
2020-11-03 13:43:43 -08:00
James T. Martin 05d5abec6d
Allow defining multiple variables with one `let`. 2020-11-03 11:33:35 -08:00
James T. Martin 3b2dd67fe7
Make the parser more forgiving, re-add `let`, update README. 2020-11-02 15:59:35 -08:00
James T. Martin 3fd494a398
Use Text instead of String in expressions. 2019-12-11 19:21:54 -08:00
James T. Martin 25658f370a
Complexity was getting out of hand. Beginning a rewrite. Added tests. 2019-12-11 18:29:28 -08:00