Reputation: 6571
What's wrong this this code?
Prelude> let xᵀ = "abc"
<interactive>:10:6: lexical error at character '\7488'
According to my reading of the Haskell 2010 report, any uppercase or lowercase Unicode letter should be valid at the end of a variable name. Does the ᵀ
character (MODIFIER LETTER CAPITAL T) not qualify as an uppercase Unicode letter?
Is there a better character to represent the transpose of a vector? I'd like to stay concise since I'm evaluating a dense mathematical formula.
I'm running GHC 7.8.3.
Upvotes: 6
Views: 743
Reputation: 120741
Characters not in the category ANY are not valid in Haskell programs and should result in a lexing error.
where
ANY → graphic | whitechar
graphic → small | large | symbol | digit | special | " | '
small → ascSmall | uniSmall | _<br>
ascSmall → a | b | … | z<br>
uniSmall → any Unicode lowercase letter
...
uniDigit → any Unicode decimal digit
...
Modifier letters like ᵀ
are not legal Haskell at all. (Unlike sub- or superscript numbers – which are in the Number, Other category so a₁
is treated much like a1
.)
I like to use non-ASCII Unicode when it helps readability, but unless you've already assigned another meaning to the prime symbol using it here for transpose should be just fine.
Upvotes: 8
Reputation: 3202
Uppercase Unicode letters are in the Unicode character category Letter, Uppercase [Lu].
Lowercase Unicode letters are in the Unicode character category Letter, Lowercase [Ll].
MODIFIER LETTER CAPITAL T is in the Unicode character category Letter, Modifier [Lm].
I tend to stick to ASCII, so I'd probably just use a name like xTrans
or x'
, depending on the number of lines it is in scope.
Upvotes: 8