OK,
Here's another design problem I have with Typer: how to allow `let` to use patterns. Normally, this is handled with a rewrite such as
let p = e1 in e2 => case e1 | p => e2
but our `let` is defined as
let <decls> in <e>
where <decls> is a bunch of declarations, some of them mutually recursive, some of them declaration-macros.
Ideally, I'd want the "<p> = <e>" declaration to be rewritten into some other set of declarations (by a declaration-macro). That could work when <p> is a kind of tuple:
(a, b) = e => t = e1; a = t.0; b = t.1
But for the more general case of non-tuple patterns it's more problematic. My best solution currently is something like
<p> = <e> => t = case <e> | <p> => (x1, x2, x3, ...); x1 = t.0; x2 = t.1; ...
Of course, this can't work for now for two reasons: - we don't have field selectors like ".1". - the "=" declaration is hard-coded so we can't extend/redefine it with a macro.
Stefan