23026

What's wrong with this Haskell unicode variable name?

Question:

What's wrong this this code?

Prelude> let xᵀ = "abc" <interactive>:10:6: lexical error at character '\7488'

According to my reading of the <a href="http://www.haskell.org/onlinereport/haskell2010/haskellch2.html#x7-180002.4" rel="nofollow">Haskell 2010 report</a>, any uppercase or lowercase Unicode letter should be valid at the end of a variable name. Does the character (<a href="http://www.fileformat.info/info/unicode/char/1d40/index.htm" rel="nofollow">MODIFIER LETTER CAPITAL T</a>) 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.

Answer1:

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.

Answer2:

<blockquote>

Characters not in the category ANY are not valid in Haskell programs and should result in a lexing error.

</blockquote>

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 <em>numbers</em> – which are in the <a href="http://www.fileformat.info/info/unicode/category/No/list.htm" rel="nofollow">Number, Other category</a> 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.

Recommend

  • Adding Reference Line for Weighted Average in Tableau
  • Create a saved search (.search-ms) from terms in Explorer search box
  • How to pass the value of a form select input to a php file using AJAX without submitting it?
  • Getting “node stack overflow” when cbind multiple sparse matrices
  • Rank by two columns and keep ties
  • Scikit-learn (sklearn) PCA throws Type Error on sparse matrix
  • Are Java Spring services evil as they are singleton? [closed]
  • simplexml and accessing feedburner's : [duplicate]
  • EWS SearchFilter.ContainsSubstring to filter on Sender Email Address
  • How to achieve a private branch in git that “floats” when merging with upstream?
  • Function Overloading for the standard library functions in C++
  • Convert a list with non-fixed length elements to tensor
  • Use shared WKWebViewCookies for a request
  • karma-browserify throws error when trying to load modules shimmed with browserify-shim
  • Multiply two data frames with similar index in python pandas
  • How can the java 'class' literal return different instances of the Class object for the sa
  • Grails Packaging and Naming Conventions
  • In BASH convert a string with . in float
  • check if numbers have the same sign
  • Constant embedded for loop condition optimization in C++ with gcc
  • Multiprocessing in Python: how to implement a loop over “apply_async” as “map_async” using a callbac
  • How to prompt user that edits have been made upon changing pages or sorting in Kendo Grid
  • substitute period from abbreviation (single letter + period) unless followed by a capital letter
  • Quickly or concisely determine the longest string per column in a row-based data collection
  • Concise regex extract function in XSLT 2.0
  • How to distribute an event to all nodes in a (Wildfly) cluster?
  • Add spaces between words in spaceless string
  • Messed up characters in webpages (especially social media)
  • Is there a way to link a linux's thread TID and a pthread_t “thread ID”
  • runtime-check whether an instance (Base*) override a parent function (Base::f())
  • IE6 changes DOCTYPE to a bad one
  • Is there a package like bigmemory in R that can deal with large list objects?
  • How to determine if there are bytes available to be read from boost:asio:serial_port
  • Android full screen on only one activity?
  • Initializer list vs. initialization method
  • VBA Convert delimiter text file to Excel
  • Return words with double consecutive letters
  • Transpose CSV data with awk (pivot transformation)
  • Comma separated Values
  • Binding checkboxes to object values in AngularJs