ghc-internal-9.1001.0: Basic libraries
Copyright(c) Andy Gill 2001
(c) Oregon Graduate Institute of Science and Technology 2001
LicenseBSD-style (see the file LICENSE)
Maintainerross@soi.city.ac.uk
Stabilitystable
Portabilityportable
Safe HaskellTrustworthy
LanguageHaskell2010

GHC.Internal.Data.Functor.Identity

Description

The identity functor and monad.

This trivial type constructor serves two purposes:

  • It can be used with functions parameterized by functor or monad classes.
  • It can be used as a base monad to which a series of monad transformers may be applied to construct a composite monad. Most monad transformer modules include the special case of applying the transformer to Identity. For example, State s is an abbreviation for StateT s Identity.

@since base-4.8.0.0

Synopsis

Documentation

newtype Identity a Source #

Identity functor and monad. (a non-strict monad)

Examples

Expand
>>> fmap (+1) (Identity 0)
Identity 1
>>> Identity [1, 2, 3] <> Identity [4, 5, 6]
Identity [1,2,3,4,5,6]
>>> do
      x <- Identity 10
      y <- Identity (x + 5)
      pure (x + y)
Identity 25

@since base-4.8.0.0

Constructors

Identity 

Fields

Instances

Instances details
Applicative Identity Source #

@since base-4.8.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Methods

pure :: a -> Identity a Source #

(<*>) :: Identity (a -> b) -> Identity a -> Identity b Source #

liftA2 :: (a -> b -> c) -> Identity a -> Identity b -> Identity c Source #

(*>) :: Identity a -> Identity b -> Identity b Source #

(<*) :: Identity a -> Identity b -> Identity a Source #

Functor Identity Source #

@since base-4.8.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Methods

fmap :: (a -> b) -> Identity a -> Identity b Source #

(<$) :: a -> Identity b -> Identity a Source #

Monad Identity Source #

@since base-4.8.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Methods

(>>=) :: Identity a -> (a -> Identity b) -> Identity b Source #

(>>) :: Identity a -> Identity b -> Identity b Source #

return :: a -> Identity a Source #

MonadFix Identity Source #

@since base-4.8.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Methods

mfix :: (a -> Identity a) -> Identity a Source #

Foldable Identity Source #

@since base-4.8.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Methods

fold :: Monoid m => Identity m -> m Source #

foldMap :: Monoid m => (a -> m) -> Identity a -> m Source #

foldMap' :: Monoid m => (a -> m) -> Identity a -> m Source #

foldr :: (a -> b -> b) -> b -> Identity a -> b Source #

foldr' :: (a -> b -> b) -> b -> Identity a -> b Source #

foldl :: (b -> a -> b) -> b -> Identity a -> b Source #

foldl' :: (b -> a -> b) -> b -> Identity a -> b Source #

foldr1 :: (a -> a -> a) -> Identity a -> a Source #

foldl1 :: (a -> a -> a) -> Identity a -> a Source #

toList :: Identity a -> [a] Source #

null :: Identity a -> Bool Source #

length :: Identity a -> Int Source #

elem :: Eq a => a -> Identity a -> Bool Source #

maximum :: Ord a => Identity a -> a Source #

minimum :: Ord a => Identity a -> a Source #

sum :: Num a => Identity a -> a Source #

product :: Num a => Identity a -> a Source #

Traversable Identity Source #

@since base-4.9.0.0

Instance details

Defined in GHC.Internal.Data.Traversable

Methods

traverse :: Applicative f => (a -> f b) -> Identity a -> f (Identity b) Source #

sequenceA :: Applicative f => Identity (f a) -> f (Identity a) Source #

mapM :: Monad m => (a -> m b) -> Identity a -> m (Identity b) Source #

sequence :: Monad m => Identity (m a) -> m (Identity a) Source #

Generic1 Identity Source # 
Instance details

Defined in GHC.Internal.Data.Functor.Identity

Associated Types

type Rep1 Identity

@since base-4.8.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

type Rep1 Identity = D1 ('MetaData "Identity" "GHC.Internal.Data.Functor.Identity" "ghc-internal" 'True) (C1 ('MetaCons "Identity" 'PrefixI 'True) (S1 ('MetaSel ('Just "runIdentity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
Monoid a => Monoid (Identity a) Source #

@since base-4.9.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Semigroup a => Semigroup (Identity a) Source #

@since base-4.9.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Bits a => Bits (Identity a) Source #

@since base-4.9.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

FiniteBits a => FiniteBits (Identity a) Source #

@since base-4.9.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Data a => Data (Identity a) Source #

@since base-4.9.0.0

Instance details

Defined in GHC.Internal.Data.Data

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Identity a -> c (Identity a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Identity a) Source #

toConstr :: Identity a -> Constr Source #

dataTypeOf :: Identity a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Identity a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Identity a)) Source #

gmapT :: (forall b. Data b => b -> b) -> Identity a -> Identity a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Identity a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Identity a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Identity a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Identity a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Identity a -> m (Identity a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Identity a -> m (Identity a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Identity a -> m (Identity a) Source #

IsString a => IsString (Identity a) Source #

@since base-4.9.0.0

Instance details

Defined in GHC.Internal.Data.String

Bounded a => Bounded (Identity a) Source #

@since base-4.9.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Enum a => Enum (Identity a) Source #

@since base-4.9.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Floating a => Floating (Identity a) Source #

@since base-4.9.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

RealFloat a => RealFloat (Identity a) Source #

@since base-4.9.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Storable a => Storable (Identity a) Source #

@since base-4.9.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Generic (Identity a) Source # 
Instance details

Defined in GHC.Internal.Data.Functor.Identity

Associated Types

type Rep (Identity a)

@since base-4.8.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

type Rep (Identity a) = D1 ('MetaData "Identity" "GHC.Internal.Data.Functor.Identity" "ghc-internal" 'True) (C1 ('MetaCons "Identity" 'PrefixI 'True) (S1 ('MetaSel ('Just "runIdentity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Methods

from :: Identity a -> Rep (Identity a) x Source #

to :: Rep (Identity a) x -> Identity a Source #

Ix a => Ix (Identity a) Source #

@since base-4.9.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Num a => Num (Identity a) Source #

@since base-4.9.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Read a => Read (Identity a) Source #

This instance would be equivalent to the derived instances of the Identity newtype if the runIdentity field were removed

@since base-4.8.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Fractional a => Fractional (Identity a) Source #

@since base-4.9.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Integral a => Integral (Identity a) Source #

@since base-4.9.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Real a => Real (Identity a) Source #

@since base-4.9.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

RealFrac a => RealFrac (Identity a) Source #

@since base-4.9.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Methods

properFraction :: Integral b => Identity a -> (b, Identity a) Source #

truncate :: Integral b => Identity a -> b Source #

round :: Integral b => Identity a -> b Source #

ceiling :: Integral b => Identity a -> b Source #

floor :: Integral b => Identity a -> b Source #

Show a => Show (Identity a) Source #

This instance would be equivalent to the derived instances of the Identity newtype if the runIdentity field were removed

@since base-4.8.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Eq a => Eq (Identity a) Source #

@since base-4.8.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

Methods

(==) :: Identity a -> Identity a -> Bool Source #

(/=) :: Identity a -> Identity a -> Bool Source #

Ord a => Ord (Identity a) Source #

@since base-4.8.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

type Rep1 Identity Source #

@since base-4.8.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

type Rep1 Identity = D1 ('MetaData "Identity" "GHC.Internal.Data.Functor.Identity" "ghc-internal" 'True) (C1 ('MetaCons "Identity" 'PrefixI 'True) (S1 ('MetaSel ('Just "runIdentity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1))
type Rep (Identity a) Source #

@since base-4.8.0.0

Instance details

Defined in GHC.Internal.Data.Functor.Identity

type Rep (Identity a) = D1 ('MetaData "Identity" "GHC.Internal.Data.Functor.Identity" "ghc-internal" 'True) (C1 ('MetaCons "Identity" 'PrefixI 'True) (S1 ('MetaSel ('Just "runIdentity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))