specialize Preparer a bit, so resourcePrepare can be added
The forall a. in Preparer made resourcePrepare not seem to be usable, so I specialized a to Bool. Which works for both Preparer Storer and Preparer Retriever, but wouldn't let the Preparer be used for hasKey as it currently stands.
This commit is contained in:
parent
1ee24a0366
commit
c3750901d8
4 changed files with 7 additions and 6 deletions
|
@ -6,7 +6,6 @@
|
|||
-}
|
||||
|
||||
{-# LANGUAGE CPP #-}
|
||||
{-# LANGUAGE Rank2Types #-}
|
||||
|
||||
module Remote.Directory (remote) where
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE Rank2Types #-}
|
||||
|
||||
module Remote.Directory.LegacyChunked where
|
||||
|
||||
import qualified Data.ByteString.Lazy as L
|
||||
|
|
|
@ -14,6 +14,7 @@ module Remote.Helper.ChunkedEncryptable (
|
|||
simplyPrepare,
|
||||
ContentSource,
|
||||
checkPrepare,
|
||||
resourcePrepare,
|
||||
fileStorer,
|
||||
byteStorer,
|
||||
fileRetriever,
|
||||
|
@ -49,6 +50,11 @@ checkPrepare checker helper k a = ifM (checker k)
|
|||
, a Nothing
|
||||
)
|
||||
|
||||
-- Use to acquire a resource when preparing a helper.
|
||||
resourcePrepare :: (Key -> (r -> Annex Bool) -> Annex Bool) -> (r -> helper) -> Preparer helper
|
||||
resourcePrepare withr helper k a = withr k $ \r ->
|
||||
a (Just (helper r))
|
||||
|
||||
-- A Storer that expects to be provided with a file containing
|
||||
-- the content of the key to store.
|
||||
fileStorer :: (Key -> FilePath -> MeterUpdate -> Annex Bool) -> Storer
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE Rank2Types #-}
|
||||
|
||||
module Types.StoreRetrieve where
|
||||
|
||||
import Common.Annex
|
||||
|
@ -16,7 +14,7 @@ import qualified Data.ByteString.Lazy as L
|
|||
|
||||
-- Prepares for and then runs an action that will act on a Key's
|
||||
-- content, passing it a helper when the preparation is successful.
|
||||
type Preparer helper = forall a. Key -> (Maybe helper -> Annex a) -> Annex a
|
||||
type Preparer helper = Key -> (Maybe helper -> Annex Bool) -> Annex Bool
|
||||
|
||||
-- A source of a Key's content.
|
||||
data ContentSource
|
||||
|
|
Loading…
Reference in a new issue