Coq-Equations icon indicating copy to clipboard operation
Coq-Equations copied to clipboard

Is there support for Haskell-like "as-patterns"?

Open anton-trunov opened this issue 3 years ago • 2 comments

Sorry if I missed this in the docs, but is there support for Haskell-like "as-patterns"? I.e. something like

Equations foo s :=
  foo [] := ...
  foo s@(x :: s') := ... (* s is in scope here *) ...

anton-trunov avatar May 13 '21 11:05 anton-trunov

While match has such a feature, it does not seem to be recognized by Equations.

Program Fixpoint base_fix (a : N) {measure a lt} : N :=
  match a with
  | N0 => 0
  | Npos _ as n =>
    let p := pred n in
    Npos (stride p) + base_fix p
  end.
Fail Equations base_fix (a : N) : N by wf a lt :=
  base_fix N0 := 0;
  base_fix (Npos _ as n) :=
    let p := pred n in
    Npos (stride p) + base_fix p.

Tuplanolla avatar May 14 '21 10:05 Tuplanolla

Yep, that's not supported yet. As the patterns are actual terms this poses a syntax issue, I need to find a way to parse as x as part of terms.

mattam82 avatar May 26 '21 10:05 mattam82