diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2015-02-22 15:21:18 +0100 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2015-02-22 15:45:39 +0100 |
commit | 1f60d635cee1ff3db72e0129f9035b147f52c9c4 (patch) | |
tree | 10da3b5fbdc680361be86c7223e699289ecbb133 /libraries/base/Data/Functor/Identity.hs | |
parent | d4b645337d2d1a2fb4cfbbef0e5a160c5384f792 (diff) | |
download | haskell-1f60d635cee1ff3db72e0129f9035b147f52c9c4.tar.gz |
{Data,Generic(1),MonadZip} instances for Identity
These instances were missed when the identity functor was added to
the `base` package (re #9664).
Reviewed By: ekmett
Differential Revision: https://phabricator.haskell.org/D674
Diffstat (limited to 'libraries/base/Data/Functor/Identity.hs')
-rw-r--r-- | libraries/base/Data/Functor/Identity.hs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libraries/base/Data/Functor/Identity.hs b/libraries/base/Data/Functor/Identity.hs index 2465a1ee7d..ac47922aef 100644 --- a/libraries/base/Data/Functor/Identity.hs +++ b/libraries/base/Data/Functor/Identity.hs @@ -1,6 +1,7 @@ -{-# LANGUAGE Trustworthy #-} {-# LANGUAGE AutoDeriveTypeable #-} +{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveTraversable #-} +{-# LANGUAGE Trustworthy #-} ----------------------------------------------------------------------------- -- | @@ -33,14 +34,17 @@ module Data.Functor.Identity ( ) where import Control.Monad.Fix +import Control.Monad.Zip import Data.Coerce +import Data.Data (Data) import Data.Foldable +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, Traversable) + deriving (Eq, Ord, Data, Traversable, Generic, Generic1) -- | This instance would be equivalent to the derived instances of the -- 'Identity' newtype if the 'runIdentity' field were removed @@ -89,6 +93,9 @@ instance Monad Identity where instance MonadFix Identity where mfix f = Identity (fix (runIdentity . f)) +instance MonadZip Identity where + mzipWith = coerce + munzip = coerce -- | Internal (non-exported) 'Coercible' helper for 'elem' -- |