Skip to content

Remove the Generic instance for LicenseId #8117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cabal-syntax/src/Distribution/SPDX/LicenseId.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
-- This file is generated. See Makefile's spdx rule
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
module Distribution.SPDX.LicenseId (
LicenseId (..),
licenseId,
Expand Down Expand Up @@ -450,7 +449,7 @@ data LicenseId
| ZPL_1_1 -- ^ @ZPL-1.1@, Zope Public License 1.1
| ZPL_2_0 -- ^ @ZPL-2.0@, Zope Public License 2.0
| ZPL_2_1 -- ^ @ZPL-2.1@, Zope Public License 2.1
deriving (Eq, Ord, Enum, Bounded, Show, Read, Typeable, Data, Generic)
deriving (Eq, Ord, Enum, Bounded, Show, Read, Typeable, Data)

instance Binary LicenseId where
-- Word16 is encoded in big endianess
Expand Down
31 changes: 0 additions & 31 deletions Cabal-tests/tests/UnitTests/Distribution/SPDX.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,7 @@ import Test.QuickCheck.Instances.Cabal ()
spdxTests :: [TestTree]
spdxTests =
[ testProperty "LicenseId roundtrip" licenseIdRoundtrip
#if MIN_VERSION_binary(0,7,0)
, testProperty "LicenseId Binary.put" licenseIdBinaryPut
, testProperty "LicenseId Binary.get" licenseIdBinaryGet
#endif
, testProperty "LicenseExceptionId roundtrip" licenseExceptionIdRoundtrip
#if MIN_VERSION_binary(0,7,0)
, testProperty "LicenseExceptionId Binary.put" licenseExceptionIdBinaryPut
, testProperty "LicenseExceptionId Binary.get" licenseExceptionIdBinaryGet
#endif
, testProperty "LicenseRef roundtrip" licenseRefRoundtrip
, testProperty "SimpleLicenseExpression roundtrip" simpleLicenseExpressionRoundtrip
, testProperty "LicenseExpression roundtrip" licenseExpressionRoundtrip
Expand All @@ -46,29 +38,6 @@ licenseIdRoundtrip x =
counterexample (prettyShow x) $
Right x === eitherParsec (prettyShow x)

#if MIN_VERSION_binary(0,7,0)
licenseIdBinaryPut :: LicenseId -> Property
licenseIdBinaryPut x =
Binary.runPut (Binary.put x)
===
Binary.runPut (Binary.gput (from x))

licenseIdBinaryGet :: Word8 -> Word8 -> Property
licenseIdBinaryGet w0 w1 =
stripMsg id (Binary.runGetOrFail Binary.get bs)
===
stripMsg to (Binary.runGetOrFail Binary.gget bs)
where
bs = LBS.pack [w0, w1]

stripMsg
:: (a -> LicenseId)
-> Either (x, y, String) (x, y, a)
-> Either (x, y) (x, y, LicenseId)
stripMsg _ (Left (x,y,_)) = Left (x,y)
stripMsg f (Right (x,y,t)) = Right (x,y,f t)
#endif

licenseExceptionIdRoundtrip :: LicenseExceptionId -> Property
licenseExceptionIdRoundtrip x =
counterexample (prettyShow x) $
Expand Down
11 changes: 11 additions & 0 deletions changelog.d/pr-8117
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
synopsis: Remove the Generic instance of LicenseId
packages: Cabal
prs: #8117
issues: #8074
significance: significant

description: {

- The `Generic` instance of LicenseId is removed, due to the extraordinary amount of memory required to compile
the Generic instances of large sum types in GHC.
}
3 changes: 1 addition & 2 deletions templates/SPDX.LicenseId.template.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
module Distribution.SPDX.LicenseId (
LicenseId (..),
licenseId,
Expand Down Expand Up @@ -35,7 +34,7 @@ import qualified Text.PrettyPrint as Disp
-- | SPDX License identifier
data LicenseId
{{ licenseIds }}
deriving (Eq, Ord, Enum, Bounded, Show, Read, Typeable, Data, Generic)
deriving (Eq, Ord, Enum, Bounded, Show, Read, Typeable, Data)

instance Binary LicenseId where
-- Word16 is encoded in big endianess
Expand Down