Skip to content

Commit 496fb32

Browse files
committed
make DerivationOutput explicitely generic
It is already parametrized, but `name` field is too specific to accommodate i.e. `DerivationOutput StorePath` which is used by `Derivation` type. So we call it `output` instead and turn the type variable to just `a`. So * for `Realisation`s this is `DerivationOutput OutputName` * for `Derivation`s this is `DerivatonOutput StorePath` * for content addressed derivations this might be `DerivationOutput Void` as the path isn't known ahead of time. So only its shape is important. Related to Gabriella439/Haskell-Nix-Derivation-Library#24
1 parent e6d21c1 commit 496fb32

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

hnix-store-core/src/System/Nix/Realisation.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ import qualified Data.Text.Lazy.Builder
2828
import qualified System.Nix.Hash
2929

3030
-- | Output of the derivation
31-
data DerivationOutput outputName = DerivationOutput
31+
data DerivationOutput a = DerivationOutput
3232
{ derivationOutputHash :: DSum HashAlgo Digest
3333
-- ^ Hash modulo of the derivation
34-
, derivationOutputName :: outputName
35-
-- ^ Name of the output
34+
, derivationOutputOutput :: a
35+
-- ^ Output (either a OutputName or StorePatH)
3636
} deriving (Eq, Generic, Ord, Show)
3737

3838
data DerivationOutputError
@@ -74,7 +74,7 @@ derivationOutputBuilder
7474
derivationOutputBuilder outputName DerivationOutput{..} =
7575
System.Nix.Hash.algoDigestBuilder derivationOutputHash
7676
<> Data.Text.Lazy.Builder.singleton '!'
77-
<> Data.Text.Lazy.Builder.fromText (outputName derivationOutputName)
77+
<> Data.Text.Lazy.Builder.fromText (outputName derivationOutputOutput)
7878

7979
-- | Build realisation context
8080
--

hnix-store-json/tests/JSONSpec.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ sampleDerivationOutput = DerivationOutput
3838
$ System.Nix.Hash.mkNamedDigest
3939
"sha256"
4040
"1b4sb93wp679q4zx9k1ignby1yna3z7c4c2ri3wphylbc2dwsys0"
41-
, derivationOutputName =
41+
, derivationOutputOutput =
4242
forceRight
4343
$ System.Nix.OutputName.mkOutputName "foo"
4444
}

0 commit comments

Comments
 (0)