Debian Codegraph @

src/Data/List/Reflection.agda

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