| Copyright | (c) Andy Gill 2001 (c) Oregon Graduate Institute of Science and Technology 2001 |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | ross@soi.city.ac.uk |
| Stability | stable |
| Portability | portable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
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 sis an abbreviation forStateT s.Identity
Since: base-4.8.0.0
Synopsis
- newtype Identity a = Identity {
- runIdentity :: a
Documentation
Identity functor and monad. (a non-strict monad)
Examples
>>>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
| Foldable1 Identity Source # | Since: base-4.18.0.0 |
Defined in Data.Foldable1 Methods fold1 :: Semigroup m => Identity m -> m Source # foldMap1 :: Semigroup m => (a -> m) -> Identity a -> m Source # foldMap1' :: Semigroup m => (a -> m) -> Identity a -> m Source # toNonEmpty :: Identity a -> NonEmpty a Source # maximum :: Ord a => Identity a -> a Source # minimum :: Ord a => Identity a -> a Source # head :: Identity a -> a Source # last :: Identity a -> a Source # foldrMap1 :: (a -> b) -> (a -> b -> b) -> Identity a -> b Source # foldlMap1' :: (a -> b) -> (b -> a -> b) -> Identity a -> b Source # foldlMap1 :: (a -> b) -> (b -> a -> b) -> Identity a -> b Source # foldrMap1' :: (a -> b) -> (a -> b -> b) -> Identity a -> b Source # | |
| Eq1 Identity Source # | Since: base-4.9.0.0 |
| Ord1 Identity Source # | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes | |
| Read1 Identity Source # | Since: base-4.9.0.0 |
Defined in Data.Functor.Classes Methods liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Identity a) Source # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Identity a] Source # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Identity a) Source # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Identity a] Source # | |
| Show1 Identity Source # | Since: base-4.9.0.0 |
| Applicative Identity Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Data.Functor.Identity | |
| Functor Identity Source # | Since: base-4.8.0.0 |
| Monad Identity Source # | Since: base-4.8.0.0 |
| MonadFix Identity Source # | Since: base-4.8.0.0 |
| MonadZip Identity Source # | Since: ghc-internal-4.8.0.0 |
| Foldable Identity Source # | Since: base-4.8.0.0 |
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 # | |
| Traversable Identity Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Traversable | |
| Generic1 Identity Source # | |
| Monoid a => Monoid (Identity a) Source # | Since: base-4.9.0.0 |
| Semigroup a => Semigroup (Identity a) Source # | Since: base-4.9.0.0 |
| Bits a => Bits (Identity a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Identity Methods (.&.) :: Identity a -> Identity a -> Identity a Source # (.|.) :: Identity a -> Identity a -> Identity a Source # xor :: Identity a -> Identity a -> Identity a Source # complement :: Identity a -> Identity a Source # shift :: Identity a -> Int -> Identity a Source # rotate :: Identity a -> Int -> Identity a Source # zeroBits :: Identity a Source # bit :: Int -> Identity a Source # setBit :: Identity a -> Int -> Identity a Source # clearBit :: Identity a -> Int -> Identity a Source # complementBit :: Identity a -> Int -> Identity a Source # testBit :: Identity a -> Int -> Bool Source # bitSizeMaybe :: Identity a -> Maybe Int Source # bitSize :: Identity a -> Int Source # isSigned :: Identity a -> Bool Source # shiftL :: Identity a -> Int -> Identity a Source # unsafeShiftL :: Identity a -> Int -> Identity a Source # shiftR :: Identity a -> Int -> Identity a Source # unsafeShiftR :: Identity a -> Int -> Identity a Source # rotateL :: Identity a -> Int -> Identity a Source # | |
| FiniteBits a => FiniteBits (Identity a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Identity Methods finiteBitSize :: Identity a -> Int Source # countLeadingZeros :: Identity a -> Int Source # countTrailingZeros :: Identity a -> Int Source # | |
| Eq a => Eq (Identity a) Source # | Since: base-4.8.0.0 |
| Ord a => Ord (Identity a) Source # | Since: base-4.8.0.0 |
Defined in GHC.Internal.Data.Functor.Identity Methods compare :: Identity a -> Identity a -> Ordering Source # (<) :: Identity a -> Identity a -> Bool Source # (<=) :: Identity a -> Identity a -> Bool Source # (>) :: Identity a -> Identity a -> Bool Source # (>=) :: Identity a -> Identity a -> Bool Source # | |
| Data a => Data (Identity a) Source # | Since: base-4.9.0.0 |
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 |
Defined in GHC.Internal.Data.String Methods fromString :: String -> Identity a Source # | |
| Bounded a => Bounded (Identity a) Source # | Since: base-4.9.0.0 |
| Enum a => Enum (Identity a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Identity Methods succ :: Identity a -> Identity a Source # pred :: Identity a -> Identity a Source # toEnum :: Int -> Identity a Source # fromEnum :: Identity a -> Int Source # enumFrom :: Identity a -> [Identity a] Source # enumFromThen :: Identity a -> Identity a -> [Identity a] Source # enumFromTo :: Identity a -> Identity a -> [Identity a] Source # enumFromThenTo :: Identity a -> Identity a -> Identity a -> [Identity a] Source # | |
| Floating a => Floating (Identity a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Identity Methods exp :: Identity a -> Identity a Source # log :: Identity a -> Identity a Source # sqrt :: Identity a -> Identity a Source # (**) :: Identity a -> Identity a -> Identity a Source # logBase :: Identity a -> Identity a -> Identity a Source # sin :: Identity a -> Identity a Source # cos :: Identity a -> Identity a Source # tan :: Identity a -> Identity a Source # asin :: Identity a -> Identity a Source # acos :: Identity a -> Identity a Source # atan :: Identity a -> Identity a Source # sinh :: Identity a -> Identity a Source # cosh :: Identity a -> Identity a Source # tanh :: Identity a -> Identity a Source # asinh :: Identity a -> Identity a Source # acosh :: Identity a -> Identity a Source # atanh :: Identity a -> Identity a Source # log1p :: Identity a -> Identity a Source # expm1 :: Identity a -> Identity a Source # | |
| RealFloat a => RealFloat (Identity a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Identity Methods floatRadix :: Identity a -> Integer Source # floatDigits :: Identity a -> Int Source # floatRange :: Identity a -> (Int, Int) Source # decodeFloat :: Identity a -> (Integer, Int) Source # encodeFloat :: Integer -> Int -> Identity a Source # exponent :: Identity a -> Int Source # significand :: Identity a -> Identity a Source # scaleFloat :: Int -> Identity a -> Identity a Source # isNaN :: Identity a -> Bool Source # isInfinite :: Identity a -> Bool Source # isDenormalized :: Identity a -> Bool Source # isNegativeZero :: Identity a -> Bool Source # | |
| Storable a => Storable (Identity a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Identity Methods sizeOf :: Identity a -> Int Source # alignment :: Identity a -> Int Source # peekElemOff :: Ptr (Identity a) -> Int -> IO (Identity a) Source # pokeElemOff :: Ptr (Identity a) -> Int -> Identity a -> IO () Source # peekByteOff :: Ptr b -> Int -> IO (Identity a) Source # pokeByteOff :: Ptr b -> Int -> Identity a -> IO () Source # | |
| Generic (Identity a) Source # | |
| Ix a => Ix (Identity a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Identity Methods range :: (Identity a, Identity a) -> [Identity a] Source # index :: (Identity a, Identity a) -> Identity a -> Int Source # unsafeIndex :: (Identity a, Identity a) -> Identity a -> Int Source # inRange :: (Identity a, Identity a) -> Identity a -> Bool Source # rangeSize :: (Identity a, Identity a) -> Int Source # unsafeRangeSize :: (Identity a, Identity a) -> Int Source # | |
| Num a => Num (Identity a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Identity Methods (+) :: Identity a -> Identity a -> Identity a Source # (-) :: Identity a -> Identity a -> Identity a Source # (*) :: Identity a -> Identity a -> Identity a Source # negate :: Identity a -> Identity a Source # abs :: Identity a -> Identity a Source # signum :: Identity a -> Identity a Source # fromInteger :: Integer -> Identity a Source # | |
| Read a => Read (Identity a) Source # | This instance would be equivalent to the derived instances of the
Since: base-4.8.0.0 |
| Fractional a => Fractional (Identity a) Source # | Since: base-4.9.0.0 |
| Integral a => Integral (Identity a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Identity Methods quot :: Identity a -> Identity a -> Identity a Source # rem :: Identity a -> Identity a -> Identity a Source # div :: Identity a -> Identity a -> Identity a Source # mod :: Identity a -> Identity a -> Identity a Source # quotRem :: Identity a -> Identity a -> (Identity a, Identity a) Source # divMod :: Identity a -> Identity a -> (Identity a, Identity a) Source # | |
| Real a => Real (Identity a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Identity Methods toRational :: Identity a -> Rational Source # | |
| RealFrac a => RealFrac (Identity a) Source # | Since: base-4.9.0.0 |
Defined in GHC.Internal.Data.Functor.Identity | |
| Show a => Show (Identity a) Source # | This instance would be equivalent to the derived instances of the
Since: base-4.8.0.0 |
| type Rep1 Identity Source # | Since: base-4.8.0.0 |
| type Rep (Identity a) Source # | Since: base-4.8.0.0 |