summaryrefslogtreecommitdiff
path: root/Annex.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-06-16 18:27:01 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-06-20 21:37:18 -0400
commitbc731ba6e0b94c7d5d4be5ba3c5c13d6644183f9 (patch)
treef43e324065537eb9dd661bc40b5451c9a9698784 /Annex.hs
parentdd4de9deb464adb6631585abd3c5a7e1401c8c6f (diff)
pointless golfing
Diffstat (limited to 'Annex.hs')
-rw-r--r--Annex.hs20
1 files changed, 9 insertions, 11 deletions
diff --git a/Annex.hs b/Annex.hs
index 06d642b74..0d6b309cc 100644
--- a/Annex.hs
+++ b/Annex.hs
@@ -17,7 +17,6 @@ module Annex (
) where
import Control.Monad.State
- (liftIO, StateT, runStateT, evalStateT, liftM, get, put)
import qualified GitRepo as Git
import GitQueue
@@ -50,8 +49,8 @@ data AnnexState = AnnexState
, cipher :: Maybe Cipher
}
-newState :: Git.Repo -> [Backend Annex] -> AnnexState
-newState gitrepo allbackends = AnnexState
+newState :: [Backend Annex] -> Git.Repo -> AnnexState
+newState allbackends gitrepo = AnnexState
{ repo = gitrepo
, backends = []
, remotes = []
@@ -72,27 +71,26 @@ newState gitrepo allbackends = AnnexState
{- Create and returns an Annex state object for the specified git repo. -}
new :: Git.Repo -> [Backend Annex] -> IO AnnexState
-new gitrepo allbackends = do
- gitrepo' <- liftIO $ Git.configRead gitrepo
- return $ newState gitrepo' allbackends
+new gitrepo allbackends =
+ newState allbackends `liftM` (liftIO . Git.configRead) gitrepo
{- performs an action in the Annex monad -}
run :: AnnexState -> Annex a -> IO (a, AnnexState)
-run state action = runStateT action state
+run = flip runStateT
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
- constructor. -}
getState :: (AnnexState -> a) -> Annex a
-getState c = liftM c get
+getState = gets
{- 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 a = put . a =<< get
+changeState = modify
{- Returns the git repository being acted on -}
gitRepo :: Annex Git.Repo