Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.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/9/blackberry/2.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
直接从Aeson encode输出将JSON作为lazy ByteString写入文件,而不转换为字符串_Json_Haskell_Aeson_Lazy Io - Fatal编程技术网

直接从Aeson encode输出将JSON作为lazy ByteString写入文件,而不转换为字符串

直接从Aeson encode输出将JSON作为lazy ByteString写入文件,而不转换为字符串,json,haskell,aeson,lazy-io,Json,Haskell,Aeson,Lazy Io,目前,我正在使用类似的方法将JSON内容(my_JSON)写入一个文件(my_output\u filepath): 这是可行的,但我想知道是否有必要在将(encodePretty)返回的ByteString转换为字符串,然后再将其写入文件,或者是否会导致性能损失 我看到一个writeFile,它接受一个ByteString作为输入。但是,当我尝试使用它时,会出现以下错误: Couldn't match expected type ‘B.ByteString’ with

目前,我正在使用类似的方法将JSON内容(
my_JSON
)写入一个文件(
my_output\u filepath
):

这是可行的,但我想知道是否有必要在将(
encodePretty
)返回的
ByteString
转换为
字符串
,然后再将其写入文件,或者是否会导致性能损失

我看到一个
writeFile
,它接受一个
ByteString
作为输入。但是,当我尝试使用它时,会出现以下错误:

Couldn't match expected type ‘B.ByteString’
            with actual type ‘U.ByteString’
NB: ‘B.ByteString’ is defined in ‘Data.ByteString.Internal’
    ‘U.ByteString’ is defined in ‘Data.ByteString.Lazy.Internal’

有没有办法让
Lazy
变体通过testring
writeFile
进行互操作?

能否请您发布导致错误的部分源代码?我看不出strict bytestring从何而来,
encodePretty
数据返回lazy bytestring和
writeFile
。bytestring.lazy
也需要lazy bytestring。可能是您正在从strict bytestring模块
Data.bytestring
导入
writeFile吗?确保你确实在使用你链接到的懒惰者。这还不够吗@WillSewell你是对的。哦,你能不能把你的源代码中导致错误的部分贴出来?我看不出strict bytestring从何而来,
encodePretty
数据返回lazy bytestring和
writeFile
。bytestring.lazy
也需要lazy bytestring。可能是您正在从strict bytestring模块
Data.bytestring
导入
writeFile吗?确保你确实在使用你链接到的懒惰者。这还不够吗@WillSewell你是对的。哦。
Couldn't match expected type ‘B.ByteString’
            with actual type ‘U.ByteString’
NB: ‘B.ByteString’ is defined in ‘Data.ByteString.Internal’
    ‘U.ByteString’ is defined in ‘Data.ByteString.Lazy.Internal’