aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaúl Benencia <rul@kalgan.cc>2013-08-24 12:17:13 -0300
committerRaúl Benencia <rul@kalgan.cc>2013-08-24 12:17:13 -0300
commitfc1231ca6e008582fb6a669cb9d0607059e82cdd (patch)
treef8884e0e7735eb60c653c3fc6a9d4e7c03850b39
parentf8a4858bc0d566b20c8201a6c42decd81442c41a (diff)
Lazymail monad
-rw-r--r--Config.hs2
-rw-r--r--Lazymail.hs18
2 files changed, 19 insertions, 1 deletions
diff --git a/Config.hs b/Config.hs
index 39e227f..bf35cb1 100644
--- a/Config.hs
+++ b/Config.hs
@@ -32,4 +32,4 @@ defaultConfig = LazymailConfig {
-- preferences. In a possible future maybe I'll work in a not-so-crappy
-- config system.
--
-customConfig = defaultConfig { basePath = "/home/rul/mail/kalgan" } \ No newline at end of file
+customConfig = defaultConfig { basePath = Just "/home/rul/mail/kalgan" } \ No newline at end of file
diff --git a/Lazymail.hs b/Lazymail.hs
index 9347b2e..70a6b96 100644
--- a/Lazymail.hs
+++ b/Lazymail.hs
@@ -6,3 +6,21 @@
-
-}
+module Lazymail where
+
+import Control.Monad.Reader
+import Control.Monad.State
+
+import Config(LazymailConfig, customConfig)
+import State(LazymailState, initialState)
+
+{- Lazymail monad is a ReaderT around a StateT with IO at the bottom of the
+ - stack.
+ -}
+type Lazymail = ReaderT LazymailConfig (StateT LazymailState IO)
+
+run :: Lazymail a -> IO (a, LazymailState)
+run k =
+ let config = customConfig
+ state = initialState
+ in runStateT (runReaderT k config) state \ No newline at end of file
nihil fit ex nihilo