What characters are permitted for Haskell operators?

前端 未结 3 980
傲寒
傲寒 2020-11-30 20:56

Is there a complete list of allowed characters somewhere, or a rule that determines what can be used in an identifier vs an operator?

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-30 21:59

    What I was looking for was the complete list of characters. Based on the other answers, the full list is;

    Unicode Punctuation:

    • http://www.fileformat.info/info/unicode/category/Pc/list.htm
    • http://www.fileformat.info/info/unicode/category/Pd/list.htm
    • http://www.fileformat.info/info/unicode/category/Pe/list.htm
    • http://www.fileformat.info/info/unicode/category/Pf/list.htm
    • http://www.fileformat.info/info/unicode/category/Pi/list.htm
    • http://www.fileformat.info/info/unicode/category/Po/list.htm
    • http://www.fileformat.info/info/unicode/category/Ps/list.htm

    Unicode Symbols:

    • http://www.fileformat.info/info/unicode/category/Sc/list.htm
    • http://www.fileformat.info/info/unicode/category/Sk/list.htm
    • http://www.fileformat.info/info/unicode/category/Sm/list.htm
    • http://www.fileformat.info/info/unicode/category/So/list.htm

    But excluding the following characters with special meaning in Haskell:

    (),;[]`{}_:"'
    

    A : is only permitted as the first character of the operator, and denotes a constructor (see An operator symbol starting with a colon is a constructor).

提交回复
热议问题