diff options
author | Ben Gamari <ben@smart-cactus.org> | 2015-04-03 00:48:51 -0500 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2015-04-03 00:48:56 -0500 |
commit | 3541f736486d08df36863fd8e29deb1ca637a498 (patch) | |
tree | a8800dacca6f3a3012f4edf1fcdb8ac9580bbd4e | |
parent | 012ea0b96cc041bced4565d74bef7ccb75f1af0d (diff) | |
download | haskell-3541f736486d08df36863fd8e29deb1ca637a498.tar.gz |
Data.Complex: Derive Generic
Reviewed By: hvr, austin
Differential Revision: https://phabricator.haskell.org/D770
-rw-r--r-- | libraries/base/Data/Complex.hs | 4 | ||||
-rw-r--r-- | libraries/base/changelog.md | 1 | ||||
-rw-r--r-- | testsuite/tests/generics/T5884.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/generics/T5884Other.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/generics/all.T | 3 |
5 files changed, 11 insertions, 5 deletions
diff --git a/libraries/base/Data/Complex.hs b/libraries/base/Data/Complex.hs index 88aa597db4..c6420cdcb2 100644 --- a/libraries/base/Data/Complex.hs +++ b/libraries/base/Data/Complex.hs @@ -1,6 +1,7 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE Trustworthy #-} {-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE DeriveGeneric #-} ----------------------------------------------------------------------------- -- | @@ -34,6 +35,7 @@ module Data.Complex ) where +import GHC.Generics (Generic) import Data.Data (Data) import Foreign (Storable, castPtr, peek, poke, pokeElemOff, peekElemOff, sizeOf, alignment) @@ -51,7 +53,7 @@ infix 6 :+ data Complex a = !a :+ !a -- ^ forms a complex number from its real and imaginary -- rectangular components. - deriving (Eq, Show, Read, Data) + deriving (Eq, Show, Read, Data, Generic) -- ----------------------------------------------------------------------------- -- Functions over Complex diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md index f4021892c0..ea509af2e2 100644 --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -29,6 +29,7 @@ * New `GHC.Stack.CallStack` data type + * `Complex` now has a `Generic` instance ## 4.8.0.0 *Mar 2015* diff --git a/testsuite/tests/generics/T5884.hs b/testsuite/tests/generics/T5884.hs index 6dfad25581..92b5087967 100644 --- a/testsuite/tests/generics/T5884.hs +++ b/testsuite/tests/generics/T5884.hs @@ -3,7 +3,6 @@ module T5884 where import GHC.Generics +import T5884Other -import Data.Complex - -deriving instance Generic (Complex v) +deriving instance Generic (Pair a) diff --git a/testsuite/tests/generics/T5884Other.hs b/testsuite/tests/generics/T5884Other.hs new file mode 100644 index 0000000000..2cf8250162 --- /dev/null +++ b/testsuite/tests/generics/T5884Other.hs @@ -0,0 +1,3 @@ +module T5884Other where + +data Pair a = Pair a a diff --git a/testsuite/tests/generics/all.T b/testsuite/tests/generics/all.T index c51de18a9c..98116ec519 100644 --- a/testsuite/tests/generics/all.T +++ b/testsuite/tests/generics/all.T @@ -26,7 +26,8 @@ test('T5462Yes2', extra_clean(['T5462Yes2/GFunctor.hi']) test('T5462No1', extra_clean(['T5462No1/GFunctor.hi']) , multimod_compile_fail, ['T5462No1', '-iGFunctor -outputdir=T5462No1']) -test('T5884', normal, compile, ['']) +test('T5884', extra_clean(['T5884Other.o', 'T5884Other.hi']) + , multimod_compile, ['T5884Other', '-v0']) test('GenNewtype', normal, compile_and_run, ['']) test('GenDerivOutput1_0', normal, compile, ['-dsuppress-uniques']) |