Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Char have an instance for Bounded?

Tags:

haskell

Why is there a maxBound of Char? If Char is character then why it is explained by numbers, and if it is not a number what does it mean?

> maxBound :: Char
'\1114111'
like image 921
user2999428 Avatar asked Nov 16 '13 16:11

user2999428


1 Answers

All characters, like all things in a computer, are ultimately just numbers. Char represents unicode characters, which are represented via numbers. You can convert between Char and Int values with ord and chr. E.g. the unicode value for a is 97, so ord 'a' is 97 and chr 97 is 'a'.

Char '\1114111' is the Char that represents the number 1114111, or 0x10FFFF, which is defined as a noncharacter. This is the largest value that is defined in Unicode, and is the largest that Haskell supports: '\1114112' will cause a compile error.

like image 191
Tim S. Avatar answered Sep 28 '22 03:09

Tim S.