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

Multiple (aliased) "imports" of types when permuting a domain #58

Open
rhinomode opened this issue Dec 18, 2020 · 0 comments
Open

Multiple (aliased) "imports" of types when permuting a domain #58

rhinomode opened this issue Dec 18, 2020 · 0 comments

Comments

@rhinomode
Copy link

This is a request for an extension to the domain permutation functionality.

When permuting a domain, I would like to be able to narrow a type (with-exclude or with-include) differently depending on where I'm using it in my AST definition (domain). Currently I can narrow a sum-type's variants only at the global/top level. This prevents me from re-using sum-types in another domain in those cases where I want to allow distinct subset of variants in different places (variants) of my own.

Below is a little cooked up example of what I'd like to be able to do:

(define common_ops_ast
  (domain
    (sum core_expr
      (op_a param::symbol)
      (op_b param::symbol)
      (op_c param::symbol))
  ) // end domain
) // end define

(define reuse_ops_ast
  (permute common_ops_ast
    (with_alias core_expr_ops_ab
      (with core_expr    // <------------+-- 'with-alias' allows re-import
        (exclude op_c)))         //      |   of the same domain sum-types with
    (with_alias core_expr_ops_bc //      |   separate (narrowed) permutation
      (with core_expr    // <------------+   of variants
        (exclude op_a)))
    (sum node1
      (op1 expr::core_expr_ops_ab)) // <-- accepts only op_a & op_b from core_expr
    (sum node2
      (op2 expr::core_expr_ops_bc))  / <-- accepts only op_b & op_c from core_expr
  ) // end permute
) // end define

My motivation is specific to PartiQL and its AST; the partiql_ast domain currently has an expr sum-type that includes a ton of useful and handy "operators"/variant which I would like to re-use. I would like to re-use them because I do not want to diverge from the expressions in the expr of partiql_ast. I would like to narrow them as much as possible early on (and relax them later) because I want the PIRG domain I create (by permuting partiql_ast) to present to readers exactly what my backend is capable of (as opposed to me throwing run-time errors when I get something from expr that I haven't implemented or haven't figure out if I want to support).

Thanks,
Chuck

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

No branches or pull requests

1 participant