On Wed, May 20, 2015 at 12:24 PM, Matt Oliveri <atma...@gmail.com> wrote:

> On Wed, May 20, 2015 at 1:44 PM, Jonathan S. Shapiro <s...@eros-os.org>
> wrote:
>
> > Last option, which I think does not really work, and cannot really be
> done
> > in F#, O'Caml, or Haskell, is to exploit the fact that a union leg type
> > actually *is* a type, and use parameterization. I don't have a way to
> > syntactically express this in these languages, but the general idea is
> that
> > the metadata node and the AST type would be mutually recursive types, and
> > the metadata node would be of the form MetaASTNode<LegType-or-group-type>
>
> I can't figure out what you're getting at here.
>
> Don't you just want something like:
>
> type Node<T> = MetaData * T
>
> type AST =
>   ...
> and Expr =
>   | MulExpr of Node<Expr> * Node<Expr>
>

More or less, yes. Though it's a bit curious here that Expr is considered a
type where MulExpr is not. One of the conclusions from BitC is that it's
actually useful to allow MulExpr to be a type that can be used and declared.

I confess that I don't fully understand the syntax you (and F#) are using
here. Are Expr and AST two independent type declarations that are
co-recursive, or is Expr a subtype of AST here? I'm not sure what this
syntax means, and I'd appreciate a quick explanation.

I think this approach is usefully carried a step further, such that MulExpr
is also a type, and we can then declare a Node<MulExpr>. For Expr there
aren't that many cases to match. For Type ASTs, on the other hand....


shap
_______________________________________________
bitc-dev mailing list
bitc-dev@coyotos.org
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to