I'm trying to do JSON parsing in IO:
{-# LANGUAGE OverloadedStrings #-}
import Network.HTTP.Simple
import Data.Aeson
import Data.Maybe (fromJust)
main :: IO ()
main = do
response <- getResponseBody <$> httpJSON "http://localhost:9200" :: IO Object
name <- fromJust <$> response .: "name" :: Parser String
print "hi"
I get the error:
/home/nut/dev/haskell/elastic/app/Main.hs:39:11: error:
• Couldn't match type ‘Parser’ with ‘IO’
Expected type: IO String
Actual type: Parser String
• In a stmt of a 'do' block:
So how do I get that name
out of the json result?