module Main (main) where import Data.Text (Text) import qualified Data.Text as T import qualified Data.Text.IO as T import qualified System.Environment as Env import qualified System.Exit as Exit import qualified CSV import Hiking (Hiking (Hiking)) import qualified Hiking import qualified HTTP import qualified Scrapper main :: IO () main = do url <- getUrl hikings <- getHikings url T.putStrLn . CSV.lines . (:) Hiking.header . map Hiking.values $ hikings getUrl :: IO Text getUrl = do args <- Env.getArgs case args of (url:_) -> return $ T.pack url _ -> Exit.die "No url providen" getHikings :: Text -> IO [Hiking] getHikings url = do urls <- Scrapper.hikingsUrls <$> HTTP.get url mapM getHiking urls getHiking :: Text -> IO Hiking getHiking = fmap Scrapper.hiking . HTTP.get