| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Reflection utilities for Vector |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
module Data.Vec.Reflection where |
| 10 |
|
| 11 |
import Data.List.Base as List using (List; []) |
| 12 |
open import Data.Vec.Base as Vec using (Vec; _∷_; []) |
| 13 |
open import Reflection.AST.Term using (Term; def; con; _⋯⟅∷⟆_) |
| 14 |
open import Reflection.AST.Argument using (_⟨∷⟩_) |
| 15 |
|
| 16 |
------------------------------------------------------------------------ |
| 17 |
-- Type |
| 18 |
|
| 19 |
`Vector : Term → Term → Term |
| 20 |
`Vector `A `n = def (quote Vec) (1 ⋯⟅∷⟆ `A ⟨∷⟩ `n ⟨∷⟩ List.[]) |
| 21 |
|
| 22 |
------------------------------------------------------------------------ |
| 23 |
-- Constructors |
| 24 |
|
| 25 |
`[] : Term |
| 26 |
`[] = con (quote []) (2 ⋯⟅∷⟆ List.[]) |
| 27 |
|
| 28 |
infixr 5 _`∷_ |
| 29 |
|
| 30 |
_`∷_ : Term → Term → Term |
| 31 |
_`∷_ x xs = con (quote _∷_) (3 ⋯⟅∷⟆ x ⟨∷⟩ xs ⟨∷⟩ List.[]) |
| 32 |
|
| 33 |
------------------------------------------------------------------------ |
| 34 |
-- Patterns |
| 35 |
|
| 36 |
-- Can't be used on the RHS as the omitted args aren't inferable. |
| 37 |
|
| 38 |
pattern `[]` = con (quote []) (_ ∷ _ ∷ []) |
| 39 |
pattern _`∷`_ x xs = con (quote _∷_) (_ ∷ _ ∷ _ ∷ x ⟨∷⟩ xs ⟨∷⟩ _) |