-
Notifications
You must be signed in to change notification settings - Fork 14
Description
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 useCode[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 typeC(for advanced users).
Alternatively, as I previously proposed in LPTK/squid-type-experiments, we could have type synonyminto enable the niceCode[T] in Csyntax (meaningCode[T]{ type Ctx >: C }), though that would likely require changes in Squid to look at theCtxmember of code types instead of theirCtype argument, which may cause weird typing problems down the line. -
Changing the code types inferred by default: we should have a
SimplePredefwhich is configured to make quasiquotes inferCode[T]types by default, instead ofCode[T,C]types; even thoughOpenCode[T,C] <: Code[T], this still does help with type inference, such as when doingvar 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 theOpenCode[T,C]type and its interaction with path-dependentVariable[T]#Ctxtypes.