| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Basic definitions for Characters |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
module Data.Char.Base where |
| 10 |
|
| 11 |
import Data.Nat.Base as ℕ using (_<_; _≡ᵇ_) |
| 12 |
open import Data.Bool.Base using (Bool) |
| 13 |
open import Function.Base using (_on_) |
| 14 |
open import Level using (zero) |
| 15 |
open import Relation.Binary.Core using (Rel) |
| 16 |
open import Relation.Binary.PropositionalEquality.Core using (_≡_; _≢_) |
| 17 |
open import Relation.Binary.Construct.Closure.Reflexive using (ReflClosure) |
| 18 |
|
| 19 |
------------------------------------------------------------------------ |
| 20 |
-- Re-export the type, and renamed primitives |
| 21 |
|
| 22 |
open import Agda.Builtin.Char public using ( Char ) |
| 23 |
renaming |
| 24 |
-- testing |
| 25 |
( primIsLower to isLower |
| 26 |
; primIsDigit to isDigit |
| 27 |
; primIsAlpha to isAlpha |
| 28 |
; primIsSpace to isSpace |
| 29 |
; primIsAscii to isAscii |
| 30 |
; primIsLatin1 to isLatin1 |
| 31 |
; primIsPrint to isPrint |
| 32 |
; primIsHexDigit to isHexDigit |
| 33 |
-- transforming |
| 34 |
; primToUpper to toUpper |
| 35 |
; primToLower to toLower |
| 36 |
-- converting |
| 37 |
; primCharToNat to toℕ |
| 38 |
; primNatToChar to fromℕ |
| 39 |
) |
| 40 |
|
| 41 |
open import Agda.Builtin.String public using () |
| 42 |
renaming ( primShowChar to show ) |
| 43 |
|
| 44 |
infix 4 _≈_ _≉_ |
| 45 |
_≈_ : Rel Char zero |
| 46 |
_≈_ = _≡_ on toℕ |
| 47 |
|
| 48 |
_≉_ : Rel Char zero |
| 49 |
_≉_ = _≢_ on toℕ |
| 50 |
|
| 51 |
infix 4 _≈ᵇ_ |
| 52 |
_≈ᵇ_ : (c d : Char) → Bool |
| 53 |
c ≈ᵇ d = toℕ c ℕ.≡ᵇ toℕ d |
| 54 |
|
| 55 |
infix 4 _<_ |
| 56 |
_<_ : Rel Char zero |
| 57 |
_<_ = ℕ._<_ on toℕ |
| 58 |
|
| 59 |
infix 4 _≤_ |
| 60 |
_≤_ : Rel Char zero |
| 61 |
_≤_ = ReflClosure _<_ |