{-# LANGUAGE FlexibleInstances #-}
-- What /would/ a nicer Haskell HTTP library look like?
import Data.Text (Text)
type Header = (String, String)
class HttpResult t where
result :: t
instance HttpResult Text where
result = undefined
instance HttpResult r => HttpResult (Maybe r) where
result = undefined
class HttpRequest t where
stuff :: t
instance HttpResult r => HttpRequest (String -> IO r) where
stuff = undefined
instance HttpResult r => HttpRequest (String -> [Header] -> IO r) where
stuff = undefined
get :: HttpRequest t => t
get = undefined
main :: IO ()
main = do
m0 <- get "/foo" :: IO Text
m1 <- get "/foo" :: IO (Maybe Text)
m2 <- get "/foo" [("Content-Type", "text/html")]:: IO (Maybe Text)
return ()