Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell 将文字字符转换为Word8_Haskell_Ghc_Bytestring - Fatal编程技术网

Haskell 将文字字符转换为Word8

Haskell 将文字字符转换为Word8,haskell,ghc,bytestring,Haskell,Ghc,Bytestring,的文档提供了以下代码示例: breakByte :: Word8 -> ByteString -> (ByteString, ByteString) breakByte 'c' "abcd" 但是,当我编写相同的代码时,会出现以下错误: 当然,'c'是一个Char,而不是Word8。大概他们正在使用某种扩展,允许fromInteger风格的函数自动处理Char文本,但我不确定是什么{-#语言重载字符串{-}似乎没有任何区别。只导入模块。它们进行字节转换。请注意,这适用于8位字符。所

的文档提供了以下代码示例:

breakByte :: Word8 -> ByteString -> (ByteString, ByteString)
breakByte 'c' "abcd"
但是,当我编写相同的代码时,会出现以下错误:

当然,
'c'
是一个
Char
,而不是
Word8
。大概他们正在使用某种扩展,允许
fromInteger
风格的函数自动处理
Char
文本,但我不确定是什么<代码>{-#语言重载字符串{-}似乎没有任何区别。

只导入模块。它们进行字节转换。请注意,这适用于8位字符。所以不要尝试将unicode数据放入其中。

只需导入模块即可。它们进行字节转换。请注意,这适用于8位字符。因此,不要尝试将unicode数据放入其中

Couldn't match expected type `GHC.Word.Word8'
            with actual type `Char'