Commit 2dff6c18 authored by duairc's avatar duairc Committed by Ben Gamari
Browse files

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
parent ff3f918d
......@@ -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
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment