Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Questionmark in function name

Tags:

haskell

I was just taking a look into clojure and found the following line of code on an example page

(filter even? [1 2 3])

While this is fairly standard code i am amazed by the fact, that they use a '?' to make the predicate easier to read.

Is it also possible to get haskell to accept this as a function name? So far i found https://wiki.haskell.org/Unicode-symbols which unfortunately does not contain '?'.

like image 426
Xlaech Avatar asked Nov 15 '25 20:11

Xlaech


1 Answers

Don't do this.

Gross hack: ? is not a valid identifier character, but ʔ is.

Don't use the following.

evenʔ :: Num a => a -> Bool
evenʔ 0 = True
evenʔ 1 = False
evenʔ n = evenʔ (n - 2)

(ʔ, of course, is U+0294 LATIN LETTER GLOTTAL STOP, which, appearances aside, is completely unrelated to U+003F QUESTION MARK.)

Did I mention you shouldn't do this?

like image 168
chepner Avatar answered Nov 17 '25 10:11

chepner