pointless golfing

This commit is contained in:
Joey Hess 2011-06-16 18:27:01 -04:00
parent dd4de9deb4
commit bc731ba6e0

View file

@ -17,7 +17,6 @@ module Annex (
) where ) where
import Control.Monad.State import Control.Monad.State
(liftIO, StateT, runStateT, evalStateT, liftM, get, put)
import qualified GitRepo as Git import qualified GitRepo as Git
import GitQueue import GitQueue
@ -50,8 +49,8 @@ data AnnexState = AnnexState
, cipher :: Maybe Cipher , cipher :: Maybe Cipher
} }
newState :: Git.Repo -> [Backend Annex] -> AnnexState newState :: [Backend Annex] -> Git.Repo -> AnnexState
newState gitrepo allbackends = AnnexState newState allbackends gitrepo = AnnexState
{ repo = gitrepo { repo = gitrepo
, backends = [] , backends = []
, remotes = [] , remotes = []
@ -72,27 +71,26 @@ newState gitrepo allbackends = AnnexState
{- Create and returns an Annex state object for the specified git repo. -} {- Create and returns an Annex state object for the specified git repo. -}
new :: Git.Repo -> [Backend Annex] -> IO AnnexState new :: Git.Repo -> [Backend Annex] -> IO AnnexState
new gitrepo allbackends = do new gitrepo allbackends =
gitrepo' <- liftIO $ Git.configRead gitrepo newState allbackends `liftM` (liftIO . Git.configRead) gitrepo
return $ newState gitrepo' allbackends
{- performs an action in the Annex monad -} {- performs an action in the Annex monad -}
run :: AnnexState -> Annex a -> IO (a, AnnexState) run :: AnnexState -> Annex a -> IO (a, AnnexState)
run state action = runStateT action state run = flip runStateT
eval :: AnnexState -> Annex a -> IO a eval :: AnnexState -> Annex a -> IO a
eval state action = evalStateT action state eval = flip evalStateT
{- Gets a value from the internal state, selected by the passed value {- Gets a value from the internal state, selected by the passed value
- constructor. -} - constructor. -}
getState :: (AnnexState -> a) -> Annex a getState :: (AnnexState -> a) -> Annex a
getState c = liftM c get getState = gets
{- Applies a state mutation function to change the internal state. {- Applies a state mutation function to change the internal state.
- -
- Example: changeState (\s -> s { quiet = True }) - Example: changeState $ \s -> s { quiet = True }
-} -}
changeState :: (AnnexState -> AnnexState) -> Annex () changeState :: (AnnexState -> AnnexState) -> Annex ()
changeState a = put . a =<< get changeState = modify
{- Returns the git repository being acted on -} {- Returns the git repository being acted on -}
gitRepo :: Annex Git.Repo gitRepo :: Annex Git.Repo