character literal question

Twan van Laarhoven twanvl at gmail.com
Fri Dec 1 17:19:14 EST 2006


Iavor Diatchki wrote:
> Hello,
> Is there a reason why we have to escape the character ' (apostrophe)
> when used in a character literal?  For example, we have to write '\''
> instead of '''.  (With syntax highlighting, the second is a lot better
> looking than the first.)  It seems that in this case we do not need
> the escape because a literal contains exactly one character.  If there
> is no good reason for having the scape, I think that we should remove
> this restriction in Haskell'.
> -Iavor

If you really want you can also allow an unescapped backslash, '\'. The 
rules for parsing character literals would become something like:
  case input of
   '''   -> a single quote
   '\''  -> a single quote
   '\'   -> a backslash
   '\..' -> an escape
   'a'   -> a normal character

I'm not saying this is a good idea, just that it is possible. :)

Twan


More information about the Haskell-prime mailing list