Where Clauses

I can imagine uses for this where clause in programs other than just explicitly shadowing pattern variables which would otherwise be captured. Not only might we consider definitions in there, like Haskell, we might also consider other bits and pieces. Recall the thorny issue of

[Unparseable or potentially dangerous latex formula. Error 3 : 546x32]

This is a reasonable definition, but it doesn’t make a very good view. What happens? You get a nice case when they’re equal, but when they’re not, the context acquires a proof of difference but you don’t. We could now have


\AR{
\FN{f}\:\vx\:\vy\:\BY\:\RW{view}\:(\FN{eqDec}\:\vx\:\vy) \\
\quad\FN{f}\:\vx\:\vx\:\cq\:\cdots \\
\quad\FN{f}\:\vx\:\vy\:\cq\:\cdots \\
\quad\quad\RW{where}\;\vp\hab\vx\TC{=}\vy\To\TC{Zero}\\
}

Clearly, such an appeal to the context must be unambiguous, and here it is, because even if we had two proofs of the inequality, they’d be definitionally equal. This brings me back to wondering about a proof language for Epigram, where we invoke a proof (with an irrelevant value) by the proposition it proves, rather than by name. Propositional hypotheses could then be anonymous, and where clauses might be the way to make them explicit.

I think there’s an opportunity to do something very nice here, but I can’t tell what it is yet. I think we should think it out a bit more.

A bit more. Where clauses would give us an opportunity to define previously unheard of symbols showing up in right hand sides. Interactively, one might invoke an undefined function: the system could respond by opening a where clause with a template for its definition. Moreover, if the invocation constitutes a Miller pattern, the type of the local function can be plausibly inferred. As a piece of programming language syntax, this makes some sort of sense, but the question is what to call the local function globally, when it shows up in the normal form of a computation on open terms. I have some ideas about that, but their distinctly underdone.

One Response to “Where Clauses”

  1. Conor Says:

    Today’s vacillation is that we restrict where clauses in programs to shadows only, for the moment—this is likely to be upward compatible with whatever other uses we make of them. Implicit bindings which need protection can now be explicitly shadowed, so there’s no need for sombreros. Good: we should be able to write the parser and the scoper now.

Leave a Reply