{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE Trustworthy #-}

-----------------------------------------------------------------------------
-- |
-- Module      :  Data.Functor.Identity
-- 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
--
-- 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 4.8.0.0
-----------------------------------------------------------------------------

module Data.Functor.Identity (
    Identity(..),
  ) where

import Control.Monad.Fix
import Data.Bits (Bits, FiniteBits)
import Data.Coerce
import Data.Foldable
import Data.Functor.Utils ((#.))
import Foreign.Storable (Storable)
import GHC.Ix (Ix)
import GHC.Base ( Applicative(..), Eq(..), Functor(..), Monad(..)
                , Semigroup, Monoid, Ord(..), ($), (.) )
import GHC.Enum (Bounded, Enum)
import GHC.Float (Floating, RealFloat)
import GHC.Generics (Generic, Generic1)
import GHC.Num (Num)
import GHC.Read (Read(..), lex, readParen)
import GHC.Real (Fractional, Integral, Real, RealFrac)
import GHC.Show (Show(..), showParen, showString)
import GHC.Types (Bool(..))

-- | Identity functor and monad. (a non-strict monad)
--
-- @since 4.8.0.0
newtype Identity a = Identity { forall a. Identity a -> a
runIdentity :: a }
    deriving ( Eq (Identity a)
Identity a
Eq (Identity a)
-> (Identity a -> Identity a -> Identity a)
-> (Identity a -> Identity a -> Identity a)
-> (Identity a -> Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Int -> Identity a)
-> (Identity a -> Int -> Identity a)
-> Identity a
-> (Int -> Identity a)
-> (Identity a -> Int -> Identity a)
-> (Identity a -> Int -> Identity a)
-> (Identity a -> Int -> Identity a)
-> (Identity a -> Int -> Bool)
-> (Identity a -> Maybe Int)
-> (Identity a -> Int)
-> (Identity a -> Bool)
-> (Identity a -> Int -> Identity a)
-> (Identity a -> Int -> Identity a)
-> (Identity a -> Int -> Identity a)
-> (Identity a -> Int -> Identity a)
-> (Identity a -> Int -> Identity a)
-> (Identity a -> Int -> Identity a)
-> (Identity a -> Int)
-> Bits (Identity a)
Int -> Identity a
Identity a -> Bool
Identity a -> Int
Identity a -> Maybe Int
Identity a -> Identity a
Identity a -> Int -> Bool
Identity a -> Int -> Identity a
Identity a -> Identity a -> Identity a
forall a.
Eq a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
forall {a}. Bits a => Eq (Identity a)
forall a. Bits a => Identity a
forall a. Bits a => Int -> Identity a
forall a. Bits a => Identity a -> Bool
forall a. Bits a => Identity a -> Int
forall a. Bits a => Identity a -> Maybe Int
forall a. Bits a => Identity a -> Identity a
forall a. Bits a => Identity a -> Int -> Bool
forall a. Bits a => Identity a -> Int -> Identity a
forall a. Bits a => Identity a -> Identity a -> Identity a
$c.&. :: forall a. Bits a => Identity a -> Identity a -> Identity a
.&. :: Identity a -> Identity a -> Identity a
$c.|. :: forall a. Bits a => Identity a -> Identity a -> Identity a
.|. :: Identity a -> Identity a -> Identity a
$cxor :: forall a. Bits a => Identity a -> Identity a -> Identity a
xor :: Identity a -> Identity a -> Identity a
$ccomplement :: forall a. Bits a => Identity a -> Identity a
complement :: Identity a -> Identity a
$cshift :: forall a. Bits a => Identity a -> Int -> Identity a
shift :: Identity a -> Int -> Identity a
$crotate :: forall a. Bits a => Identity a -> Int -> Identity a
rotate :: Identity a -> Int -> Identity a
$czeroBits :: forall a. Bits a => Identity a
zeroBits :: Identity a
$cbit :: forall a. Bits a => Int -> Identity a
bit :: Int -> Identity a
$csetBit :: forall a. Bits a => Identity a -> Int -> Identity a
setBit :: Identity a -> Int -> Identity a
$cclearBit :: forall a. Bits a => Identity a -> Int -> Identity a
clearBit :: Identity a -> Int -> Identity a
$ccomplementBit :: forall a. Bits a => Identity a -> Int -> Identity a
complementBit :: Identity a -> Int -> Identity a
$ctestBit :: forall a. Bits a => Identity a -> Int -> Bool
testBit :: Identity a -> Int -> Bool
$cbitSizeMaybe :: forall a. Bits a => Identity a -> Maybe Int
bitSizeMaybe :: Identity a -> Maybe Int
$cbitSize :: forall a. Bits a => Identity a -> Int
bitSize :: Identity a -> Int
$cisSigned :: forall a. Bits a => Identity a -> Bool
isSigned :: Identity a -> Bool
$cshiftL :: forall a. Bits a => Identity a -> Int -> Identity a
shiftL :: Identity a -> Int -> Identity a
$cunsafeShiftL :: forall a. Bits a => Identity a -> Int -> Identity a
unsafeShiftL :: Identity a -> Int -> Identity a
$cshiftR :: forall a. Bits a => Identity a -> Int -> Identity a
shiftR :: Identity a -> Int -> Identity a
$cunsafeShiftR :: forall a. Bits a => Identity a -> Int -> Identity a
unsafeShiftR :: Identity a -> Int -> Identity a
$crotateL :: forall a. Bits a => Identity a -> Int -> Identity a
rotateL :: Identity a -> Int -> Identity a
$crotateR :: forall a. Bits a => Identity a -> Int -> Identity a
rotateR :: Identity a -> Int -> Identity a
$cpopCount :: forall a. Bits a => Identity a -> Int
popCount :: Identity a -> Int
Bits       -- ^ @since 4.9.0.0
             , Identity a
Identity a -> Identity a -> Bounded (Identity a)
forall a. a -> a -> Bounded a
forall a. Bounded a => Identity a
$cminBound :: forall a. Bounded a => Identity a
minBound :: Identity a
$cmaxBound :: forall a. Bounded a => Identity a
maxBound :: Identity a
Bounded    -- ^ @since 4.9.0.0
             , Int -> Identity a
Identity a -> Int
Identity a -> [Identity a]
Identity a -> Identity a
Identity a -> Identity a -> [Identity a]
Identity a -> Identity a -> Identity a -> [Identity a]
(Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Int -> Identity a)
-> (Identity a -> Int)
-> (Identity a -> [Identity a])
-> (Identity a -> Identity a -> [Identity a])
-> (Identity a -> Identity a -> [Identity a])
-> (Identity a -> Identity a -> Identity a -> [Identity a])
-> Enum (Identity a)
forall a. Enum a => Int -> Identity a
forall a. Enum a => Identity a -> Int
forall a. Enum a => Identity a -> [Identity a]
forall a. Enum a => Identity a -> Identity a
forall a. Enum a => Identity a -> Identity a -> [Identity a]
forall a.
Enum a =>
Identity a -> Identity a -> Identity a -> [Identity a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: forall a. Enum a => Identity a -> Identity a
succ :: Identity a -> Identity a
$cpred :: forall a. Enum a => Identity a -> Identity a
pred :: Identity a -> Identity a
$ctoEnum :: forall a. Enum a => Int -> Identity a
toEnum :: Int -> Identity a
$cfromEnum :: forall a. Enum a => Identity a -> Int
fromEnum :: Identity a -> Int
$cenumFrom :: forall a. Enum a => Identity a -> [Identity a]
enumFrom :: Identity a -> [Identity a]
$cenumFromThen :: forall a. Enum a => Identity a -> Identity a -> [Identity a]
enumFromThen :: Identity a -> Identity a -> [Identity a]
$cenumFromTo :: forall a. Enum a => Identity a -> Identity a -> [Identity a]
enumFromTo :: Identity a -> Identity a -> [Identity a]
$cenumFromThenTo :: forall a.
Enum a =>
Identity a -> Identity a -> Identity a -> [Identity a]
enumFromThenTo :: Identity a -> Identity a -> Identity a -> [Identity a]
Enum       -- ^ @since 4.9.0.0
             , Identity a -> Identity a -> Bool
(Identity a -> Identity a -> Bool)
-> (Identity a -> Identity a -> Bool) -> Eq (Identity a)
forall a. Eq a => Identity a -> Identity a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => Identity a -> Identity a -> Bool
== :: Identity a -> Identity a -> Bool
$c/= :: forall a. Eq a => Identity a -> Identity a -> Bool
/= :: Identity a -> Identity a -> Bool
Eq         -- ^ @since 4.8.0.0
             , Bits (Identity a)
Bits (Identity a)
-> (Identity a -> Int)
-> (Identity a -> Int)
-> (Identity a -> Int)
-> FiniteBits (Identity a)
Identity a -> Int
forall {a}. FiniteBits a => Bits (Identity a)
forall a. FiniteBits a => Identity a -> Int
forall b.
Bits b -> (b -> Int) -> (b -> Int) -> (b -> Int) -> FiniteBits b
$cfiniteBitSize :: forall a. FiniteBits a => Identity a -> Int
finiteBitSize :: Identity a -> Int
$ccountLeadingZeros :: forall a. FiniteBits a => Identity a -> Int
countLeadingZeros :: Identity a -> Int
$ccountTrailingZeros :: forall a. FiniteBits a => Identity a -> Int
countTrailingZeros :: Identity a -> Int
FiniteBits -- ^ @since 4.9.0.0
             , Fractional (Identity a)
Identity a
Fractional (Identity a)
-> Identity a
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a -> Identity a)
-> (Identity a -> Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> Floating (Identity a)
Identity a -> Identity a
Identity a -> Identity a -> Identity a
forall {a}. Floating a => Fractional (Identity a)
forall a. Floating a => Identity a
forall a. Floating a => Identity a -> Identity a
forall a. Floating a => Identity a -> Identity a -> Identity a
forall a.
Fractional a
-> a
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> Floating a
$cpi :: forall a. Floating a => Identity a
pi :: Identity a
$cexp :: forall a. Floating a => Identity a -> Identity a
exp :: Identity a -> Identity a
$clog :: forall a. Floating a => Identity a -> Identity a
log :: Identity a -> Identity a
$csqrt :: forall a. Floating a => Identity a -> Identity a
sqrt :: Identity a -> Identity a
$c** :: forall a. Floating a => Identity a -> Identity a -> Identity a
** :: Identity a -> Identity a -> Identity a
$clogBase :: forall a. Floating a => Identity a -> Identity a -> Identity a
logBase :: Identity a -> Identity a -> Identity a
$csin :: forall a. Floating a => Identity a -> Identity a
sin :: Identity a -> Identity a
$ccos :: forall a. Floating a => Identity a -> Identity a
cos :: Identity a -> Identity a
$ctan :: forall a. Floating a => Identity a -> Identity a
tan :: Identity a -> Identity a
$casin :: forall a. Floating a => Identity a -> Identity a
asin :: Identity a -> Identity a
$cacos :: forall a. Floating a => Identity a -> Identity a
acos :: Identity a -> Identity a
$catan :: forall a. Floating a => Identity a -> Identity a
atan :: Identity a -> Identity a
$csinh :: forall a. Floating a => Identity a -> Identity a
sinh :: Identity a -> Identity a
$ccosh :: forall a. Floating a => Identity a -> Identity a
cosh :: Identity a -> Identity a
$ctanh :: forall a. Floating a => Identity a -> Identity a
tanh :: Identity a -> Identity a
$casinh :: forall a. Floating a => Identity a -> Identity a
asinh :: Identity a -> Identity a
$cacosh :: forall a. Floating a => Identity a -> Identity a
acosh :: Identity a -> Identity a
$catanh :: forall a. Floating a => Identity a -> Identity a
atanh :: Identity a -> Identity a
$clog1p :: forall a. Floating a => Identity a -> Identity a
log1p :: Identity a -> Identity a
$cexpm1 :: forall a. Floating a => Identity a -> Identity a
expm1 :: Identity a -> Identity a
$clog1pexp :: forall a. Floating a => Identity a -> Identity a
log1pexp :: Identity a -> Identity a
$clog1mexp :: forall a. Floating a => Identity a -> Identity a
log1mexp :: Identity a -> Identity a
Floating   -- ^ @since 4.9.0.0
             , Num (Identity a)
Num (Identity a)
-> (Identity a -> Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Rational -> Identity a)
-> Fractional (Identity a)
Rational -> Identity a
Identity a -> Identity a
Identity a -> Identity a -> Identity a
forall {a}. Fractional a => Num (Identity a)
forall a. Fractional a => Rational -> Identity a
forall a. Fractional a => Identity a -> Identity a
forall a. Fractional a => Identity a -> Identity a -> Identity a
forall a.
Num a
-> (a -> a -> a) -> (a -> a) -> (Rational -> a) -> Fractional a
$c/ :: forall a. Fractional a => Identity a -> Identity a -> Identity a
/ :: Identity a -> Identity a -> Identity a
$crecip :: forall a. Fractional a => Identity a -> Identity a
recip :: Identity a -> Identity a
$cfromRational :: forall a. Fractional a => Rational -> Identity a
fromRational :: Rational -> Identity a
Fractional -- ^ @since 4.9.0.0
             , (forall x. Identity a -> Rep (Identity a) x)
-> (forall x. Rep (Identity a) x -> Identity a)
-> Generic (Identity a)
forall x. Rep (Identity a) x -> Identity a
forall x. Identity a -> Rep (Identity a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Identity a) x -> Identity a
forall a x. Identity a -> Rep (Identity a) x
$cfrom :: forall a x. Identity a -> Rep (Identity a) x
from :: forall x. Identity a -> Rep (Identity a) x
$cto :: forall a x. Rep (Identity a) x -> Identity a
to :: forall x. Rep (Identity a) x -> Identity a
Generic    -- ^ @since 4.8.0.0
             , (forall a. Identity a -> Rep1 Identity a)
-> (forall a. Rep1 Identity a -> Identity a) -> Generic1 Identity
forall a. Rep1 Identity a -> Identity a
forall a. Identity a -> Rep1 Identity a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cfrom1 :: forall a. Identity a -> Rep1 Identity a
from1 :: forall a. Identity a -> Rep1 Identity a
$cto1 :: forall a. Rep1 Identity a -> Identity a
to1 :: forall a. Rep1 Identity a -> Identity a
Generic1   -- ^ @since 4.8.0.0
             , Enum (Identity a)
Real (Identity a)
Real (Identity a)
-> Enum (Identity a)
-> (Identity a -> Identity a -> Identity a)
-> (Identity a -> Identity a -> Identity a)
-> (Identity a -> Identity a -> Identity a)
-> (Identity a -> Identity a -> Identity a)
-> (Identity a -> Identity a -> (Identity a, Identity a))
-> (Identity a -> Identity a -> (Identity a, Identity a))
-> (Identity a -> Integer)
-> Integral (Identity a)
Identity a -> Integer
Identity a -> Identity a -> (Identity a, Identity a)
Identity a -> Identity a -> Identity a
forall {a}. Integral a => Enum (Identity a)
forall {a}. Integral a => Real (Identity a)
forall a. Integral a => Identity a -> Integer
forall a.
Integral a =>
Identity a -> Identity a -> (Identity a, Identity a)
forall a. Integral a => Identity a -> Identity a -> Identity a
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
$cquot :: forall a. Integral a => Identity a -> Identity a -> Identity a
quot :: Identity a -> Identity a -> Identity a
$crem :: forall a. Integral a => Identity a -> Identity a -> Identity a
rem :: Identity a -> Identity a -> Identity a
$cdiv :: forall a. Integral a => Identity a -> Identity a -> Identity a
div :: Identity a -> Identity a -> Identity a
$cmod :: forall a. Integral a => Identity a -> Identity a -> Identity a
mod :: Identity a -> Identity a -> Identity a
$cquotRem :: forall a.
Integral a =>
Identity a -> Identity a -> (Identity a, Identity a)
quotRem :: Identity a -> Identity a -> (Identity a, Identity a)
$cdivMod :: forall a.
Integral a =>
Identity a -> Identity a -> (Identity a, Identity a)
divMod :: Identity a -> Identity a -> (Identity a, Identity a)
$ctoInteger :: forall a. Integral a => Identity a -> Integer
toInteger :: Identity a -> Integer
Integral   -- ^ @since 4.9.0.0
             , Ord (Identity a)
Ord (Identity a)
-> ((Identity a, Identity a) -> [Identity a])
-> ((Identity a, Identity a) -> Identity a -> Int)
-> ((Identity a, Identity a) -> Identity a -> Int)
-> ((Identity a, Identity a) -> Identity a -> Bool)
-> ((Identity a, Identity a) -> Int)
-> ((Identity a, Identity a) -> Int)
-> Ix (Identity a)
(Identity a, Identity a) -> Int
(Identity a, Identity a) -> [Identity a]
(Identity a, Identity a) -> Identity a -> Bool
(Identity a, Identity a) -> Identity a -> Int
forall a.
Ord a
-> ((a, a) -> [a])
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Int)
-> ((a, a) -> a -> Bool)
-> ((a, a) -> Int)
-> ((a, a) -> Int)
-> Ix a
forall {a}. Ix a => Ord (Identity a)
forall a. Ix a => (Identity a, Identity a) -> Int
forall a. Ix a => (Identity a, Identity a) -> [Identity a]
forall a. Ix a => (Identity a, Identity a) -> Identity a -> Bool
forall a. Ix a => (Identity a, Identity a) -> Identity a -> Int
$crange :: forall a. Ix a => (Identity a, Identity a) -> [Identity a]
range :: (Identity a, Identity a) -> [Identity a]
$cindex :: forall a. Ix a => (Identity a, Identity a) -> Identity a -> Int
index :: (Identity a, Identity a) -> Identity a -> Int
$cunsafeIndex :: forall a. Ix a => (Identity a, Identity a) -> Identity a -> Int
unsafeIndex :: (Identity a, Identity a) -> Identity a -> Int
$cinRange :: forall a. Ix a => (Identity a, Identity a) -> Identity a -> Bool
inRange :: (Identity a, Identity a) -> Identity a -> Bool
$crangeSize :: forall a. Ix a => (Identity a, Identity a) -> Int
rangeSize :: (Identity a, Identity a) -> Int
$cunsafeRangeSize :: forall a. Ix a => (Identity a, Identity a) -> Int
unsafeRangeSize :: (Identity a, Identity a) -> Int
Ix         -- ^ @since 4.9.0.0
             , NonEmpty (Identity a) -> Identity a
Identity a -> Identity a -> Identity a
(Identity a -> Identity a -> Identity a)
-> (NonEmpty (Identity a) -> Identity a)
-> (forall b. Integral b => b -> Identity a -> Identity a)
-> Semigroup (Identity a)
forall b. Integral b => b -> Identity a -> Identity a
forall a. Semigroup a => NonEmpty (Identity a) -> Identity a
forall a. Semigroup a => Identity a -> Identity a -> Identity a
forall a b.
(Semigroup a, Integral b) =>
b -> Identity a -> Identity a
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
$c<> :: forall a. Semigroup a => Identity a -> Identity a -> Identity a
<> :: Identity a -> Identity a -> Identity a
$csconcat :: forall a. Semigroup a => NonEmpty (Identity a) -> Identity a
sconcat :: NonEmpty (Identity a) -> Identity a
$cstimes :: forall a b.
(Semigroup a, Integral b) =>
b -> Identity a -> Identity a
stimes :: forall b. Integral b => b -> Identity a -> Identity a
Semigroup  -- ^ @since 4.9.0.0
             , Semigroup (Identity a)
Identity a
Semigroup (Identity a)
-> Identity a
-> (Identity a -> Identity a -> Identity a)
-> ([Identity a] -> Identity a)
-> Monoid (Identity a)
[Identity a] -> Identity a
Identity a -> Identity a -> Identity a
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
forall {a}. Monoid a => Semigroup (Identity a)
forall a. Monoid a => Identity a
forall a. Monoid a => [Identity a] -> Identity a
forall a. Monoid a => Identity a -> Identity a -> Identity a
$cmempty :: forall a. Monoid a => Identity a
mempty :: Identity a
$cmappend :: forall a. Monoid a => Identity a -> Identity a -> Identity a
mappend :: Identity a -> Identity a -> Identity a
$cmconcat :: forall a. Monoid a => [Identity a] -> Identity a
mconcat :: [Identity a] -> Identity a
Monoid     -- ^ @since 4.9.0.0
             , Integer -> Identity a
Identity a -> Identity a
Identity a -> Identity a -> Identity a
(Identity a -> Identity a -> Identity a)
-> (Identity a -> Identity a -> Identity a)
-> (Identity a -> Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Identity a -> Identity a)
-> (Integer -> Identity a)
-> Num (Identity a)
forall a. Num a => Integer -> Identity a
forall a. Num a => Identity a -> Identity a
forall a. Num a => Identity a -> Identity a -> Identity a
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: forall a. Num a => Identity a -> Identity a -> Identity a
+ :: Identity a -> Identity a -> Identity a
$c- :: forall a. Num a => Identity a -> Identity a -> Identity a
- :: Identity a -> Identity a -> Identity a
$c* :: forall a. Num a => Identity a -> Identity a -> Identity a
* :: Identity a -> Identity a -> Identity a
$cnegate :: forall a. Num a => Identity a -> Identity a
negate :: Identity a -> Identity a
$cabs :: forall a. Num a => Identity a -> Identity a
abs :: Identity a -> Identity a
$csignum :: forall a. Num a => Identity a -> Identity a
signum :: Identity a -> Identity a
$cfromInteger :: forall a. Num a => Integer -> Identity a
fromInteger :: Integer -> Identity a
Num        -- ^ @since 4.9.0.0
             , Eq (Identity a)
Eq (Identity a)
-> (Identity a -> Identity a -> Ordering)
-> (Identity a -> Identity a -> Bool)
-> (Identity a -> Identity a -> Bool)
-> (Identity a -> Identity a -> Bool)
-> (Identity a -> Identity a -> Bool)
-> (Identity a -> Identity a -> Identity a)
-> (Identity a -> Identity a -> Identity a)
-> Ord (Identity a)
Identity a -> Identity a -> Bool
Identity a -> Identity a -> Ordering
Identity a -> Identity a -> Identity a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {a}. Ord a => Eq (Identity a)
forall a. Ord a => Identity a -> Identity a -> Bool
forall a. Ord a => Identity a -> Identity a -> Ordering
forall a. Ord a => Identity a -> Identity a -> Identity a
$ccompare :: forall a. Ord a => Identity a -> Identity a -> Ordering
compare :: Identity a -> Identity a -> Ordering
$c< :: forall a. Ord a => Identity a -> Identity a -> Bool
< :: Identity a -> Identity a -> Bool
$c<= :: forall a. Ord a => Identity a -> Identity a -> Bool
<= :: Identity a -> Identity a -> Bool
$c> :: forall a. Ord a => Identity a -> Identity a -> Bool
> :: Identity a -> Identity a -> Bool
$c>= :: forall a. Ord a => Identity a -> Identity a -> Bool
>= :: Identity a -> Identity a -> Bool
$cmax :: forall a. Ord a => Identity a -> Identity a -> Identity a
max :: Identity a -> Identity a -> Identity a
$cmin :: forall a. Ord a => Identity a -> Identity a -> Identity a
min :: Identity a -> Identity a -> Identity a
Ord        -- ^ @since 4.8.0.0
             , Num (Identity a)
Ord (Identity a)
Num (Identity a)
-> Ord (Identity a)
-> (Identity a -> Rational)
-> Real (Identity a)
Identity a -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
forall {a}. Real a => Num (Identity a)
forall {a}. Real a => Ord (Identity a)
forall a. Real a => Identity a -> Rational
$ctoRational :: forall a. Real a => Identity a -> Rational
toRational :: Identity a -> Rational
Real       -- ^ @since 4.9.0.0
             , Fractional (Identity a)
Real (Identity a)
Real (Identity a)
-> Fractional (Identity a)
-> (forall b. Integral b => Identity a -> (b, Identity a))
-> (forall b. Integral b => Identity a -> b)
-> (forall b. Integral b => Identity a -> b)
-> (forall b. Integral b => Identity a -> b)
-> (forall b. Integral b => Identity a -> b)
-> RealFrac (Identity a)
forall b. Integral b => Identity a -> b
forall b. Integral b => Identity a -> (b, Identity a)
forall a.
Real a
-> Fractional a
-> (forall b. Integral b => a -> (b, a))
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> RealFrac a
forall {a}. RealFrac a => Fractional (Identity a)
forall {a}. RealFrac a => Real (Identity a)
forall a b. (RealFrac a, Integral b) => Identity a -> b
forall a b.
(RealFrac a, Integral b) =>
Identity a -> (b, Identity a)
$cproperFraction :: forall a b.
(RealFrac a, Integral b) =>
Identity a -> (b, Identity a)
properFraction :: forall b. Integral b => Identity a -> (b, Identity a)
$ctruncate :: forall a b. (RealFrac a, Integral b) => Identity a -> b
truncate :: forall b. Integral b => Identity a -> b
$cround :: forall a b. (RealFrac a, Integral b) => Identity a -> b
round :: forall b. Integral b => Identity a -> b
$cceiling :: forall a b. (RealFrac a, Integral b) => Identity a -> b
ceiling :: forall b. Integral b => Identity a -> b
$cfloor :: forall a b. (RealFrac a, Integral b) => Identity a -> b
floor :: forall b. Integral b => Identity a -> b
RealFrac   -- ^ @since 4.9.0.0
             , Floating (Identity a)
RealFrac (Identity a)
RealFrac (Identity a)
-> Floating (Identity a)
-> (Identity a -> Integer)
-> (Identity a -> Int)
-> (Identity a -> (Int, Int))
-> (Identity a -> (Integer, Int))
-> (Integer -> Int -> Identity a)
-> (Identity a -> Int)
-> (Identity a -> Identity a)
-> (Int -> Identity a -> Identity a)
-> (Identity a -> Bool)
-> (Identity a -> Bool)
-> (Identity a -> Bool)
-> (Identity a -> Bool)
-> (Identity a -> Bool)
-> (Identity a -> Identity a -> Identity a)
-> RealFloat (Identity a)
Int -> Identity a -> Identity a
Integer -> Int -> Identity a
Identity a -> Bool
Identity a -> Int
Identity a -> Integer
Identity a -> (Int, Int)
Identity a -> (Integer, Int)
Identity a -> Identity a
Identity a -> Identity a -> Identity a
forall {a}. RealFloat a => Floating (Identity a)
forall {a}. RealFloat a => RealFrac (Identity a)
forall a. RealFloat a => Int -> Identity a -> Identity a
forall a. RealFloat a => Integer -> Int -> Identity a
forall a. RealFloat a => Identity a -> Bool
forall a. RealFloat a => Identity a -> Int
forall a. RealFloat a => Identity a -> Integer
forall a. RealFloat a => Identity a -> (Int, Int)
forall a. RealFloat a => Identity a -> (Integer, Int)
forall a. RealFloat a => Identity a -> Identity a
forall a. RealFloat a => Identity a -> Identity a -> Identity a
forall a.
RealFrac a
-> Floating a
-> (a -> Integer)
-> (a -> Int)
-> (a -> (Int, Int))
-> (a -> (Integer, Int))
-> (Integer -> Int -> a)
-> (a -> Int)
-> (a -> a)
-> (Int -> a -> a)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> a -> a)
-> RealFloat a
$cfloatRadix :: forall a. RealFloat a => Identity a -> Integer
floatRadix :: Identity a -> Integer
$cfloatDigits :: forall a. RealFloat a => Identity a -> Int
floatDigits :: Identity a -> Int
$cfloatRange :: forall a. RealFloat a => Identity a -> (Int, Int)
floatRange :: Identity a -> (Int, Int)
$cdecodeFloat :: forall a. RealFloat a => Identity a -> (Integer, Int)
decodeFloat :: Identity a -> (Integer, Int)
$cencodeFloat :: forall a. RealFloat a => Integer -> Int -> Identity a
encodeFloat :: Integer -> Int -> Identity a
$cexponent :: forall a. RealFloat a => Identity a -> Int
exponent :: Identity a -> Int
$csignificand :: forall a. RealFloat a => Identity a -> Identity a
significand :: Identity a -> Identity a
$cscaleFloat :: forall a. RealFloat a => Int -> Identity a -> Identity a
scaleFloat :: Int -> Identity a -> Identity a
$cisNaN :: forall a. RealFloat a => Identity a -> Bool
isNaN :: Identity a -> Bool
$cisInfinite :: forall a. RealFloat a => Identity a -> Bool
isInfinite :: Identity a -> Bool
$cisDenormalized :: forall a. RealFloat a => Identity a -> Bool
isDenormalized :: Identity a -> Bool
$cisNegativeZero :: forall a. RealFloat a => Identity a -> Bool
isNegativeZero :: Identity a -> Bool
$cisIEEE :: forall a. RealFloat a => Identity a -> Bool
isIEEE :: Identity a -> Bool
$catan2 :: forall a. RealFloat a => Identity a -> Identity a -> Identity a
atan2 :: Identity a -> Identity a -> Identity a
RealFloat  -- ^ @since 4.9.0.0
             , Ptr (Identity a) -> IO (Identity a)
Ptr (Identity a) -> Int -> IO (Identity a)
Ptr (Identity a) -> Int -> Identity a -> IO ()
Ptr (Identity a) -> Identity a -> IO ()
Identity a -> Int
(Identity a -> Int)
-> (Identity a -> Int)
-> (Ptr (Identity a) -> Int -> IO (Identity a))
-> (Ptr (Identity a) -> Int -> Identity a -> IO ())
-> (forall b. Ptr b -> Int -> IO (Identity a))
-> (forall b. Ptr b -> Int -> Identity a -> IO ())
-> (Ptr (Identity a) -> IO (Identity a))
-> (Ptr (Identity a) -> Identity a -> IO ())
-> Storable (Identity a)
forall b. Ptr b -> Int -> IO (Identity a)
forall b. Ptr b -> Int -> Identity a -> IO ()
forall a. Storable a => Ptr (Identity a) -> IO (Identity a)
forall a. Storable a => Ptr (Identity a) -> Int -> IO (Identity a)
forall a.
Storable a =>
Ptr (Identity a) -> Int -> Identity a -> IO ()
forall a. Storable a => Ptr (Identity a) -> Identity a -> IO ()
forall a. Storable a => Identity a -> Int
forall a b. Storable a => Ptr b -> Int -> IO (Identity a)
forall a b. Storable a => Ptr b -> Int -> Identity a -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
$csizeOf :: forall a. Storable a => Identity a -> Int
sizeOf :: Identity a -> Int
$calignment :: forall a. Storable a => Identity a -> Int
alignment :: Identity a -> Int
$cpeekElemOff :: forall a. Storable a => Ptr (Identity a) -> Int -> IO (Identity a)
peekElemOff :: Ptr (Identity a) -> Int -> IO (Identity a)
$cpokeElemOff :: forall a.
Storable a =>
Ptr (Identity a) -> Int -> Identity a -> IO ()
pokeElemOff :: Ptr (Identity a) -> Int -> Identity a -> IO ()
$cpeekByteOff :: forall a b. Storable a => Ptr b -> Int -> IO (Identity a)
peekByteOff :: forall b. Ptr b -> Int -> IO (Identity a)
$cpokeByteOff :: forall a b. Storable a => Ptr b -> Int -> Identity a -> IO ()
pokeByteOff :: forall b. Ptr b -> Int -> Identity a -> IO ()
$cpeek :: forall a. Storable a => Ptr (Identity a) -> IO (Identity a)
peek :: Ptr (Identity a) -> IO (Identity a)
$cpoke :: forall a. Storable a => Ptr (Identity a) -> Identity a -> IO ()
poke :: Ptr (Identity a) -> Identity a -> IO ()
Storable   -- ^ @since 4.9.0.0
             )

-- | This instance would be equivalent to the derived instances of the
-- 'Identity' newtype if the 'runIdentity' field were removed
--
-- @since 4.8.0.0
instance (Read a) => Read (Identity a) where
    readsPrec :: Int -> ReadS (Identity a)
readsPrec Int
d = Bool -> ReadS (Identity a) -> ReadS (Identity a)
forall a. Bool -> ReadS a -> ReadS a
readParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10) (ReadS (Identity a) -> ReadS (Identity a))
-> ReadS (Identity a) -> ReadS (Identity a)
forall a b. (a -> b) -> a -> b
$ \ String
r ->
        [(a -> Identity a
forall a. a -> Identity a
Identity a
x,String
t) | (String
"Identity",String
s) <- ReadS String
lex String
r, (a
x,String
t) <- Int -> ReadS a
forall a. Read a => Int -> ReadS a
readsPrec Int
11 String
s]

-- | This instance would be equivalent to the derived instances of the
-- 'Identity' newtype if the 'runIdentity' field were removed
--
-- @since 4.8.0.0
instance (Show a) => Show (Identity a) where
    showsPrec :: Int -> Identity a -> ShowS
showsPrec Int
d (Identity a
x) = Bool -> ShowS -> ShowS
showParen (Int
d Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
10) (ShowS -> ShowS) -> ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
        String -> ShowS
showString String
"Identity " ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> a -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 a
x

-- ---------------------------------------------------------------------------
-- Identity instances for Functor and Monad

-- | @since 4.8.0.0
instance Foldable Identity where
    foldMap :: forall m a. Monoid m => (a -> m) -> Identity a -> m
foldMap                = (a -> m) -> Identity a -> m
forall a b. Coercible a b => a -> b
coerce

    elem :: forall a. Eq a => a -> Identity a -> Bool
elem                   = ((a -> Bool) -> (Identity a -> a) -> Identity a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Identity a -> a
forall a. Identity a -> a
runIdentity) ((a -> Bool) -> Identity a -> Bool)
-> (a -> a -> Bool) -> a -> Identity a -> Bool
forall b c a. Coercible b c => (b -> c) -> (a -> b) -> a -> c
#. a -> a -> Bool
forall a. Eq a => a -> a -> Bool
(==)
    foldl :: forall b a. (b -> a -> b) -> b -> Identity a -> b
foldl                  = (b -> a -> b) -> b -> Identity a -> b
forall a b. Coercible a b => a -> b
coerce
    foldl' :: forall b a. (b -> a -> b) -> b -> Identity a -> b
foldl'                 = (b -> a -> b) -> b -> Identity a -> b
forall a b. Coercible a b => a -> b
coerce
    foldl1 :: forall a. (a -> a -> a) -> Identity a -> a
foldl1 a -> a -> a
_               = Identity a -> a
forall a. Identity a -> a
runIdentity
    foldr :: forall a b. (a -> b -> b) -> b -> Identity a -> b
foldr a -> b -> b
f b
z (Identity a
x) = a -> b -> b
f a
x b
z
    foldr' :: forall a b. (a -> b -> b) -> b -> Identity a -> b
foldr'                 = (a -> b -> b) -> b -> Identity a -> b
forall a b. (a -> b -> b) -> b -> Identity a -> b
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr
    foldr1 :: forall a. (a -> a -> a) -> Identity a -> a
foldr1 a -> a -> a
_               = Identity a -> a
forall a. Identity a -> a
runIdentity
    length :: forall a. Identity a -> Int
length Identity a
_               = Int
1
    maximum :: forall a. Ord a => Identity a -> a
maximum                = Identity a -> a
forall a. Identity a -> a
runIdentity
    minimum :: forall a. Ord a => Identity a -> a
minimum                = Identity a -> a
forall a. Identity a -> a
runIdentity
    null :: forall a. Identity a -> Bool
null Identity a
_                 = Bool
False
    product :: forall a. Num a => Identity a -> a
product                = Identity a -> a
forall a. Identity a -> a
runIdentity
    sum :: forall a. Num a => Identity a -> a
sum                    = Identity a -> a
forall a. Identity a -> a
runIdentity
    toList :: forall a. Identity a -> [a]
toList (Identity a
x)    = [a
x]

-- | @since 4.8.0.0
instance Functor Identity where
    fmap :: forall a b. (a -> b) -> Identity a -> Identity b
fmap     = (a -> b) -> Identity a -> Identity b
forall a b. Coercible a b => a -> b
coerce

-- | @since 4.8.0.0
instance Applicative Identity where
    pure :: forall a. a -> Identity a
pure     = a -> Identity a
forall a. a -> Identity a
Identity
    <*> :: forall a b. Identity (a -> b) -> Identity a -> Identity b
(<*>)    = Identity (a -> b) -> Identity a -> Identity b
forall a b. Coercible a b => a -> b
coerce
    liftA2 :: forall a b c.
(a -> b -> c) -> Identity a -> Identity b -> Identity c
liftA2   = (a -> b -> c) -> Identity a -> Identity b -> Identity c
forall a b. Coercible a b => a -> b
coerce

-- | @since 4.8.0.0
instance Monad Identity where
    Identity a
m >>= :: forall a b. Identity a -> (a -> Identity b) -> Identity b
>>= a -> Identity b
k  = a -> Identity b
k (Identity a -> a
forall a. Identity a -> a
runIdentity Identity a
m)

-- | @since 4.8.0.0
instance MonadFix Identity where
    mfix :: forall a. (a -> Identity a) -> Identity a
mfix a -> Identity a
f   = a -> Identity a
forall a. a -> Identity a
Identity ((a -> a) -> a
forall a. (a -> a) -> a
fix (Identity a -> a
forall a. Identity a -> a
runIdentity (Identity a -> a) -> (a -> Identity a) -> a -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Identity a
f))