Haskell: How to use attoparsec in order to read a nested list from a ByteString

为君一笑 提交于 2019-12-01 11:05:15

The data seems to be in JSON format, so you can use Data.Aeson decode function which works on ByteString

import qualified Data.ByteString.Lazy as BL
import Data.Aeson
import Data.Maybe

main = do fContents <- BL.readFile filePath 
          let numList = decode fContents :: Maybe [[Int]]
          putStrLn (show $ fromJust numList)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!