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

Type case operator that gets stuck on unsolved metas (i.e. THE DREAM ACHIEVED) #53

Merged
merged 10 commits into from
May 6, 2020

Conversation

david-christiansen
Copy link
Collaborator

This is based on #47, because of the various bug fixes and such in it. On top of #47's changes, it has the following:

  • The expression constructor of Problem has been given a primitive representation of types at the next phase as an argument (the new built-in type Type)
  • The new type-case operator allows matching on a Type in a monadic context, getting stuck if that type is not yet determined. Type patterns are expansion positions, just like data patterns.

Things to be improved over time:

  • If type-case never gets un-stuck, the error message is quite bad. We probably need some provenance tracking for metas to tell it where they are from, at the very least.

This is the equivalent of Racket's make-syntax-introducer and
generate-temporaries.
This makes debugging much easier.
Some examples relied on this bug - it's now fixed.

Fixes #48.
This commit contains the final bits of run-time and expander support
for a monadic type-case operator that gets stuck on unsolved metas.

The which-problem example has been updated with a demonstration that
the type checker's order of traversal is independent of the
availability of type information to the macro expander.

(m)

(example (case (unit)
((m) (true))))

(define-macros
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so cool 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could try to imlement something like Cryptol's zero operator using this. That'd be fun :-)

Copy link
Collaborator

@langston-barrett langston-barrett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!!!

examples/temporaries.kl Show resolved Hide resolved
@@ -15,6 +15,7 @@ dependencies:
- lens
- megaparsec
- mtl
- n-ary-functor
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, you used my n-ary-functor package! I'm so proud! but... where are you using it? I don't see any import NAryFunctor.

@david-christiansen
Copy link
Collaborator Author

david-christiansen commented May 6, 2020 via email

@langston-barrett langston-barrett deleted the type-case branch August 26, 2020 00:01
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