on master help sign in
Minimal Enum instance for Char
commite8983e7956df94afe12dc8d5a9173ae6565d4ba6 authorGabriel Garcia <garciat@live.com> dateWed 25 Nov 2015, 10:09 (11 years ago) parent140d06a
1 file changed+6
libs/prelude/Prelude.idr+6
libs/prelude/Prelude.idr+6
@@ -203,6 +203,12 @@ instance Enum Int where
203203 go [] = []
204204 go (x :: xs) = n + (cast x * inc) :: go xs
205205
206+instance Enum Char where
207+ toNat c = toNat (ord c)
208+ fromNat n = chr (fromNat n)
209+
210+ pred c = fromNat (pred (toNat c))
211+
206212syntax "[" [start] ".." [end] "]"
207213 = enumFromTo start end
208214syntax "[" [start] "," [next] ".." [end] "]"