Merge branch 'new-monad-control'
This commit is contained in:
commit
6d4382a89e
3 changed files with 19 additions and 8 deletions
17
Annex.hs
17
Annex.hs
|
@ -5,7 +5,7 @@
|
|||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving, TypeFamilies, MultiParamTypeClasses #-}
|
||||
|
||||
module Annex (
|
||||
Annex,
|
||||
|
@ -22,8 +22,9 @@ module Annex (
|
|||
fromRepo,
|
||||
) where
|
||||
|
||||
import Control.Monad.IO.Control
|
||||
import Control.Monad.State
|
||||
import Control.Monad.Trans.Control (StM, MonadBaseControl, liftBaseWith, restoreM)
|
||||
import Control.Monad.Base (liftBase, MonadBase)
|
||||
|
||||
import Common
|
||||
import qualified Git
|
||||
|
@ -45,12 +46,22 @@ newtype Annex a = Annex { runAnnex :: StateT AnnexState IO a }
|
|||
deriving (
|
||||
Monad,
|
||||
MonadIO,
|
||||
MonadControlIO,
|
||||
MonadState AnnexState,
|
||||
Functor,
|
||||
Applicative
|
||||
)
|
||||
|
||||
instance MonadBase IO Annex where
|
||||
liftBase = Annex . liftBase
|
||||
|
||||
instance MonadBaseControl IO Annex where
|
||||
newtype StM Annex a = StAnnex (StM (StateT AnnexState IO) a)
|
||||
liftBaseWith f = Annex $ liftBaseWith $ \runInIO ->
|
||||
f $ liftM StAnnex . runInIO . runAnnex
|
||||
restoreM = Annex . restoreM . unStAnnex
|
||||
where
|
||||
unStAnnex (StAnnex st) = st
|
||||
|
||||
data OutputType = NormalOutput | QuietOutput | JSONOutput
|
||||
|
||||
-- internal state storage
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue