Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The easiest way to create a Request is with the
parseUrl function. This function will return a value in
any Failure monad, such as Maybe or IO. The last of those is the most
commonly used, and results in a runtime exception whenever an invalid URL is provided.
However, you can use a different monad if, for example, you want to validate user
input.
importNetwork.HTTP.ConduitimportSystem.Environment(getArgs)importqualifiedData.ByteString.LazyasLimportControl.Monad.IO.Class(liftIO)main::IO()main=doargs<-getArgscaseargsof[urlString]->caseparseUrlurlStringofNothing->putStrLn"Sorry, invalid URL"Justreq->