My understanding is that if I use the json parser with parse on json data, I would get json types back. Unless,of course, the data is mal-formed. But then I would expect a failed parse.
This is all done in ghci.
>test <- (parseUrl "https://pkg.cudaops.com/cgi-bin/qaLinkEditor.cgi?json=1") :: (IO (Request IO))
>nManager <- newManager
>catch <- httpLbsRedirect test nManager
>let catchChunks = toChunks $ responseBody catch
>let flatChunks = Data.ByteString.concat catchChunks
>let parsed = parse json flatChunks
>:t parsed
>parsed :: Data.Attoparsec.Result Value
The result is rather large, Here’s part of the beginning of parsed that I wrote out to file
Done “\n” Object (fromList [(“name”,String “versions”),(“products”,Object (fromList [(“BCC Admin”,Object (fromList [(“available”,Array (fromList [String …”
How am I getting fromList? Where it says”Object (fromList [(“available”,Array… “, I expected “Object(Array [“available”,Array …” Am I misusing parse? Could I just be misunderstanding how parse works, it did what it was supposed to do and my expectations were wrong?
That’s just how arrays print. The convention is that
Showinstances should give valid Haskell code that recreates the value.