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

Make non-contextual Code the default #63

Open
3 tasks
LPTK opened this issue Jan 28, 2019 · 0 comments
Open
3 tasks

Make non-contextual Code the default #63

LPTK opened this issue Jan 28, 2019 · 0 comments

Comments

@LPTK
Copy link
Member

LPTK commented Jan 28, 2019

It is entirely possible to use Squid without statically checking scopes, similar to MetaOCaml or Dotty's quotes (but of course with more features, like pattern matching).

This simpler mode of usage is less type-safe, but makes many things much easier and less intimidating for beginners. One has to use the OpenCode[T] type (which is a super type of the contextual Code[T,C]), and use .unsafe_asClosedCode whenever one wants to run or compile the piece of code.

However, currently we emphasize the contextual mode of Squid as the default/normal mode, which is intimidating and may scare beginners away. Instead, I think we should promote the simpler interface as the default interface, and reserve the contextual interface for advanced users. This would mean:

  • Changing the type synonyms: OpenCode[T] is long-winded and a bit ugly; we'd like to use Code[T] instead. The new scheme would be: Code[T] for when you do not know the context, ClosedCode[T] for code that is assuredly closed and can be run; OpenCode[T,C] for open code for which we statically track the scope using contextual type C (for advanced users).
    Alternatively, as I previously proposed in LPTK/squid-type-experiments, we could have type synonym in to enable the nice Code[T] in C syntax (meaning Code[T]{ type Ctx >: C }), though that would likely require changes in Squid to look at the Ctx member of code types instead of their C type argument, which may cause weird typing problems down the line.

  • Changing the code types inferred by default: we should have a SimplePredef which is configured to make quasiquotes infer Code[T] types by default, instead of Code[T,C] types; even though OpenCode[T,C] <: Code[T], this still does help with type inference, such as when doing var c = code"0"; ... ; c = code"<open term>".

  • Splitting the basic tutorial in two: there should be a basic tutorial using simple Code[T] types and cross-quotation references, which are now supported, and a tutorial for advanced users that demonstrates the OpenCode[T,C] type and its interaction with path-dependent Variable[T]#Ctx types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant