Skip to content

Commit a1871e7

Browse files
committed
fix accessor dropping common stanza map when non it is not required
1 parent f67bf41 commit a1871e7

File tree

1 file changed

+11
-3
lines changed
  • Cabal-syntax/src/Distribution/Types/GenericPackageDescription

1 file changed

+11
-3
lines changed

Cabal-syntax/src/Distribution/Types/GenericPackageDescription/Lens.hs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,24 @@ import Distribution.Version (Version, VersionRange)
4444

4545
type DependencyTree a = CondTree ConfVar [Dependency] a
4646

47+
-- Merging drops commonStanzas!
48+
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49+
--
50+
-- When using an the bidirectional PatternSynonym 'GenericPackageDescription' and its accessors,
51+
-- commonStanzas is filled with mempty.
52+
--
53+
-- When there's no specific reason to use merging pattern accessors, use the internal one!
54+
4755
packageDescription :: Lens' GenericPackageDescription PackageDescription
48-
packageDescription f s = fmap (\x -> s{T.packageDescription = x}) (f (T.packageDescription s))
56+
packageDescription f s = fmap (\x -> s{T.packageDescriptionInternal = x}) (f (T.packageDescriptionInternal s))
4957
{-# INLINE packageDescription #-}
5058

5159
gpdScannedVersion :: Lens' GenericPackageDescription (Maybe Version)
52-
gpdScannedVersion f s = fmap (\x -> s{T.gpdScannedVersion = x}) (f (T.gpdScannedVersion s))
60+
gpdScannedVersion f s = fmap (\x -> s{T.gpdScannedVersionInternal = x}) (f (T.gpdScannedVersionInternal s))
5361
{-# INLINE gpdScannedVersion #-}
5462

5563
genPackageFlags :: Lens' GenericPackageDescription [PackageFlag]
56-
genPackageFlags f s = fmap (\x -> s{T.genPackageFlags = x}) (f (T.genPackageFlags s))
64+
genPackageFlags f s = fmap (\x -> s{T.genPackageFlagsInternal = x}) (f (T.genPackageFlagsInternal s))
5765
{-# INLINE genPackageFlags #-}
5866

5967
gpdCommonStanzas :: Lens' GenericPackageDescription (Map ImportName (DependencyTree (T.WithImports BuildInfo)))

0 commit comments

Comments
 (0)