| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Literals used in the reflection machinery |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
module Reflection.AST.Literal where |
| 10 |
|
| 11 |
open import Data.Bool.Base using (Bool; true; false) |
| 12 |
import Data.Char.Properties as Char |
| 13 |
import Data.Float.Properties as Float |
| 14 |
import Data.Nat.Properties as ℕ |
| 15 |
import Data.String.Properties as String |
| 16 |
import Data.Word64.Properties as Word64 |
| 17 |
import Reflection.AST.Meta as Meta |
| 18 |
import Reflection.AST.Name as Name |
| 19 |
open import Relation.Nullary.Decidable.Core using (yes; no; map′; isYes) |
| 20 |
open import Relation.Binary.Definitions using (DecidableEquality) |
| 21 |
open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl; cong) |
| 22 |
|
| 23 |
------------------------------------------------------------------------ |
| 24 |
-- Re-exporting the builtin type and constructors |
| 25 |
|
| 26 |
open import Agda.Builtin.Reflection public |
| 27 |
using ( Literal ) |
| 28 |
open Literal public |
| 29 |
|
| 30 |
------------------------------------------------------------------------ |
| 31 |
-- Decidable equality |
| 32 |
|
| 33 |
meta-injective : ∀ {x y} → meta x ≡ meta y → x ≡ y |
| 34 |
meta-injective refl = refl |
| 35 |
|
| 36 |
nat-injective : ∀ {x y} → nat x ≡ nat y → x ≡ y |
| 37 |
nat-injective refl = refl |
| 38 |
|
| 39 |
word64-injective : ∀ {x y} → word64 x ≡ word64 y → x ≡ y |
| 40 |
word64-injective refl = refl |
| 41 |
|
| 42 |
float-injective : ∀ {x y} → float x ≡ float y → x ≡ y |
| 43 |
float-injective refl = refl |
| 44 |
|
| 45 |
char-injective : ∀ {x y} → char x ≡ char y → x ≡ y |
| 46 |
char-injective refl = refl |
| 47 |
|
| 48 |
string-injective : ∀ {x y} → string x ≡ string y → x ≡ y |
| 49 |
string-injective refl = refl |
| 50 |
|
| 51 |
name-injective : ∀ {x y} → name x ≡ name y → x ≡ y |
| 52 |
name-injective refl = refl |
| 53 |
|
| 54 |
infix 4 _≟_ |
| 55 |
_≟_ : DecidableEquality Literal |
| 56 |
nat x ≟ nat x₁ = map′ (cong nat) nat-injective (x ℕ.≟ x₁) |
| 57 |
nat x ≟ word64 x₁ = no (λ ()) |
| 58 |
nat x ≟ float x₁ = no (λ ()) |
| 59 |
nat x ≟ char x₁ = no (λ ()) |
| 60 |
nat x ≟ string x₁ = no (λ ()) |
| 61 |
nat x ≟ name x₁ = no (λ ()) |
| 62 |
nat x ≟ meta x₁ = no (λ ()) |
| 63 |
word64 x ≟ word64 x₁ = map′ (cong word64) word64-injective (x Word64.≟ x₁) |
| 64 |
word64 x ≟ nat x₁ = no (λ ()) |
| 65 |
word64 x ≟ float x₁ = no (λ ()) |
| 66 |
word64 x ≟ char x₁ = no (λ ()) |
| 67 |
word64 x ≟ string x₁ = no (λ ()) |
| 68 |
word64 x ≟ name x₁ = no (λ ()) |
| 69 |
word64 x ≟ meta x₁ = no (λ ()) |
| 70 |
float x ≟ nat x₁ = no (λ ()) |
| 71 |
float x ≟ word64 x₁ = no (λ ()) |
| 72 |
float x ≟ float x₁ = map′ (cong float) float-injective (x Float.≟ x₁) |
| 73 |
float x ≟ char x₁ = no (λ ()) |
| 74 |
float x ≟ string x₁ = no (λ ()) |
| 75 |
float x ≟ name x₁ = no (λ ()) |
| 76 |
float x ≟ meta x₁ = no (λ ()) |
| 77 |
char x ≟ nat x₁ = no (λ ()) |
| 78 |
char x ≟ word64 x₁ = no (λ ()) |
| 79 |
char x ≟ float x₁ = no (λ ()) |
| 80 |
char x ≟ char x₁ = map′ (cong char) char-injective (x Char.≟ x₁) |
| 81 |
char x ≟ string x₁ = no (λ ()) |
| 82 |
char x ≟ name x₁ = no (λ ()) |
| 83 |
char x ≟ meta x₁ = no (λ ()) |
| 84 |
string x ≟ nat x₁ = no (λ ()) |
| 85 |
string x ≟ word64 x₁ = no (λ ()) |
| 86 |
string x ≟ float x₁ = no (λ ()) |
| 87 |
string x ≟ char x₁ = no (λ ()) |
| 88 |
string x ≟ string x₁ = map′ (cong string) string-injective (x String.≟ x₁) |
| 89 |
string x ≟ name x₁ = no (λ ()) |
| 90 |
string x ≟ meta x₁ = no (λ ()) |
| 91 |
name x ≟ nat x₁ = no (λ ()) |
| 92 |
name x ≟ word64 x₁ = no (λ ()) |
| 93 |
name x ≟ float x₁ = no (λ ()) |
| 94 |
name x ≟ char x₁ = no (λ ()) |
| 95 |
name x ≟ string x₁ = no (λ ()) |
| 96 |
name x ≟ name x₁ = map′ (cong name) name-injective (x Name.≟ x₁) |
| 97 |
name x ≟ meta x₁ = no (λ ()) |
| 98 |
meta x ≟ nat x₁ = no (λ ()) |
| 99 |
meta x ≟ word64 x₁ = no (λ ()) |
| 100 |
meta x ≟ float x₁ = no (λ ()) |
| 101 |
meta x ≟ char x₁ = no (λ ()) |
| 102 |
meta x ≟ string x₁ = no (λ ()) |
| 103 |
meta x ≟ name x₁ = no (λ ()) |
| 104 |
meta x ≟ meta x₁ = map′ (cong meta) meta-injective (x Meta.≟ x₁) |
| 105 |
|
| 106 |
infix 4 _≡ᵇ_ |
| 107 |
|
| 108 |
_≡ᵇ_ : Literal → Literal → Bool |
| 109 |
l ≡ᵇ l′ = isYes (l ≟ l′) |