在哪里指定是否允许在Haskell实现中使用Unicode标识符? [英] Where is it specified whether Unicode identifiers should be allowed in a Haskell implementation?

查看:112
本文介绍了在哪里指定是否允许在Haskell实现中使用Unicode标识符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用标识符中的Unicode字符(非拉丁字母)在Haskell中编写一些教育代码。 (所以标识符对于非英文自然语言的演讲者来说看起来很好,很自然,因为在写作时没有使用拉丁文字符)。所以,我着手寻找一个合适的Haskell实现来实现这一点。



但是语言规范中指定的这个特性在哪里?在寻找合适的实现时,我将如何引用此功能? (Haskell实现已知实际上支持Unicode标识符?)

事实证明,一个Haskell实现确实接受了带有Unicode标识符的我的代码,而另一个Haskell实现没有接受它。如果有一种方法可以将我的代码的这种需求正式化,我可能会希望它以语言功能开关的形式出现,这样,如果我或其他人试图运行我的代码,立刻就会清楚他的实现是否缺失所需的功能,因此他应该寻找另一个。 (这个功能也可能有一个维基页面 - Unicode标识符,它将列出哪些现有的实现支持它,这样人们就会知道如果需要的话,应该去哪里。)



(顺便说一下,我已经在这个问题上加了一个语法标签,但我实际上认为它是一个lexing级别的问题,比语言的语法级别要低。一个标签在这里是针对一种语言的lexing级别的特征,而不是针对一种语言的语法规范的特征?)

解决方案

在线报告记录在词位。它还很早就注意到Haskell使用Unicode字符集,但是源程序目前偏向于早期版本的Haskell中使用的ASCII字符集。。

实际的编译器可能支持也可能不支持Unicode标识符。 GHC会这样做,但需要注意的是,Unicode代码点必须遵循与ASCII字符相同的规则:类型必须以大写或标题类型的代码点开头,变量为小写字母(尽管事实上,这可以放宽为字母而不是大写/标题;这可能值得向语言委员会澄清),操作员必须是标点或符号。 (这意味着你不能用阿拉伯语声明类型,例如,除非你在其他一些大写/标题的脚本中用一个字符作为前缀)。

As收集Unicode支持信息:虽然我不知道提供它的单个页面,但搜索unicode 关于 Haskell Wiki 在许多Haskell编译器中查找有关Unicode支持的信息。


I wanted to write some educational code in Haskell with Unicode characters (non-Latin) in the identifiers. (So that the identifiers look nice and natural for speakers of a natural language other than English which is not using the Latin characters in its writing.) So, I set out for finding an appropriate Haskell implementation that would allow this.

But where is this feature specified in the language specification? How would I refer to this feature when looking for a conforming implementation? (And which Haskell implemenations are known to actually support Unicode identifiers?)

It turned out that one Haskell implementation did accept my code with Unicode identifiers, whereas another one failed to accept it. I would like it if there were a way to formalize this requirement of my code, in a form of a language feature switch perhaps, so that if I or someone else tries to run my code, it would be immediately clear whether his implementation is missing the required feature and hence he should look for another one. (There could be also a wiki page for this feature--"Unicode identifiers", which would list which of the existing implementations support it, so that one would know where to go if one needs it.)

(BTW, I have put a "syntax" tag on this question, but I actually perceive it to be an issue of the level of lexing, a lower level than the syntax of a language. Is there a tag here for features of the lexing level of a language, rather than for features of the syntax specification of a language?)

解决方案

The Online Report documents this under Lexemes. It also notes early on that "Haskell uses the Unicode character set. However, source programs are currently biased toward the ASCII character set used in earlier versions of Haskell.".

Actual compilers may or may not support Unicode identifiers. GHC does, but you need to keep in mind that Unicode codepoints must obey the same rules as ASCII characters: types must start with a codepoint which is classed as uppercase or titlecase, variables as lowercase (although de facto this is relaxed to alphabetic and not uppercase/titlecase; this might be worth asking for a clarification from the language committee), operators must be punctuation or symbol. (This means that you can't declare types in Arabic, for example, unless you prefix them with a character in some other script that is uppercase/titlecase.)

As to collecting Unicode support information: while I don't know of a single page that provides it, searching for "unicode" on the Haskell Wiki finds information about Unicode support in a number of Haskell compilers.

这篇关于在哪里指定是否允许在Haskell实现中使用Unicode标识符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆