gpt4 book ai didi

Haskell 源编码

转载 作者:行者123 更新时间:2023-12-03 15:03:21 25 4
gpt4 key购买 nike

Haskell 2010 语言报告说:

Haskell uses the Unicode [2] character set. However, source programs are currently biased toward the ASCII character set used in earlier versions of Haskell.


这是否意味着 UTF-8?

在 ghc-7.0.4/compiler/parser/Lexer.x.source 中:
$unispace    = \x05 -- Trick Alex into handling Unicode. See alexGetChar.
$whitechar = [\ \n\r\f\v $unispace]
$white_no_nl = $whitechar # \n
$tab = \t

$ascdigit = 0-9
$unidigit = \x03 -- Trick Alex into handling Unicode. See alexGetChar.
$decdigit = $ascdigit -- for now, should really be $digit (ToDo)
$digit = [$ascdigit $unidigit]

$special = [\(\)\,\;\[\]\`\{\}]
$ascsymbol = [\!\#\$\%\&\*\+\.\/\<\=\>\?\@\\\^\|\-\~]
$unisymbol = \x04 -- Trick Alex into handling Unicode. See alexGetChar.
$symbol = [$ascsymbol $unisymbol] # [$special \_\:\"\']

$unilarge = \x01 -- Trick Alex into handling Unicode. See alexGetChar.
$asclarge = [A-Z]
$large = [$asclarge $unilarge]

$unismall = \x02 -- Trick Alex into handling Unicode. See alexGetChar.
$ascsmall = [a-z]
$small = [$ascsmall $unismall \_]

$unigraphic = \x06 -- Trick Alex into handling Unicode. See alexGetChar.
$graphic = [$small $large $symbol $digit $special $unigraphic \:\"\']

...我不知道该怎么做。 alexGetChar真的没有帮助。

最佳答案

a proposal将 UTF-8 标准化为 Haskell 源文件的标准编码,但我不确定它是否被接受。

在实践中,GHC 假定所有输入文件都是 UTF-8,但它会忽略注释中格式错误的字节序列。

关于Haskell 源编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6797902/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com