Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Haskell cognates of builtin Agda Char functions in Data.Char #299

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions lib/Haskell/Data/Char.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module Haskell.Data.Char where

open import Agda.Builtin.Char
open import Agda.Builtin.Bool
open import Agda.Builtin.Nat
open import Agda.Builtin.Int using (pos)
open import Haskell.Prim.Int
open import Haskell.Prim using (_∘_; eqNat)

-- Translating builtin, postulated Agda functions
-- to Haskell functions in Data.Char.

isLower isDigit isAlpha isSpace isAscii
isLatin1 isPrint isHexDigit : Char → Bool
isLower = primIsLower
isDigit = primIsDigit
isAlpha = primIsAlpha
isSpace = primIsSpace
isAscii = primIsAscii
isLatin1 = primIsLatin1
isPrint = primIsPrint
isHexDigit = primIsHexDigit
toUpper toLower : Char → Char
toUpper = primToUpper
toLower = primToLower
ord : Char → Int
ord = (integerToInt ∘ pos) ∘ primCharToNat
chr : Int → Char
chr = primNatToChar ∘ unsafeIntToNat
Loading