Movatterモバイル変換


[0]ホーム

URL:


{-# LANGUAGE DeriveDataTypeable #-}{-# LANGUAGE DeriveGeneric #-}{-# LANGUAGE DeriveTraversable #-}{-# 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   :  experimental-- 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-----------------------------------------------------------------------------moduleData.Functor.Identity(Identity(..),)whereimportControl.Monad.FiximportData.Bits(Bits,FiniteBits)importData.CoerceimportData.FoldableimportData.Functor.Utils((#.))importForeign.Storable(Storable)importGHC.Ix(Ix)importGHC.Base(Applicative(..),Eq(..),Functor(..),Monad(..),Semigroup,Monoid,Ord(..),($),(.))importGHC.Enum(Bounded,Enum)importGHC.Float(Floating,RealFloat)importGHC.Generics(Generic,Generic1)importGHC.Num(Num)importGHC.Read(Read(..),lex,readParen)importGHC.Real(Fractional,Integral,Real,RealFrac)importGHC.Show(Show(..),showParen,showString)importGHC.Types(Bool(..))-- | Identity functor and monad. (a non-strict monad)---- @since 4.8.0.0newtypeIdentitya=Identity{Identity a -> arunIdentity::a}deriving(Bits-- ^ @since 4.9.0.0,Bounded-- ^ @since 4.9.0.0,Enum-- ^ @since 4.9.0.0,Eq-- ^ @since 4.8.0.0,FiniteBits-- ^ @since 4.9.0.0,Floating-- ^ @since 4.9.0.0,Fractional-- ^ @since 4.9.0.0,Generic-- ^ @since 4.8.0.0,Generic1-- ^ @since 4.8.0.0,Integral-- ^ @since 4.9.0.0,Ix-- ^ @since 4.9.0.0,Semigroup-- ^ @since 4.9.0.0,Monoid-- ^ @since 4.9.0.0,Num-- ^ @since 4.9.0.0,Ord-- ^ @since 4.8.0.0,Real-- ^ @since 4.9.0.0,RealFrac-- ^ @since 4.9.0.0,RealFloat-- ^ @since 4.9.0.0,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.0instance(Reada)=>Read(Identitya)wherereadsPrec :: Int -> ReadS (Identity a)readsPrecIntd=Bool -> ReadS (Identity a) -> ReadS (Identity a)forall a. Bool -> ReadS a -> ReadS areadParen(IntdInt -> Int -> Boolforall a. Ord a => a -> a -> Bool>Int10)(ReadS (Identity a) -> ReadS (Identity a))-> ReadS (Identity a) -> ReadS (Identity a)forall a b. (a -> b) -> a -> b$\Stringr->[(a -> Identity aforall a. a -> Identity aIdentityax,Stringt)|(String"Identity",Strings)<-ReadS StringlexStringr,(ax,Stringt)<-Int -> ReadS aforall a. Read a => Int -> ReadS areadsPrecInt11Strings]-- | This instance would be equivalent to the derived instances of the-- 'Identity' newtype if the 'runIdentity' field were removed---- @since 4.8.0.0instance(Showa)=>Show(Identitya)whereshowsPrec :: Int -> Identity a -> ShowSshowsPrecIntd(Identityax)=Bool -> ShowS -> ShowSshowParen(IntdInt -> Int -> Boolforall a. Ord a => a -> a -> Bool>Int10)(ShowS -> ShowS) -> ShowS -> ShowSforall a b. (a -> b) -> a -> b$String -> ShowSshowStringString"Identity "ShowS -> ShowS -> ShowSforall b c a. (b -> c) -> (a -> b) -> a -> c.Int -> a -> ShowSforall a. Show a => Int -> a -> ShowSshowsPrecInt11ax-- ----------------------------------------------------------------------------- Identity instances for Functor and Monad-- | @since 4.8.0.0instanceFoldableIdentitywherefoldMap :: (a -> m) -> Identity a -> mfoldMap=(a -> m) -> Identity a -> mcoerceelem :: a -> Identity a -> Boolelem=((a -> Bool) -> (Identity a -> a) -> Identity a -> Boolforall b c a. (b -> c) -> (a -> b) -> a -> c.Identity a -> aforall a. Identity a -> arunIdentity)((a -> Bool) -> Identity a -> Bool)-> (a -> a -> Bool) -> a -> Identity a -> Boolforall b c a. Coercible b c => (b -> c) -> (a -> b) -> a -> c#.a -> a -> Boolforall a. Eq a => a -> a -> Bool(==)foldl :: (b -> a -> b) -> b -> Identity a -> bfoldl=(b -> a -> b) -> b -> Identity a -> bcoercefoldl' :: (b -> a -> b) -> b -> Identity a -> bfoldl'=(b -> a -> b) -> b -> Identity a -> bcoercefoldl1 :: (a -> a -> a) -> Identity a -> afoldl1a -> a -> a_=Identity a -> aforall a. Identity a -> arunIdentityfoldr :: (a -> b -> b) -> b -> Identity a -> bfoldra -> b -> bfbz(Identityax)=a -> b -> bfaxbzfoldr' :: (a -> b -> b) -> b -> Identity a -> bfoldr'=(a -> b -> b) -> b -> Identity a -> bforall (t :: * -> *) a b.Foldable t =>(a -> b -> b) -> b -> t a -> bfoldrfoldr1 :: (a -> a -> a) -> Identity a -> afoldr1a -> a -> a_=Identity a -> aforall a. Identity a -> arunIdentitylength :: Identity a -> IntlengthIdentity a_=Int1maximum :: Identity a -> amaximum=Identity a -> aforall a. Identity a -> arunIdentityminimum :: Identity a -> aminimum=Identity a -> aforall a. Identity a -> arunIdentitynull :: Identity a -> BoolnullIdentity a_=BoolFalseproduct :: Identity a -> aproduct=Identity a -> aforall a. Identity a -> arunIdentitysum :: Identity a -> asum=Identity a -> aforall a. Identity a -> arunIdentitytoList :: Identity a -> [a]toList(Identityax)=[ax]-- | @since 4.8.0.0instanceFunctorIdentitywherefmap :: (a -> b) -> Identity a -> Identity bfmap=(a -> b) -> Identity a -> Identity bcoerce-- | @since 4.8.0.0instanceApplicativeIdentitywherepure :: a -> Identity apure=a -> Identity aforall a. a -> Identity aIdentity<*> :: Identity (a -> b) -> Identity a -> Identity b(<*>)=Identity (a -> b) -> Identity a -> Identity bcoerceliftA2 :: (a -> b -> c) -> Identity a -> Identity b -> Identity cliftA2=(a -> b -> c) -> Identity a -> Identity b -> Identity ccoerce-- | @since 4.8.0.0instanceMonadIdentitywhereIdentity am>>= :: Identity a -> (a -> Identity b) -> Identity b>>=a -> Identity bk=a -> Identity bk(Identity a -> aforall a. Identity a -> arunIdentityIdentity am)-- | @since 4.8.0.0instanceMonadFixIdentitywheremfix :: (a -> Identity a) -> Identity amfixa -> Identity af=a -> Identity aforall a. a -> Identity aIdentity((a -> a) -> aforall a. (a -> a) -> afix(Identity a -> aforall a. Identity a -> arunIdentity(Identity a -> a) -> (a -> Identity a) -> a -> aforall b c a. (b -> c) -> (a -> b) -> a -> c.a -> Identity af))

[8]ページ先頭

©2009-2025 Movatter.jp