packages feed

cas-store 1.0.0 → 1.0.1

raw patch · 3 files changed

+45/−2 lines, 3 filesdep ~cas-hashable

Dependency ranges changed: cas-hashable

Files

cas-store.cabal view
@@ -1,5 +1,5 @@ Name:                cas-store-Version:             1.0.0+Version:             1.0.1 Synopsis:            A content-addressed storage Description:             A content-addressed storage supporting a remote caching. The API mainly consists of the cacheKleisliIO function which takes a (a -> m b) function@@ -26,13 +26,14 @@    Exposed-modules:  Data.CAS.ContentStore                    , Data.CAS.Lock                    , Data.CAS.RemoteCache+                   , Data.CAS.StoreOrphans    Other-modules: Data.CAS.ContentStore.Notify    Build-depends:                  base                    >= 4.6 && <5                , aeson                   >= 1.2.3.0                , async                , bytestring-               , cas-hashable            >= 1.0.0 && < 2+               , cas-hashable            >= 1.0.1 && < 2                , containers                , cryptonite                , directory
src/Data/CAS/ContentStore.hs view
@@ -146,6 +146,7 @@ import qualified Data.ByteString                     as BS import qualified Data.ByteString.Char8               as C8 import           Data.CAS.ContentStore.Notify+import           Data.CAS.StoreOrphans               () import           Data.Foldable                       (asum) import qualified Data.Hashable import           Data.List                           (foldl', stripPrefix)
+ src/Data/CAS/StoreOrphans.hs view
@@ -0,0 +1,41 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE LambdaCase        #-}+{-# LANGUAGE OverloadedStrings #-}++-- | Dedicated module for orphan instances.+module Data.CAS.StoreOrphans where++import           Data.Functor.Contravariant+import           Data.CAS.ContentHashable+import           Data.Store                 as Store+import qualified Path                       as Path+import qualified Path.Internal+++instance Store (Path.Path Path.Abs Path.File) where+  size = contramap (\(Path.Internal.Path fp) -> fp) Store.size+  peek = Path.Internal.Path <$> Store.peek+  poke = Store.poke . (\(Path.Internal.Path fp) -> fp)+instance Store (Path.Path Path.Abs Path.Dir) where+  size = contramap (\(Path.Internal.Path fp) -> fp) Store.size+  peek = Path.Internal.Path <$> Store.peek+  poke = Store.poke . (\(Path.Internal.Path fp) -> fp)+instance Store (Path.Path Path.Rel Path.File) where+  size = contramap (\(Path.Internal.Path fp) -> fp) Store.size+  peek = Path.Internal.Path <$> Store.peek+  poke = Store.poke . (\(Path.Internal.Path fp) -> fp)+instance Store (Path.Path Path.Rel Path.Dir) where+  size = contramap (\(Path.Internal.Path fp) -> fp) Store.size+  peek = Path.Internal.Path <$> Store.peek+  poke = Store.poke . (\(Path.Internal.Path fp) -> fp)++instance Store ContentHash where+  size = contramap toBytes size+  peek = fromBytes <$> peek >>= \case+    Nothing -> peekException "Store ContentHash: Illegal digest"+    Just x -> return x+  poke = poke . toBytes++instance Store ExternallyAssuredFile+instance Store ExternallyAssuredDirectory