Skip to content

Commit

Permalink
Merge #1022: dep: support 'hashable 1.4'
Browse files Browse the repository at this point in the history
At the time, upstream still needed to kowainik/relude#394
  • Loading branch information
Anton-Latukha authored Jan 6, 2022
2 parents 64ba3c7 + 6ad7f3e commit 084766c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/Cabal-Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ jobs:
name: "GHC"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ghc: [ "9.0", "8.8" ]
ghc:
[ "8.8"
, "9.0"
]
steps:

- name: "Git checkout"
Expand All @@ -42,9 +46,9 @@ jobs:
- name: "Repository update"
run: cabal v2-update

# NOTE: Freeze is for the caching
# Freeze is for the caching
- name: "Configuration freeze"
run: cabal v2-freeze $cabalConfig
run: cabal v2-freeze $cabalConfig --minimize-conflict-set

- name: "Configuring GitHub cache"
uses: actions/cache@v2
Expand Down
2 changes: 1 addition & 1 deletion hnix.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ library
, filepath >= 1.4.2 && < 1.5
, free >= 5.1 && < 5.2
, gitrev >= 1.1.0 && < 1.4
, hashable >= 1.2.5 && < 1.4
, hashable >= 1.2.5 && < 1.5
, hashing >= 0.1.0 && < 0.2
, hnix-store-core >= 0.5.0 && < 0.6
, hnix-store-remote >= 0.5.0 && < 0.6
Expand Down
29 changes: 19 additions & 10 deletions src/Nix/Expr/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ data Params r
( Eq, Ord, Generic, Generic1
, Typeable, Data, NFData, NFData1, Serialise, Binary, ToJSON, ToJSON1, FromJSON, FromJSON1
, Functor, Foldable, Traversable
, Show, Hashable, Hashable1
, Show, Hashable
)

instance IsString (Params r) where
Expand All @@ -187,6 +187,8 @@ $(deriveRead1 ''Params)
$(deriveEq1 ''Params)
$(deriveOrd1 ''Params)

deriving instance Hashable1 Params

-- *** lens traversals

$(makeTraversals ''Params)
Expand All @@ -212,14 +214,9 @@ data Antiquoted (v :: Type) (r :: Type)
, Typeable, Data, NFData, NFData1, Serialise, Binary
, ToJSON, ToJSON1, FromJSON, FromJSON1
, Functor, Foldable, Traversable
, Show, Read, Hashable, Hashable1
, Show, Read, Hashable
)

instance Hashable2 Antiquoted where
liftHashWithSalt2 ha _ salt (Plain a) = ha (salt `hashWithSalt` (0 :: Int)) a
liftHashWithSalt2 _ _ salt EscapedNewline = salt `hashWithSalt` (1 :: Int)
liftHashWithSalt2 _ hb salt (Antiquoted b) = hb (salt `hashWithSalt` (2 :: Int)) b

$(deriveShow1 ''Antiquoted)
$(deriveShow2 ''Antiquoted)
$(deriveRead1 ''Antiquoted)
Expand All @@ -230,6 +227,12 @@ $(deriveOrd1 ''Antiquoted)
$(deriveOrd2 ''Antiquoted)
$(deriveJSON2 defaultOptions ''Antiquoted)

instance Hashable2 Antiquoted where
liftHashWithSalt2 ha _ salt (Plain a) = ha (salt `hashWithSalt` (0 :: Int)) a
liftHashWithSalt2 _ _ salt EscapedNewline = salt `hashWithSalt` (1 :: Int)
liftHashWithSalt2 _ hb salt (Antiquoted b) = hb (salt `hashWithSalt` (2 :: Int)) b

deriving instance (Hashable v) => Hashable1 (Antiquoted (v :: Type))

-- *** lens traversals

Expand Down Expand Up @@ -263,7 +266,7 @@ data NString r
( Eq, Ord, Generic, Generic1
, Typeable, Data, NFData, NFData1, Serialise, Binary, ToJSON, ToJSON1, FromJSON, FromJSON1
, Functor, Foldable, Traversable
, Show, Read, Hashable, Hashable1
, Show, Read, Hashable
)

-- | For the the 'IsString' instance, we use a plain doublequoted string.
Expand All @@ -276,6 +279,8 @@ $(deriveRead1 ''NString)
$(deriveEq1 ''NString)
$(deriveOrd1 ''NString)

deriving instance Hashable1 NString

-- *** lens traversals

$(makeTraversals ''NString)
Expand Down Expand Up @@ -423,14 +428,16 @@ data Binding r
( Eq, Ord, Generic, Generic1
, Typeable, Data, NFData, NFData1, Serialise, Binary, ToJSON, FromJSON
, Functor, Foldable, Traversable
, Show, Hashable, Hashable1
, Show, Hashable
)

$(deriveShow1 ''Binding)
$(deriveEq1 ''Binding)
$(deriveOrd1 ''Binding)
--x $(deriveJSON1 defaultOptions ''Binding)

deriving instance Hashable1 Binding

-- *** lens traversals

$(makeTraversals ''Binding)
Expand Down Expand Up @@ -596,7 +603,7 @@ data NExprF r
( Eq, Ord, Generic, Generic1
, Typeable, Data, NFData, NFData1, Serialise, Binary, ToJSON, FromJSON
, Functor, Foldable, Traversable
, Show, Hashable, Hashable1
, Show, Hashable
)


Expand All @@ -605,6 +612,8 @@ $(deriveEq1 ''NExprF)
$(deriveOrd1 ''NExprF)
--x $(deriveJSON1 defaultOptions ''NExprF)

deriving instance Hashable1 NExprF

-- ** lens traversals

$(makeTraversals ''NExprF)
Expand Down
4 changes: 2 additions & 2 deletions src/Nix/Expr/Types/Annotated.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ annUnitToAnn (AnnUnit ann a) = Ann ann a

-- ** Instances

instance Hashable ann => Hashable1 (AnnUnit ann)

instance NFData ann => NFData1 (AnnUnit ann)

instance (Binary ann, Binary a) => Binary (AnnUnit ann a)
Expand All @@ -128,6 +126,8 @@ $(deriveShow2 ''AnnUnit)
$(deriveJSON1 defaultOptions ''AnnUnit)
$(deriveJSON2 defaultOptions ''AnnUnit)

instance Hashable ann => Hashable1 (AnnUnit ann)

instance (Serialise ann, Serialise a) => Serialise (AnnUnit ann a)

-- ** @NExprLoc{,F}@ - annotated Nix expression
Expand Down

0 comments on commit 084766c

Please sign in to comment.