aboutsummaryrefslogtreecommitdiff
path: root/Lazymail.hs
blob: 70a6b963b23dc347b36c68bd361b9c56cefddb93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{- Lazymail monad.
 -
 - Copyright 2013 Raúl Benencia <rul@kalgan.cc>
 -
 - Licensed under the GNU GPL version 3 or higher
 - 
 -}

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
nihil fit ex nihilo