[commit: ghc] master: Added missing instances for Identity and Const (#11210) (2dff6c1)

git at git.haskell.org git at git.haskell.org
Mon Dec 21 21:44:13 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/2dff6c184f97fa564c72c73374378a65e12984d8/ghc

>---------------------------------------------------------------

commit 2dff6c184f97fa564c72c73374378a65e12984d8
Author: Shane O'Brien <shane at duairc.com>
Date:   Mon Dec 21 20:25:19 2015 +0100

    Added missing instances for Identity and Const (#11210)
    
    The following instances are added
    
        instance Bounded a => Bounded (Const a b)
        instance Enum a => Enum (Const a b)
        instance Ix a => Ix (Const a b)
        instance Storable a => Storable (Const a b)
    
        instance Bounded a => Bounded (Identity a)
        instance Enum a => Enum (Identity a)
        instance Ix a => Ix (Identity a)
        instance Semigroup a => Semigroup (Identity a)
        instance Storable a => Storable (Identity a)
    
    Reviewers: ekmett, RyanGlScott, rwbarton, hvr, austin, bgamari
    
    Reviewed By: RyanGlScott, hvr
    
    Subscribers: rwbarton, RyanGlScott, thomie
    
    Differential Revision: https://phabricator.haskell.org/D1626
    
    GHC Trac Issues: #11210


>---------------------------------------------------------------

2dff6c184f97fa564c72c73374378a65e12984d8
 libraries/base/Data/Functor/Const.hs    | 6 +++++-
 libraries/base/Data/Functor/Identity.hs | 6 +++++-
 libraries/base/changelog.md             | 6 +++++-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/libraries/base/Data/Functor/Const.hs b/libraries/base/Data/Functor/Const.hs
index 21e6f85..7457951 100644
--- a/libraries/base/Data/Functor/Const.hs
+++ b/libraries/base/Data/Functor/Const.hs
@@ -22,15 +22,19 @@
 module Data.Functor.Const (Const(..)) where
 
 import Data.Foldable (Foldable(foldMap))
+import Foreign.Storable (Storable)
 
+import GHC.Arr (Ix)
 import GHC.Base
+import GHC.Enum (Bounded, Enum)
 import GHC.Generics (Generic, Generic1)
 import GHC.Read (Read(readsPrec), readParen, lex)
 import GHC.Show (Show(showsPrec), showParen, showString)
 
 -- | The 'Const' functor.
 newtype Const a b = Const { getConst :: a }
-                  deriving (Generic, Generic1, Monoid, Eq, Ord)
+                  deriving ( Generic, Generic1, Bounded, Enum, Eq, Ix, Ord
+                           , Monoid, Storable)
 
 -- | This instance would be equivalent to the derived instances of the
 -- 'Const' newtype if the 'runConst' field were removed
diff --git a/libraries/base/Data/Functor/Identity.hs b/libraries/base/Data/Functor/Identity.hs
index 46fb666..df424f2 100644
--- a/libraries/base/Data/Functor/Identity.hs
+++ b/libraries/base/Data/Functor/Identity.hs
@@ -39,13 +39,17 @@ import Control.Monad.Zip
 import Data.Coerce
 import Data.Data (Data)
 import Data.Foldable
+import Data.Ix (Ix)
+import Data.Semigroup (Semigroup)
+import Foreign.Storable (Storable)
 import GHC.Generics (Generic, Generic1)
 
 -- | Identity functor and monad. (a non-strict monad)
 --
 -- @since 4.8.0.0
 newtype Identity a = Identity { runIdentity :: a }
-    deriving (Eq, Ord, Data, Monoid, Traversable, Generic, Generic1)
+    deriving ( Bounded, Enum, Eq, Ix, Ord, Data, Monoid, Semigroup
+             , Storable, Traversable, Generic, Generic1)
 
 -- | This instance would be equivalent to the derived instances of the
 -- 'Identity' newtype if the 'runIdentity' field were removed
diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md
index 96df6bb..a4472df 100644
--- a/libraries/base/changelog.md
+++ b/libraries/base/changelog.md
@@ -24,7 +24,11 @@
 
   * `ZipList` now has `Foldable` and `Traversable` instances
 
-  * `Identity` now has a `Monoid` instance
+  * `Identity` now has `Semigroup` and `Monoid` instances
+
+  * `Identity` and `Const` now have `Bounded`, `Enum` and `Ix` instances
+
+  * `Identity` and `Const` now have `Storable` instances
 
   * `()` now has a `Storable` instance
 



More information about the ghc-commits mailing list