I’m trying to use HTTP Conduit and it’s really good but now I’m trapped on how to get if the response is OK or if it has an error using the
Normally that is done with a case of using
Left and Right but this is wrapped on a
Response that I don’t know how to extract.
module Main where import Data.Aeson ( Value ) import Network.HTTP.Simple ( httpJSONEither, Response, JSONException ) main :: IO () main = do response <- httpJSONEither "http://httpbin.org/get" :: IO (Response (Either JSONException Value)) case response of r -> print r
So instead of just
r, what match cases are required for the
Response Either ?
The type of the response and source code can be found at https://hackage.haskell.org/package/http-conduit-2.3.8/docs/Network-HTTP-Simple.html#v:httpJSONEither
Please find a cabal repo at https://github.com/csaltos/hello-conduit for easy reproducing this.