Debian Codegraph @

src/Reflection/AST/Name.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Names used in the reflection machinery
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 module Reflection.AST.Name where
10
11 open import Data.List.Base using (List)
12 import Data.Product.Properties as Prodₚ using (≡-dec)
13 import Data.Word64.Properties as Wₚ using (_≟_)
14 open import Function.Base using (_on_)
15 open import Relation.Nullary.Decidable.Core using (map′)
16 open import Relation.Binary.Core using (Rel)
17 open import Relation.Binary.Definitions using (Decidable; DecidableEquality)
18 open import Relation.Binary.Construct.On using (decidable)
19 open import Relation.Binary.PropositionalEquality.Core using (_≡_; cong)
20
21 ------------------------------------------------------------------------
22 -- Re-export built-ins
23
24 open import Agda.Builtin.Reflection public
25 using (Name) renaming (primQNameToWord64s to toWords; primQNameEquality to _≡ᵇ_)
26
27 open import Agda.Builtin.Reflection.Properties public
28 renaming (primQNameToWord64sInjective to toWords-injective)
29
30 ------------------------------------------------------------------------
31 -- More definitions
32 ------------------------------------------------------------------------
33
34 Names : Set
35 Names = List Name
36
37 ------------------------------------------------------------------------
38 -- Decidable equality for names
39 ------------------------------------------------------------------------
40
41 infix 4 _≈?_ _≟_ _≈_
42
43 _≈_ : Rel Name _
44 _≈_ = _≡_ on toWords
45
46 _≈?_ : Decidable _≈_
47 _≈?_ = decidable toWords _≡_ (Prodₚ.≡-dec Wₚ._≟_ Wₚ._≟_)
48
49 _≟_ : DecidableEquality Name
50 m ≟ n = map′ (toWords-injective _ _) (cong toWords) (m ≈? n)