diff options
author | Joey Hess <joey@kitenet.net> | 2011-12-24 23:02:42 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-12-24 23:02:42 -0400 |
commit | 6d4382a89ee0a021b3fa71302bfd74a906029e63 (patch) | |
tree | 99885f1cf6862aff0ffa37ba1f4b018ba92effa1 /Annex.hs | |
parent | ffefe742d8cc2655e29fa356c82326e867e27aa9 (diff) | |
parent | e04852c8af22f784d184a001b9fee04adb1828c1 (diff) |
Merge branch 'new-monad-control'
Diffstat (limited to 'Annex.hs')
-rw-r--r-- | Annex.hs | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -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 |