I'm using Aeson
and Network.HTTP
. I was able to encode a json and print it on the screen doing the following:
getCode :: String -> IO ResponseCode
getCode url = simpleHTTP req >>= getResponseCode
where req = getRequest url
main :: IO ()
main = do
x <- get "http://jsonplaceholder.typicode.com/todos/1"
let y = encode x
B.putStrLn y
However I do not understand what this do
expression desugars to. Something like this:
get "http://jsonplaceholder.typicode.com/todos/1" >>= (?)
what should be in the ?
?
I only know how to desugar this:
do { x1 <- action1
; x2 <- action2
; mk_action3 x1 x2 }
to this
action1 >>= (\ x1 -> action2 >>= (\ x2 -> mk_action3 x1 x2 ))
bu the way, what is an action
? https://en.m.wikibooks.org/wiki/Haskell/do_notation does not explain very precisely.
get "http://jsonplaceholder.typicode.com/todos/1" >>= (\x -> let y = encode x in B.putStrLn y)