Operators using CHAR
Keywords: pame

#
Operators using `CHAR`

This chapter has been rather heavy on arithmetic up to now. You might wonder whether operators can have operands of mode `CHAR`. The answer is yes. Indeed, the `+` and `*` operators are so declared, and we shall meet them in chapter 3. There are two monadic operators which involve the mode `CHAR`. The operator `ABS` (which we have already met) can take a `CHAR` operand and yields the integer corresponding to that character. For example, `ABS "A"` yields `65` (the number associated with the letter `"A"` as defined by the ASCII standard). The identifier `max abs char` is declared in the standard prelude with the value `255`. Conversely, we can convert an integer to a character using the monadic operator `REPR`. The formula

       REPR 65

yields the value `"A"`. `REPR` can act on any integer in the range `0` to `max abs char`. `REPR` is of particular value in allowing access to control characters. For example, the tab character is declared in the standard prelude as `tab ch`. Consult section 13.2.2 for the details.