Skip to content

Commit caf7162

Browse files
authored
update build to work with aeson >= 2.0 and text >= 2.0 (#209)
Fixes #208 by updating stack, cabal, and nix versions, and making the necessary changes to the codebase.
1 parent a7de68c commit caf7162

File tree

19 files changed

+260
-109
lines changed

19 files changed

+260
-109
lines changed

cas/hashable/cas-hashable.cabal

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
cabal-version: 1.12
22

3-
-- This file has been generated from package.yaml by hpack version 0.34.4.
3+
-- This file has been generated from package.yaml by hpack version 0.34.7.
44
--
55
-- see: https://github.com/sol/hpack
66

77
name: cas-hashable
8-
version: 1.0.1
8+
version: 1.0.2
99
synopsis: A hashing class for content-addressed storage
1010
description: A hashing class for content-addressed storage. Content can be hashed either by value or through an IO action. Part of the funflow ecosystem.
1111
category: Control
@@ -32,21 +32,21 @@ library
3232
src
3333
ghc-options: -Wall
3434
build-depends:
35-
aeson
35+
aeson >=2.1.0 && <2.2
3636
, base >=4.9 && <5
3737
, bytestring
3838
, clock
3939
, containers
4040
, cryptonite
4141
, ghc-prim
42-
, hashable
42+
, hashable >=1.4.1 && <1.5
4343
, integer-gmp
4444
, memory
4545
, path
4646
, path-io
4747
, safe-exceptions
4848
, scientific
49-
, text
49+
, text >=2.0.1 && <2.1
5050
, time
5151
, unix
5252
, unordered-containers
@@ -61,22 +61,22 @@ test-suite perf
6161
hs-source-dirs:
6262
app
6363
build-depends:
64-
aeson
64+
aeson >=2.1.0 && <2.2
6565
, base >=4.6 && <5
6666
, bytestring
6767
, cas-hashable
6868
, clock
6969
, containers
7070
, cryptonite
7171
, ghc-prim
72-
, hashable
72+
, hashable >=1.4.1 && <1.5
7373
, integer-gmp
7474
, memory
7575
, path
7676
, path-io
7777
, safe-exceptions
7878
, scientific
79-
, text
79+
, text >=2.0.1 && <2.1
8080
, time
8181
, unix
8282
, unordered-containers

cas/hashable/package.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: cas-hashable
2-
version: 1.0.1
2+
version: 1.0.2
33
synopsis: A hashing class for content-addressed storage
44
description: A hashing class for content-addressed storage. Content can be hashed either by value or through an IO action. Part of the funflow ecosystem.
55
license: MIT
@@ -12,21 +12,21 @@ author: Tom Nielsen, Nicholas Clarke, Andreas Herrmann
1212
ghc-options: -Wall
1313

1414
dependencies:
15-
- base >= 4.9 && < 5
16-
- aeson
15+
- base >= 4.9 && < 5
16+
- aeson >= 2.1.0 && < 2.2
1717
- bytestring
1818
- clock
1919
- containers
2020
- cryptonite
2121
- ghc-prim
22-
- hashable
22+
- hashable >= 1.4.1 && < 1.5
2323
- integer-gmp
2424
- memory
2525
- path
2626
- path-io
2727
- safe-exceptions
2828
- scientific
29-
- text
29+
- text >= 2.0.1 && < 2.1
3030
- time
3131
- unix
3232
- unordered-containers
@@ -45,4 +45,4 @@ tests:
4545
- -rtsopts -O2
4646
dependencies:
4747
- base >=4.6 && <5
48-
- cas-hashable
48+
- cas-hashable

cas/hashable/src/Data/CAS/ContentHashable.hs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
{-# LANGUAGE TypeOperators #-}
1111
{-# LANGUAGE TypeSynonymInstances #-}
1212
{-# LANGUAGE UnboxedTuples #-}
13+
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
14+
{-# HLINT ignore "Use camelCase" #-}
1315

1416
-- | 'ContentHashable' provides a hashing function suitable for use in the
1517
-- Funflow content store.
@@ -59,7 +61,8 @@ import Crypto.Hash
5961
)
6062
import qualified Data.Aeson as Aeson
6163
import qualified Data.Aeson.Types as Aeson
62-
import Data.Bits (shiftL)
64+
import qualified Data.Aeson.KeyMap as Aeson
65+
import qualified Data.Aeson.Key as Aeson
6366
import Data.ByteArray
6467
( Bytes,
6568
MemView (MemView),
@@ -249,11 +252,9 @@ contentHashUpdate_byteArray# ba (I# off) (I# len) ctx = hashUpdate ctx $
249252

250253
-- | Update hash context based on the contents of a strict 'Data.Text.Text'.
251254
contentHashUpdate_text :: Context SHA256 -> T.Text -> Context SHA256
252-
contentHashUpdate_text ctx (T.Text arr off_ len_) =
253-
contentHashUpdate_byteArray# (TA.aBA arr) off len ctx
254-
where
255-
off = off_ `shiftL` 1 -- convert from 'Word16' to 'Word8'
256-
len = len_ `shiftL` 1 -- convert from 'Word16' to 'Word8'
255+
contentHashUpdate_text ctx (T.Text (TA.ByteArray arr) off len) =
256+
contentHashUpdate_byteArray# arr off len ctx
257+
257258

258259
instance Monad m => ContentHashable m Fingerprint where
259260
contentHashUpdate ctx (Fingerprint a b) = flip contentHashUpdate_storable a >=> flip contentHashUpdate_storable b $ ctx
@@ -443,6 +444,12 @@ instance (ContentHashable m a, ContentHashable m b) => ContentHashable m (Either
443444

444445
instance Monad m => ContentHashable m Aeson.Value
445446

447+
instance Monad m => ContentHashable m (Aeson.KeyMap Aeson.Value) where
448+
contentHashUpdate ctx m = contentHashUpdate ctx (Aeson.toList m)
449+
450+
instance Monad m => ContentHashable m Aeson.Key where
451+
contentHashUpdate ctx k = contentHashUpdate ctx (Aeson.toText k)
452+
446453
class Monad m => GContentHashable m f where
447454
gContentHashUpdate :: Context SHA256 -> f a -> m (Context SHA256)
448455

cas/s3/cas-hashable-s3.cabal

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
cabal-version: 1.12
22

3-
-- This file has been generated from package.yaml by hpack version 0.34.4.
3+
-- This file has been generated from package.yaml by hpack version 0.34.7.
44
--
55
-- see: https://github.com/sol/hpack
66

77
name: cas-hashable-s3
8-
version: 1.0.0
8+
version: 1.0.1
99
synopsis: ContentHashable instances for S3 objects
1010
description: Provides ContentHashable instances for S3 objects
1111
category: Control
@@ -30,7 +30,7 @@ library
3030
src
3131
ghc-options: -Wall
3232
build-depends:
33-
aeson
33+
aeson >=2.0
3434
, aws
3535
, base >=4.9 && <5
3636
, cas-hashable

cas/s3/package.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: cas-hashable-s3
2-
version: 1.0.0
2+
version: 1.0.1
33
synopsis: ContentHashable instances for S3 objects
44
description: Provides ContentHashable instances for S3 objects
55
license: MIT
@@ -13,7 +13,7 @@ ghc-options: -Wall
1313

1414
dependencies:
1515
- base >= 4.9 && < 5
16-
- aeson
16+
- aeson >= 2.0
1717
- aws
1818
- cas-hashable
1919
- constraints

cas/store/cas-store.cabal

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
cabal-version: 1.12
22

3-
-- This file has been generated from package.yaml by hpack version 0.34.4.
3+
-- This file has been generated from package.yaml by hpack version 0.34.7.
44
--
55
-- see: https://github.com/sol/hpack
66

77
name: cas-store
8-
version: 1.1.0
8+
version: 1.1.1
99
synopsis: A content-addressed storage
1010
description: A content-addressed storage supporting a remote caching. The API mainly consists of the cacheKleisliIO function which takes a (a -> m b) function and runs it only if the store doesn't already contain a result for it. Part of the funflow ecosystem.
1111
category: Control
@@ -35,7 +35,7 @@ library
3535
src
3636
ghc-options: -Wall
3737
build-depends:
38-
aeson
38+
aeson >=2.1.0 && <2.2
3939
, async
4040
, base >=4.9 && <5
4141
, bytestring
@@ -44,17 +44,17 @@ library
4444
, cryptonite
4545
, directory
4646
, filepath
47-
, hashable
47+
, hashable >=1.4.1 && <1.5
4848
, hostname
49-
, lens
49+
, lens >=5.2
5050
, path
5151
, path-io
5252
, random
5353
, safe-exceptions
5454
, sqlite-simple
5555
, store
5656
, tar
57-
, text
57+
, text >=2.0.1 && <2.1
5858
, unix
5959
, unliftio
6060
if os(linux)
@@ -82,7 +82,7 @@ test-suite unit-tests
8282
test
8383
ghc-options: -Wall -Wall -threaded
8484
build-depends:
85-
aeson
85+
aeson >=2.1.0 && <2.2
8686
, async
8787
, base
8888
, bytestring
@@ -92,9 +92,9 @@ test-suite unit-tests
9292
, cryptonite
9393
, directory
9494
, filepath
95-
, hashable
95+
, hashable >=1.4.1 && <1.5
9696
, hostname
97-
, lens
97+
, lens >=5.2
9898
, path
9999
, path-io
100100
, random
@@ -104,7 +104,7 @@ test-suite unit-tests
104104
, tar
105105
, tasty
106106
, tasty-hunit
107-
, text
107+
, text >=2.0.1 && <2.1
108108
, unix
109109
, unliftio
110110
default-language: Haskell2010

cas/store/package.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: cas-store
2-
version: 1.1.0
2+
version: 1.1.1
33
synopsis: A content-addressed storage
44
description: A content-addressed storage supporting a remote caching. The API mainly consists of the cacheKleisliIO function which takes a (a -> m b) function and runs it only if the store doesn't already contain a result for it. Part of the funflow ecosystem.
55
license: MIT
@@ -12,26 +12,26 @@ author: Tom Nielsen, Nicholas Clarke, Andreas Herrmann
1212
ghc-options: -Wall
1313

1414
dependencies:
15-
- base >= 4.9 && < 5
16-
- aeson
15+
- base >= 4.9 && < 5
16+
- aeson >= 2.1.0 && < 2.2
1717
- async
1818
- bytestring
1919
- cas-hashable
2020
- containers
2121
- cryptonite
2222
- directory
2323
- filepath
24-
- hashable
24+
- hashable >= 1.4.1 && < 1.5
2525
- hostname
26-
- lens
26+
- lens >= 5.2
2727
- path
2828
- path-io
2929
- random
3030
- safe-exceptions
3131
- sqlite-simple
3232
- store
3333
- tar
34-
- text
34+
- text >= 2.0.1 && < 2.1
3535
- unix
3636
- unliftio
3737

cas/store/src/Data/CAS/ContentStore.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ import qualified Database.SQLite.Simple.FromField as SQL
174174
import qualified Database.SQLite.Simple.ToField as SQL
175175
import GHC.Generics (Generic)
176176
import Path
177-
import Path.IO
177+
import Path.IO hiding (removePathForcibly)
178178
import System.Directory (removePathForcibly)
179179
import System.FilePath (dropTrailingPathSeparator)
180180
import System.IO
@@ -261,7 +261,7 @@ instance Exception StoreError where
261261
++ ". No automatic migration is available, \
262262
\please use a fresh store location."
263263
MalformedMetadataEntry hash key ->
264-
"The metadtaa entry for hash '"
264+
"The metadata entry for hash '"
265265
++ C8.unpack (encodeHash hash)
266266
++ "' under key '"
267267
++ show key
@@ -272,18 +272,18 @@ data ContentStore = ContentStore
272272
{ -- | Root directory of the content store.
273273
-- The process must be able to create this directory if missing,
274274
-- change permissions, and create files and directories within.
275-
storeRoot :: Path Abs Dir,
275+
storeRoot :: !(Path Abs Dir),
276276
-- | Write lock on store metadata to ensure multi thread and process safety.
277277
-- The lock is taken when item state is changed or queried.
278-
storeLock :: Lock,
278+
storeLock :: !Lock,
279279
-- | Used to watch for updates on store items.
280-
storeNotifier :: Notifier,
280+
storeNotifier :: !Notifier,
281281
-- | Connection to the metadata SQLite database.
282-
storeDb :: SQL.Connection
282+
storeDb :: !SQL.Connection
283283
}
284284

285285
-- | A completed item in the 'ContentStore'.
286-
data Item = Item {itemHash :: ContentHash}
286+
newtype Item = Item {itemHash :: ContentHash}
287287
deriving (Eq, Ord, Show, Generic)
288288

289289
instance Monad m => ContentHashable m Item where
@@ -716,13 +716,13 @@ removeAlias store alias =
716716
[":hash" SQL.:= hash]
717717

718718
-- | List all aliases and the respective items.
719-
listAliases :: MonadIO m => ContentStore -> m [(Alias, Item)]
719+
listAliases :: MonadIO m => ContentStore -> m [(Alias, Item, ContentHash)]
720720
listAliases store =
721721
liftIO . withStoreLock store $
722-
fmap (map (second Item)) $
722+
map (\(a,b,c) -> (a, Item b, c)) <$>
723723
SQL.query_
724724
(storeDb store)
725-
"SELECT name, dest FROM aliases"
725+
"SELECT name, dest, hash FROM aliases"
726726

727727
-- | Get all hashes that resulted in the given item.
728728
getBackReferences :: MonadIO m => ContentStore -> Item -> m [ContentHash]

cas/store/test/CAS/ContentStore.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ tests =
301301
testCase "list store contents" $
302302
withEmptyStore $ \store -> do
303303
[a, b, c, d] <- mapM contentHash ["a", "b", "c", "d" :: String]
304-
void $ mapM (ContentStore.markPending store) [a, b, c, d]
304+
mapM_ (ContentStore.markPending store) [a, b, c, d]
305305
mapM_ (ContentStore.markComplete store) [a, b]
306306

307307
(pendings, completes, items) <- ContentStore.listAll store
@@ -341,6 +341,16 @@ tests =
341341

342342
ContentStore.assignAlias store aliasA itemA
343343
ContentStore.assignAlias store aliasB itemB
344+
345+
do
346+
lr <- ContentStore.listAliases store
347+
length lr @?= 2
348+
((\(a,b,c) -> a) <$> lr) @?= [aliasA, aliasB]
349+
((\(_,b,_) -> b) <$> lr) @?= [itemA, itemB]
350+
hashA <- contentHash aliasA
351+
hashB <- contentHash aliasB
352+
((\(_,_,c) -> c) <$> lr) @?= [hashA, hashB]
353+
344354
do
345355
r <- ContentStore.lookupAlias store aliasA
346356
r @?= Just itemA

0 commit comments

Comments
 (0)