extraSimpleHTTP in Haskell

simpleHTTP is simple. But can the simple common case be made even simpler? Sure!

import Network.HTTP
import Network.URI

extraSimpleHTTP :: URI -> IO (Response String)
extraSimpleHTTP uri = (simpleHTTP $ mkRequest GET uri) >>= handleError
  where handleError = either (fail . show) return

You don’t have to create the request value yourself and you don’t have to handle possible errors any longer (since that is left to IO’s fail).

The signature String -> IO (Response String) would arguably be even simpler, but not as clear.