【问题标题】:OverloadedStrings for chars [duplicate]字符的重载字符串[重复]
【发布时间】:2014-12-22 08:11:47
【问题描述】:

ByteString 的hackage 文档包含这个example

split :: Word8 -> ByteString -> [ByteString]
split '\n' "a\nb\nd\ne" == ["a","b","d","e"]

好像'\n' 被转换为Word8,但LANGUAGE OverloadedStrings 似乎只适用于字符串,而不适用于字符。我需要包含什么扩展才能使示例代码正常工作?

【问题讨论】:

  • 如果我尝试该示例,则会导致错误。 Couldn't match expected type 'Word8' with actual type 'Char' In the first argument of 'split', namely '\n'
  • 这可能会有所帮助:stackoverflow.com/questions/10623424/…

标签: haskell bytestring


【解决方案1】:

bytestring 支持一种廉价且欢快的 Latin1 字节视图。您可以导入 Data.ByteString.Char8 来获取该视图。

【讨论】:

    猜你喜欢
    • 2018-07-09
    • 2010-09-12
    • 1970-01-01
    • 1970-01-01
    • 2021-10-18
    • 1970-01-01
    • 2020-04-20
    相关资源
    最近更新 更多