Define Vervis monad as a newtype over RWST
This commit is contained in:
parent
a953923a3e
commit
56dddddde6
2 changed files with 25 additions and 0 deletions
|
@ -13,12 +13,15 @@
|
|||
- <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
|
||||
module Vervis
|
||||
( User (..)
|
||||
, Group (..)
|
||||
, IrcChannel (..)
|
||||
, Repository (..)
|
||||
, Server (..)
|
||||
, Vervis ()
|
||||
, subdirs
|
||||
, lastChange
|
||||
, timeAgo
|
||||
|
@ -27,6 +30,9 @@ module Vervis
|
|||
where
|
||||
|
||||
import Control.Monad (join)
|
||||
import Control.Monad.Fix (MonadFix)
|
||||
import Control.Monad.IO.Class (MonadIO)
|
||||
import Control.Monad.Trans.RWS (RWST (..))
|
||||
import Data.CaseInsensitive (CI)
|
||||
import Data.Foldable (toList)
|
||||
import Data.Git
|
||||
|
@ -75,6 +81,24 @@ data Server = Server
|
|||
, serverRepos :: HashMap (Either Int Int) [Repository]
|
||||
}
|
||||
|
||||
data VervisEnv = VervisEnv
|
||||
{
|
||||
}
|
||||
|
||||
data VervisState = VervisState
|
||||
{
|
||||
}
|
||||
|
||||
newtype Vervis a = Vervis { unVervis :: RWST VervisEnv () VervisState IO a }
|
||||
deriving (Functor, Applicative, Monad, MonadFix, MonadIO)
|
||||
|
||||
-- internal func, wrap with API func which hides env and state details
|
||||
runVervis' :: VervisEnv -> VervisState -> Vervis a -> IO (a, VervisState)
|
||||
runVervis' venv vstate computation = do
|
||||
let rwst = unVervis computation
|
||||
(a, s, _) <- runRWST rwst venv vstate
|
||||
return (a, s)
|
||||
|
||||
subdirs :: FilePath -> IO [FilePath]
|
||||
subdirs dir = do
|
||||
_base :/ tree <- buildL dir
|
||||
|
|
|
@ -36,6 +36,7 @@ library
|
|||
, hit >=0.6.3
|
||||
, hourglass
|
||||
, text >=1
|
||||
, transformers >=0.4.2
|
||||
, unordered-containers >=0.2.5
|
||||
hs-source-dirs: src
|
||||
default-language: Haskell2010
|
||||
|
|
Loading…
Reference in a new issue