[Agda] A feature request: typed pattern synonyms.

Andreas Abel andreas.abel at ifi.lmu.de
Wed Jun 29 16:08:32 CEST 2016


Filed as

   https://github.com/agda/agda/issues/2069

where we should continue the discussion.

On 18.06.2016 12:18, Roman wrote:
> Hi, I'm doing some generic programming and defining lots of pattern
> synonyms, but they are not equivalent to constructors due to their
> untyped nature. E.g. I have
>
>      pattern _∷_ x xs = cons₁ (x , xs , lrefl)
>
> Clearly, Agda can't infer that `_∷_` has type `∀ {α} {A : Set α} -> A
> -> List A -> List A`, so the inferred type of `2 ∷ []` is `μ (_Ds_57 x
> xs) (_j_58 x xs)` instead of `List ℕ`, i.e. completely unspecified. It
> means that I need both a pattern `_∷_` and an operator
>
>      _∷′_ : ∀ {α} {A : Set α} -> A -> List A -> List A
>      _∷′_ = _∷_
>
> to use on the RHS. It's rather inconvenient to have a pattern and a
> function instead of just one constructor, especially in my case as I
> want to figure out whether it's possible to type check existing code
> after changing data definitions to their generic counterparts.
>
> Ideally, I would like to write
>
>      pattern
>        _∷_ : ∀ {α} {A : Set α} -> A -> List A -> List A
>        x ∷ xs = cons₁ (x , xs , lrefl)
>
> Is it possible to implement such a feature? Or maybe something else
> that would allow to use pattern synonyms as genuine constructors?


-- 
Andreas Abel  <><      Du bist der geliebte Mensch.

Department of Computer Science and Engineering
Chalmers and Gothenburg University, Sweden

andreas.abel at gu.se
http://www2.tcs.ifi.lmu.de/~abel/


More information about the Agda mailing list