Can parse a feed

This commit is contained in:
Mats Rauhala 2021-11-11 22:40:47 +02:00
parent 1e661fe3ca
commit 21520d987f
4 changed files with 14 additions and 6 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
dist-newstyle
.envrc
/FeedMonad/state/
/state/

View File

@ -54,6 +54,7 @@ library
, safecopy
, xdg-basedir
, free
, feed
hs-source-dirs: src
default-language: Haskell2010
ghc-options: -Wall

View File

@ -1,14 +1,15 @@
{ mkDerivation, acid-state, base, bytestring, containers
, http-client, http-client-tls, lens, lib, mtl, safecopy, servant
, servant-server, text, xdg-basedir
{ mkDerivation, acid-state, base, bytestring, containers, feed
, free, http-client, http-client-tls, lens, lib, mtl, safecopy
, servant, servant-server, text, xdg-basedir
}:
mkDerivation {
pname = "FeedMonad";
version = "0.1.0.0";
src = ./.;
libraryHaskellDepends = [
acid-state base bytestring containers http-client http-client-tls
lens mtl safecopy servant servant-server text xdg-basedir
acid-state base bytestring containers feed free http-client
http-client-tls lens mtl safecopy servant servant-server text
xdg-basedir
];
license = "unknown";
hydraPlatforms = lib.platforms.none;

View File

@ -14,6 +14,9 @@ import Control.Monad.App (runApp)
import Data.Environment
import Control.Monad.Trans (liftIO)
import Data.URL (URL)
import Data.Foldable (for_)
import Control.Monad.HTTP (fetch, execute)
import Text.Feed.Import (parseFeedSource)
newtype Minutes = Minutes Natural
@ -44,4 +47,6 @@ defaultMain f =
bracket (openLocalState emptyFeedMonadState) closeAcidState $ \st -> do
mgr <- newTlsManager
runApp (Environment mgr st) $
liftIO $ print $ feeds f
for_ (feeds f) $ \c -> for_ c $ \url -> do
feed <- parseFeedSource <$> liftIO (execute mgr (fetch url))
liftIO $ print feed