{-# LANGUAGE BlockArguments #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# OPTIONS_GHC -fno-warn-name-shadowing #-} module Main where import Conduit import Data.Maybe import Data.XML.Types import Network.HTTP.Conduit import Text.Atom.Conduit.Parse import Text.Atom.Conduit.Render import Text.XML.Stream.Parse import Text.XML.Stream.Render import Text.XML.Unresolved (elementToEvents) main :: IO () main = do request <- parseRequest "https://code.nomath.org/abuilder/atom" manager <- newManager tlsManagerSettings runResourceT do response <- http request manager runConduit $ ( \feed -> renderAtomFeed feed .| renderBytes def .| printC ) . fromJust =<< responseBody response .| parseBytes def .| massage .| atomFeed massage :: ConduitT Event Event (ResourceT IO) () massage = do await >>= \case Nothing -> pure () Just e -> do yield e -- BeginDocument await >>= \case Nothing -> pure () Just e -> do yield e -- yieldMany (elementToEvents idE) yieldMany (elementToEvents updatedE) mapC id where idE = -- TODO(id) Element "{http://www.w3.org/2005/Atom}id" [] [ NodeContent (ContentText "TODO") ] updatedE = -- TODO(updated) Element "{http://www.w3.org/2005/Atom}updated" [] [ NodeContent (ContentText "1970-01-01T00:00:00Z") ]