What is a valid name for a function?
Examples
-- works
let µ x = x * x
let ö x = x * x
-- doesn't work
let € x = x * x
let § x = x * x
I am not sure, but my hunch is that Haskell doesn't allow Unicode function names, does it? (Unicode like in http://www.cse.chalmers.se/~nad/listings/lib-0.4/Data.List.html)
A valid identifier can have letters (both uppercase and lowercase letters), digits and underscores. The first letter of an identifier should be either a letter or an underscore.
(->) is often called the "function arrow" or "function type constructor", and while it does have some special syntax, there's not that much special about it. It's essentially an infix type operator. Give it two types, and it gives you the type of functions between those types.
From the Haskell report:
Haskell uses the Unicode character set. However, source programs are currently biased toward the ASCII character set used in earlier versions of Haskell .
Recent versions of GHC seem to be fine with unicode (at least in the form of UTF-8):
Prelude> let пять=5; два=2; умножить=(*); на=id in пять `умножить` на два
10
(In case you wonder, «пять `умножить` на два» means «five `multiplied` by two» in Russian.)
Your examples do not work because those character are «symbols» and can be used in infix operators but not in function names. See "uniSymbol" category in the report.
Prelude> let x € y = x * y in 2 € 5
10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With