What characters are permitted for Haskell operators?

前端 未结 3 988
傲寒
傲寒 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:36

    From the Haskell 2010 Report §2.4:

    Operator symbols are formed from one or more symbol characters...

    §2.2 defines symbol characters as being any of !#$%&*+./<=>?@\^|-~: or "any [non-ascii] Unicode symbol or punctuation".

    NOTE: User-defined operators cannot begin with a : as, quoting the language report, "An operator symbol starting with a colon is a constructor."

提交回复
热议问题