Safe Haskell | None |
---|---|
Language | Haskell98 |
Getting started
Dynamic reconfiguration
This program is dynamically configured using the dyre library.
You may want to check out this documentation to know how to get started.
Your personal configuration is located at $XDG_CONFIG_HOME/imm/imm.hs
.
Interpreter pattern
The behavior of this program can be customized through the interpreter pattern, implemented using free monads (for the DSL part) and cofree comonads (for the interpreter part).
The design is inspired from Cofun with cofree monads.
- imm :: (a -> CoHttpClientF IO a, a) -> (b -> CoDatabaseF' IO b, b) -> (c -> CoLoggerF IO c, c) -> (d -> CoHooksF IO d, d) -> (e -> CoXmlParserF IO e, e) -> IO ()
Documentation
:: (a -> CoHttpClientF IO a, a) | HTTP client interpreter (cf Imm.HTTP) |
-> (b -> CoDatabaseF' IO b, b) | Database interpreter (cf Imm.Database) |
-> (c -> CoLoggerF IO c, c) | Logger interpreter (cf Imm.Logger) |
-> (d -> CoHooksF IO d, d) | Hooks interpreter (cf Imm.Hooks) |
-> (e -> CoXmlParserF IO e, e) | XML parsing interpreter (cf Imm.XML) |
-> IO () |
Main function, meant to be used in your personal configuration file. Each argument is an interpreter functor along with an initial state.
Here is an example:
import Imm.Boot import Imm.Database.JsonFile import Imm.Feed import Imm.Hooks.SendMail import Imm.HTTP.Simple import Imm.Logger.Simple import Imm.XML.Simple main :: IO () main = do logger <- defaultLogger manager <- defaultManager database <- defaultDatabase imm (mkCoHttpClient, manager) (mkCoDatabase, database) (mkCoLogger, logger) (mkCoHooks, sendmail) (mkCoXmlParser, defaultPreProcess) 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)