diff --git a/src/Vervis.hs b/src/Vervis.hs index 738267f..fa5c279 100644 --- a/src/Vervis.hs +++ b/src/Vervis.hs @@ -13,12 +13,15 @@ - . -} +{-# 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 diff --git a/vervis.cabal b/vervis.cabal index 74e2e6c..816b637 100644 --- a/vervis.cabal +++ b/vervis.cabal @@ -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