-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Execute arbitrary actions for each unread element of RSS/Atom feeds -- -- Cf README file @package imm @version 1.3.0.0 module Imm.Prelude type LByteString = ByteString type ByteString = ByteString type LText = Text type Text = Text -- | Shortcut to liftIO io :: MonadIO m => IO a -> m a -- | Generic show show :: (Show a, IsString b) => a -> b -- | Logger module. module Imm.Logger data LogLevel Debug :: LogLevel Info :: LogLevel Warning :: LogLevel Error :: LogLevel -- | Monad capable of logging pretty text. class Monad m => MonadLog m log :: MonadLog m => LogLevel -> Doc AnsiStyle -> m () getLogLevel :: MonadLog m => m LogLevel setLogLevel :: MonadLog m => LogLevel -> m () setColorizeLogs :: MonadLog m => Bool -> m () flushLogs :: MonadLog m => m () logDebug :: MonadLog m => Doc AnsiStyle -> m () logInfo :: MonadLog m => Doc AnsiStyle -> m () logWarning :: MonadLog m => Doc AnsiStyle -> m () logError :: MonadLog m => Doc AnsiStyle -> m () instance GHC.Show.Show Imm.Logger.LogLevel instance GHC.Read.Read Imm.Logger.LogLevel instance GHC.Classes.Ord Imm.Logger.LogLevel instance GHC.Classes.Eq Imm.Logger.LogLevel instance Data.Text.Prettyprint.Doc.Internal.Pretty Imm.Logger.LogLevel -- | Implementation of Imm.Logger based on fast-logger. For -- further information, please consult System.Log.FastLogger. module Imm.Logger.Simple data LoggerSettings LoggerSettings :: LoggerSet -> LoggerSet -> LogLevel -> Bool -> LoggerSettings -- | LoggerSet used for Debug, Info and Warning -- logs [_loggerSet] :: LoggerSettings -> LoggerSet -- | LoggerSet used for Error logs [_errorLoggerSet] :: LoggerSettings -> LoggerSet -- | Discard logs that are strictly less serious than this level [_logLevel] :: LoggerSettings -> LogLevel -- | Enable log colorisation [_colorizeLogs] :: LoggerSettings -> Bool -- | Default logger forwards error messages to stderr, and other messages -- to stdout. defaultLogger :: IO (MVar LoggerSettings) instance Imm.Logger.MonadLog (Control.Monad.Trans.Reader.ReaderT (GHC.MVar.MVar Imm.Logger.Simple.LoggerSettings) GHC.Types.IO) -- | HTTP module abstracts over HTTP requests to the external world. module Imm.HTTP -- | Monad capable of performing GET HTTP requests. class MonadThrow m => MonadHttpClient m httpGet :: MonadHttpClient m => URI -> m LByteString -- | Simple wrapper around httpGet that also logs the requested URI. get :: (MonadHttpClient m, MonadLog m, MonadThrow m) => URI -> m LByteString -- | Implementation of Imm.HTTP based on Network.HTTP.Client. module Imm.HTTP.Simple -- | Default manager uses TLS and no proxy defaultManager :: IO Manager instance Imm.HTTP.MonadHttpClient (Control.Monad.Trans.Reader.ReaderT Network.HTTP.Client.Types.Manager GHC.Types.IO) -- | Helpers to manipulate feeds module Imm.Feed -- | Feed reference: either its URI, or its UID from database data FeedRef ByUID :: Int -> FeedRef ByURI :: URI -> FeedRef data Feed Rss :: (RssDocument '[ContentModule, DublinCoreModule]) -> Feed Atom :: AtomFeed -> Feed data FeedElement RssElement :: (RssItem '[ContentModule, DublinCoreModule]) -> FeedElement AtomElement :: AtomEntry -> FeedElement getFeedTitle :: Feed -> Text getElements :: Feed -> [FeedElement] getDate :: FeedElement -> Maybe UTCTime getTitle :: FeedElement -> Text getContent :: FeedElement -> Text getHashes :: FeedElement -> [Int] prettyElement :: FeedElement -> Doc a instance GHC.Show.Show Imm.Feed.FeedElement instance GHC.Classes.Eq Imm.Feed.FeedElement instance GHC.Show.Show Imm.Feed.Feed instance GHC.Classes.Eq Imm.Feed.Feed instance GHC.Show.Show Imm.Feed.FeedRef instance GHC.Classes.Eq Imm.Feed.FeedRef instance Data.Text.Prettyprint.Doc.Internal.Pretty Imm.Feed.FeedRef -- | Hooks module to define the main behavior of the program. module Imm.Hooks -- | Monad capable of acting on specific events. class Monad m => MonadImm m -- | Action triggered for each unread feed element processNewElement :: MonadImm m => Feed -> FeedElement -> m () onNewElement :: (MonadImm m, MonadLog m) => Feed -> FeedElement -> m () -- | Implementation of Imm.Hooks that writes a file for each new -- RSS/Atom item. module Imm.Hooks.WriteFile -- | Where and what to write in a file data FileInfo FileInfo :: FilePath -> Builder -> FileInfo newtype WriteFileSettings WriteFileSettings :: (Feed -> FeedElement -> FileInfo) -> WriteFileSettings -- | Wrapper around defaultFilePath and defaultFileContent defaultSettings :: FilePath -> WriteFileSettings -- | Generate a path -- roottitledate-title.html, -- where root is the first argument defaultFilePath :: FilePath -> Feed -> FeedElement -> FilePath -- | Generate an HTML page, with a title, a header and an article that -- contains the feed element defaultFileContent :: Feed -> FeedElement -> Builder defaultArticleTitle :: Feed -> FeedElement -> Html defaultArticleAuthor :: Feed -> FeedElement -> Html defaultArticleDate :: Feed -> FeedElement -> Html -- | Generate the HTML content for a given feed element defaultBody :: Feed -> FeedElement -> Html convertAtomURI :: (IsString t) => AtomURI -> t convertURI :: (IsString t) => URIRef a -> t convertText :: (IsString t) => Text -> t convertDoc :: (IsString t) => Doc a -> t instance Imm.Hooks.MonadImm (Control.Monad.Trans.Reader.ReaderT Imm.Hooks.WriteFile.WriteFileSettings GHC.Types.IO) -- | Implementation of Imm.Hooks that sends a mail via a SMTP server -- for each new RSS/Atom element. You may want to check out -- Network.HaskellNet.SMTP, Network.HaskellNet.SMTP.SSL and -- Network.Mail.Mime modules for additional information. -- -- Here is an example configuration: -- --
-- sendmail :: SendMailSettings
-- sendmail = 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.server" defaultSettingsSMTPSTARTTLS)
--
module Imm.Hooks.SendMail
type Username = String
type Password = String
type ServerName = String
-- | How to connect to the SMTP server
data ConnectionSettings
Plain :: ServerName -> PortNumber -> ConnectionSettings
Ssl :: ServerName -> Settings -> ConnectionSettings
StartTls :: ServerName -> Settings -> ConnectionSettings
-- | How to authenticate to the SMTP server
data Authentication
Authentication :: AuthType -> Username -> Password -> Authentication
data SMTPServer
SMTPServer :: (Maybe Authentication) -> ConnectionSettings -> SMTPServer
-- | How to format outgoing mails from feed elements
data FormatMail
FormatMail :: (Feed -> FeedElement -> Address) -> (Feed -> FeedElement -> Text) -> (Feed -> FeedElement -> Text) -> (Feed -> FeedElement -> [Address]) -> FormatMail
-- | How to write the From: header of feed mails
[formatFrom] :: FormatMail -> Feed -> FeedElement -> Address
-- | How to write the Subject: header of feed mails
[formatSubject] :: FormatMail -> Feed -> FeedElement -> Text
-- | How to write the body of feed mails (sic!)
[formatBody] :: FormatMail -> Feed -> FeedElement -> Text
-- | How to write the To: header of feed mails
[formatTo] :: FormatMail -> Feed -> FeedElement -> [Address]
data SendMailSettings
SendMailSettings :: (Feed -> FeedElement -> SMTPServer) -> FormatMail -> SendMailSettings
-- | Fill addressName with the feed title and, if available, the
-- authors' names.
--
-- This function leaves addressEmail empty. You are expected to
-- fill it adequately, because many SMTP servers enforce constraints on
-- the From: email.
defaultFormatFrom :: Feed -> FeedElement -> Address
-- | Fill mail subject with the element title
defaultFormatSubject :: Feed -> FeedElement -> Text
-- | Fill mail body with:
--
--
-- import Imm.Boot
-- import Imm.Database.JsonFile
-- import Imm.Feed
-- import Imm.Hooks.SendMail
-- import Imm.HTTP.Conduit
-- import Imm.Logger.Simple
-- import Imm.XML.Simple
--
-- main :: IO ()
-- main = do
-- logger <- defaultLogger
-- manager <- defaultManager
-- database <- defaultDatabase
--
-- imm $ mkModulesM manager database logger sendmail defaultXmlParser
--
-- sendmail :: SendMailSettings
-- sendmail = 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)
--
imm :: ModulesM IO -> IO ()
-- | Modules are independent features of the program which behavior can be
-- controlled by the user.
data Modules httpClient databaseClient logger hooks xmlParser
Modules :: httpClient -> databaseClient -> logger -> hooks -> xmlParser -> Modules httpClient databaseClient logger hooks xmlParser
-- | HTTP client interpreter (cf Imm.HTTP)
[_httpClient] :: Modules httpClient databaseClient logger hooks xmlParser -> httpClient
-- | Database interpreter (cf Imm.Database)
[_databaseClient] :: Modules httpClient databaseClient logger hooks xmlParser -> databaseClient
-- | Logging interpreter (cf Imm.Logger)
[_logger] :: Modules httpClient databaseClient logger hooks xmlParser -> logger
-- | Hooks interpreter (cf Imm.Hooks)
[_hooks] :: Modules httpClient databaseClient logger hooks xmlParser -> hooks
-- | XML parsing interpreter (cf Imm.XML)
[_xmlParser] :: Modules httpClient databaseClient logger hooks xmlParser -> xmlParser
-- | Type-erased version of Modules, using existential
-- quantification.
data ModulesM m
-- | Constructor for ModulesM.
mkModulesM :: (MonadXmlParser (ReaderT e m), MonadImm (ReaderT d m), MonadLog (ReaderT c m), MonadDatabase FeedTable (ReaderT b m), MonadHttpClient (ReaderT a m)) => a -> b -> c -> d -> e -> ModulesM m
instance GHC.Show.Show Imm.Boot.InterruptedException
instance GHC.Read.Read Imm.Boot.InterruptedException
instance GHC.Classes.Eq Imm.Boot.InterruptedException
instance GHC.Show.Show Imm.Boot.SafeGuard
instance GHC.Read.Read Imm.Boot.SafeGuard
instance GHC.Classes.Eq Imm.Boot.SafeGuard
instance GHC.Exception.Exception Imm.Boot.InterruptedException
instance (Control.Monad.IO.Class.MonadIO m, Imm.Logger.MonadLog (Control.Monad.Trans.Reader.ReaderT c m)) => Imm.Logger.MonadLog (Control.Monad.Trans.Reader.ReaderT (Imm.Boot.Modules a b c d e) m)
instance (GHC.Base.Monad m, Imm.Hooks.MonadImm (Control.Monad.Trans.Reader.ReaderT d m)) => Imm.Hooks.MonadImm (Control.Monad.Trans.Reader.ReaderT (Imm.Boot.Modules a b c d e) m)
instance (Control.Monad.Catch.MonadThrow m, Imm.HTTP.MonadHttpClient (Control.Monad.Trans.Reader.ReaderT a m)) => Imm.HTTP.MonadHttpClient (Control.Monad.Trans.Reader.ReaderT (Imm.Boot.Modules a b c d e) m)
instance (Control.Monad.Catch.MonadThrow m, Imm.XML.MonadXmlParser (Control.Monad.Trans.Reader.ReaderT e m)) => Imm.XML.MonadXmlParser (Control.Monad.Trans.Reader.ReaderT (Imm.Boot.Modules a b c d e) m)
instance (Control.Monad.Catch.MonadThrow m, Imm.Database.MonadDatabase Imm.Database.FeedTable.FeedTable (Control.Monad.Trans.Reader.ReaderT b m)) => Imm.Database.MonadDatabase Imm.Database.FeedTable.FeedTable (Control.Monad.Trans.Reader.ReaderT (Imm.Boot.Modules a b c d e) m)
-- | Meta-module that reexports many Imm sub-modules.
--
-- To get started, please consult Imm.Boot.
module Imm