Skip to content

Commit 7f7bd7b

Browse files
committed
Merge pull request #11 from jdegoes/ready/char-instances
added essential instances for Char; fully backward compatible
2 parents 976d330 + 2a044ec commit 7f7bd7b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
newtype Char
88

99

10+
### Type Class Instances
11+
12+
instance eqChar :: Eq Char
13+
14+
instance ordChar :: Ord Char
15+
16+
instance showChar :: Show Char
17+
18+
1019
### Values
1120

1221
charString :: Char -> String

src/Data/Char/Char.purs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,13 @@ module Data.Char
2020
\ return String.fromCharCode(c);\
2121
\}" :: Number -> Char
2222

23+
instance eqChar :: Eq Char where
24+
(==) (Char a) (Char b) = a == b
25+
26+
(/=) a b = not (a == b)
27+
28+
instance ordChar :: Ord Char where
29+
compare (Char a) (Char b) = a `compare` b
30+
31+
instance showChar :: Show Char where
32+
show (Char s) = "Char " ++ show s

0 commit comments

Comments
 (0)