Reputation: 544
I'm trying to use the Aeson JSON library in haskell. Right now, i just need to use "decode" to read a JSON dump.
import Data.Aeson
import Data.ByteString as BS
import Control.Applicative
main :: IO ()
main = print $ decode <$> BS.readFile "json"
I got the following error when trying to compile/run it:
Couldn't match type 'ByteString'
with 'Data.ByteString.Lazy.Internal.ByteString'
NB: 'ByteString is defined in 'Data.ByteString.Internal'
'Data.ByteString.Lazy.Internal.ByteString'
is defined in 'Data.ByteString.Lazy.Internal.ByteString
This error doesn't make sense to me. I tried importing the files described by ghc, but the import either fails or doesn't solve the problem. Thanks
Upvotes: 1
Views: 68
Reputation: 25782
There are two variants of ByteString
: A strict (the default one), exported by Data.ByteString
, and a lazy one, exported by Data.ByteString.Lazy
.
Aeson works on top of lazy byte string, so you should change your second line to
import Data.ByteString.Lazy as BS
Upvotes: 2