imm-1.5.0.0: Execute arbitrary actions for each unread element of RSS/Atom feeds

Safe HaskellNone
LanguageHaskell98

Imm

Description

Meta-module that reexports many Imm sub-modules.

To get started, please consult Imm.Boot.

Synopsis

Documentation

data LogLevel Source #

Constructors

Debug 
Info 
Warning 
Error 
Instances
Eq LogLevel Source # 
Instance details

Defined in Imm.Logger

Ord LogLevel Source # 
Instance details

Defined in Imm.Logger

Read LogLevel Source # 
Instance details

Defined in Imm.Logger

Show LogLevel Source # 
Instance details

Defined in Imm.Logger

Pretty LogLevel Source # 
Instance details

Defined in Imm.Logger

Methods

pretty :: LogLevel -> Doc ann #

prettyList :: [LogLevel] -> Doc ann #

log :: Handle m -> LogLevel -> Doc AnsiStyle -> m () Source #

flushLogs :: Handle m -> m () Source #

get :: Monad m => Handle m -> Handle m -> URI -> m LByteString Source #

Simple wrapper around httpGet that also logs the requested URI.

data Feed Source #

Instances
Eq Feed Source # 
Instance details

Defined in Imm.Feed

Methods

(==) :: Feed -> Feed -> Bool #

(/=) :: Feed -> Feed -> Bool #

Show Feed Source # 
Instance details

Defined in Imm.Feed

Methods

showsPrec :: Int -> Feed -> ShowS #

show :: Feed -> String #

showList :: [Feed] -> ShowS #

data FeedRef Source #

Feed reference: either its URI, or its UID from database

Constructors

ByUID Int 
ByURI URI 
Instances
Eq FeedRef Source # 
Instance details

Defined in Imm.Feed

Methods

(==) :: FeedRef -> FeedRef -> Bool #

(/=) :: FeedRef -> FeedRef -> Bool #

Show FeedRef Source # 
Instance details

Defined in Imm.Feed

Pretty FeedRef Source # 
Instance details

Defined in Imm.Feed

Methods

pretty :: FeedRef -> Doc ann #

prettyList :: [FeedRef] -> Doc ann #

processNewElement :: Handle m -> Feed -> FeedElement -> m () Source #

Action triggered for each unread feed element

onNewElement :: Monad m => Handle m -> Handle m -> Feed -> FeedElement -> m () Source #

data DatabaseException t Source #

Constructors

NotCommitted t 
NotDeleted t [Key t] 
NotFound t [Key t] 
NotInserted t [(Key t, Entry t)] 
NotPurged t 
NotUpdated t (Key t) 
UnableFetchAll t 
Instances
(Eq t, Eq (Key t), Eq (Entry t)) => Eq (DatabaseException t) Source # 
Instance details

Defined in Imm.Database

(Show t, Show (Key t), Show (Entry t)) => Show (DatabaseException t) Source # 
Instance details

Defined in Imm.Database

(Table t, Show (Key t), Show (Entry t), Pretty (Key t), Typeable t) => Exception (DatabaseException t) Source # 
Instance details

Defined in Imm.Database

(Pretty t, Pretty (Key t)) => Pretty (DatabaseException t) Source # 
Instance details

Defined in Imm.Database

Methods

pretty :: DatabaseException t -> Doc ann #

prettyList :: [DatabaseException t] -> Doc ann #

_describeDatabase :: Handle m t -> forall a. m (Doc a) Source #

_fetchList :: Handle m t -> [Key t] -> m (Map (Key t) (Entry t)) Source #

_fetchAll :: Handle m t -> m (Map (Key t) (Entry t)) Source #

_update :: Handle m t -> Key t -> (Entry t -> Entry t) -> m () Source #

_insertList :: Handle m t -> [(Key t, Entry t)] -> m () Source #

_deleteList :: Handle m t -> [Key t] -> m () Source #

_purge :: Handle m t -> m () Source #

_commit :: Handle m t -> m () Source #

class (Ord (Key t), Show (Key t), Show (Entry t), Typeable t, Show t, Pretty t, Pretty (Key t)) => Table t where Source #

Generic database table

Associated Types

type Key t :: * Source #

type Entry t :: * Source #

Methods

rep :: t Source #

Instances
Table FeedTable Source # 
Instance details

Defined in Imm.Database.FeedTable

Associated Types

type Key FeedTable :: Type Source #

type Entry FeedTable :: Type Source #

Methods

rep :: FeedTable Source #

fetch :: Monad m => Table t => MonadThrow m => Handle m t -> Key t -> m (Entry t) Source #

fetchList :: Monad m => Handle m t -> [Key t] -> m (Map (Key t) (Entry t)) Source #

fetchAll :: Monad m => Handle m t -> m (Map (Key t) (Entry t)) Source #

update :: Monad m => Handle m t -> Key t -> (Entry t -> Entry t) -> m () Source #

insert :: Monad m => Handle m -> Handle m t -> Key t -> Entry t -> m () Source #

insertList :: Monad m => Handle m -> Handle m t -> [(Key t, Entry t)] -> m () Source #

delete :: Monad m => Handle m -> Handle m t -> Key t -> m () Source #

deleteList :: Monad m => Handle m -> Handle m t -> [Key t] -> m () Source #

purge :: Monad m => Handle m -> Handle m t -> m () Source #

commit :: Monad m => Handle m -> Handle m t -> m () Source #

table :: Table t => Handle m t -> t Source #

showFeed :: MonadThrow m => Handle m -> Handle m FeedTable -> [FeedID] -> m () Source #

Print database status for given feed(s)

subscribe :: MonadCatch m => Handle m -> Handle m FeedTable -> URI -> Set Text -> m () Source #

Register the given feed URI in database

check :: (MonadAsync m, MonadCatch m) => Handle m -> Handle m FeedTable -> Handle m -> Handle m -> [FeedID] -> m () Source #

Check for unread elements without processing them

run :: (MonadTime m, MonadAsync m, MonadCatch m) => Handle m -> Handle m FeedTable -> Handle m -> Handle m -> Handle m -> [FeedID] -> m () Source #

importOPML :: MonadCatch m => Handle m -> Handle m FeedTable -> ConduitT () ByteString m () -> m () Source #

subscribe to all feeds described by the OPML document provided in input

imm :: Handle IO -> Handle IO FeedTable -> Handle IO -> Handle IO -> Handle IO -> IO () Source #

Main function, meant to be used in your personal configuration file.

Here is an example:

import           Imm.Boot
import           Imm.Database.JsonFile as Database
import           Imm.Feed
import           Imm.Hooks.SendMail as Hooks
import           Imm.HTTP.Simple as HTTP
import           Imm.Logger.Simple as Logger
import           Imm.XML.Conduit as XML

main :: IO ()
main = do
  logger     <- Logger.mkHandle <$> defaultLogger
  database   <- Database.mkHandle <$> defaultDatabase
  httpClient <- HTTP.mkHandle <$> defaultManager

  imm logger database httpClient hooks xmlParser

xmlParser :: XML.Handle IO
xmlParser = XML.mkHandle defaultXmlParser

hooks :: Hooks.Handle IO
hooks = Hooks.mkHandle $ SendMailSettings smtpServer formatMail

formatMail :: FormatMail
formatMail = FormatMail
  (\a b -> (defaultFormatFrom a b) { addressEmail = "user@host" } )
  defaultFormatSubject
  defaultFormatBody
  (\_ _ -> [Address Nothing "user@host"])

smtpServer :: Feed -> FeedElement -> SMTPServer
smtpServer _ _ = SMTPServer
  (Just $ Authentication PLAIN "user" "password")
  (StartTls "smtp.host" defaultSettingsSMTPSTARTTLS)