Reputation: 3334
post "/introduceAnIdea" $ do
command <- jsonData
json $ handle command
How would you remove the do and change it with >>= ?
Upvotes: 3
Views: 139
Reputation: 11923
Here's how to rewrite do
-notation as >>=
and >>
: (NB: a newline becomes ;
in the c-like notation option, which I use here.)
do { a <- m; b... } = m >>= \a -> do { b... }
do { a; b... } = a >> do { b... }
do { a } = a
So this becomes:
post "/introduceAnIdea" $ do { command <- jsonData; json $ handle command}
= post "/introduceAnIdea" $ jsonData >>= \command -> do {json $ handle command}
= post "/introduceAnIdea" $ jsonData >>= \c -> json $ handle c
Upvotes: 3
Reputation: 15703
post "/introduceAnIdea" $ jsonData >>= (json . handle)
I don't think that's necessarily better in this case though.
Upvotes: 5