Movatterモバイル変換


[0]ホーム

URL:


base-4.12.0.0: Basic libraries

Copyright(c) The University of Glasgow 2001
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityprovisional
Portabilityportable
Safe HaskellTrustworthy
LanguageHaskell2010

Data.Functor

Description

Functors: uniform action over a parameterized type, generalizing themap function on lists.

Synopsis

Documentation

classFunctor fwhereSource#

TheFunctor class is used for types that can be mapped over.Instances ofFunctor should satisfy the following laws:

fmap id  ==  idfmap (f . g)  ==  fmap f . fmap g

The instances ofFunctor for lists,Maybe andIOsatisfy these laws.

Methods

fmap :: (a -> b) -> f a -> f bSource#

Instances
Functor []Source#

Since: 2.1

Instance details

Defined inGHC.Base

Methods

fmap :: (a -> b) -> [a] -> [b]Source#

(<$) :: a -> [b] -> [a]Source#

FunctorMaybeSource#

Since: 2.1

Instance details

Defined inGHC.Base

Methods

fmap :: (a -> b) ->Maybe a ->Maybe bSource#

(<$) :: a ->Maybe b ->Maybe aSource#

FunctorIOSource#

Since: 2.1

Instance details

Defined inGHC.Base

Methods

fmap :: (a -> b) ->IO a ->IO bSource#

(<$) :: a ->IO b ->IO aSource#

FunctorPar1Source#

Since: 4.9.0.0

Instance details

Defined inGHC.Generics

Methods

fmap :: (a -> b) ->Par1 a ->Par1 bSource#

(<$) :: a ->Par1 b ->Par1 aSource#

FunctorNonEmptySource#

Since: 4.9.0.0

Instance details

Defined inGHC.Base

Methods

fmap :: (a -> b) ->NonEmpty a ->NonEmpty bSource#

(<$) :: a ->NonEmpty b ->NonEmpty aSource#

FunctorReadPSource#

Since: 2.1

Instance details

Defined inText.ParserCombinators.ReadP

Methods

fmap :: (a -> b) ->ReadP a ->ReadP bSource#

(<$) :: a ->ReadP b ->ReadP aSource#

FunctorReadPrecSource#

Since: 2.1

Instance details

Defined inText.ParserCombinators.ReadPrec

Methods

fmap :: (a -> b) ->ReadPrec a ->ReadPrec bSource#

(<$) :: a ->ReadPrec b ->ReadPrec aSource#

FunctorDownSource#

Since: 4.11.0.0

Instance details

Defined inData.Ord

Methods

fmap :: (a -> b) ->Down a ->Down bSource#

(<$) :: a ->Down b ->Down aSource#

FunctorProductSource#

Since: 4.8.0.0

Instance details

Defined inData.Semigroup.Internal

Methods

fmap :: (a -> b) ->Product a ->Product bSource#

(<$) :: a ->Product b ->Product aSource#

FunctorSumSource#

Since: 4.8.0.0

Instance details

Defined inData.Semigroup.Internal

Methods

fmap :: (a -> b) ->Sum a ->Sum bSource#

(<$) :: a ->Sum b ->Sum aSource#

FunctorDualSource#

Since: 4.8.0.0

Instance details

Defined inData.Semigroup.Internal

Methods

fmap :: (a -> b) ->Dual a ->Dual bSource#

(<$) :: a ->Dual b ->Dual aSource#

FunctorLastSource#

Since: 4.8.0.0

Instance details

Defined inData.Monoid

Methods

fmap :: (a -> b) ->Last a ->Last bSource#

(<$) :: a ->Last b ->Last aSource#

FunctorFirstSource#

Since: 4.8.0.0

Instance details

Defined inData.Monoid

Methods

fmap :: (a -> b) ->First a ->First bSource#

(<$) :: a ->First b ->First aSource#

FunctorSTMSource#

Since: 4.3.0.0

Instance details

Defined inGHC.Conc.Sync

Methods

fmap :: (a -> b) ->STM a ->STM bSource#

(<$) :: a ->STM b ->STM aSource#

FunctorHandlerSource#

Since: 4.6.0.0

Instance details

Defined inControl.Exception

Methods

fmap :: (a -> b) ->Handler a ->Handler bSource#

(<$) :: a ->Handler b ->Handler aSource#

FunctorIdentitySource#

Since: 4.8.0.0

Instance details

Defined inData.Functor.Identity

Methods

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

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

FunctorZipListSource#

Since: 2.1

Instance details

Defined inControl.Applicative

Methods

fmap :: (a -> b) ->ZipList a ->ZipList bSource#

(<$) :: a ->ZipList b ->ZipList aSource#

FunctorArgDescrSource#

Since: 4.6.0.0

Instance details

Defined inSystem.Console.GetOpt

Methods

fmap :: (a -> b) ->ArgDescr a ->ArgDescr bSource#

(<$) :: a ->ArgDescr b ->ArgDescr aSource#

FunctorOptDescrSource#

Since: 4.6.0.0

Instance details

Defined inSystem.Console.GetOpt

Methods

fmap :: (a -> b) ->OptDescr a ->OptDescr bSource#

(<$) :: a ->OptDescr b ->OptDescr aSource#

FunctorArgOrderSource#

Since: 4.6.0.0

Instance details

Defined inSystem.Console.GetOpt

Methods

fmap :: (a -> b) ->ArgOrder a ->ArgOrder bSource#

(<$) :: a ->ArgOrder b ->ArgOrder aSource#

FunctorOptionSource#

Since: 4.9.0.0

Instance details

Defined inData.Semigroup

Methods

fmap :: (a -> b) ->Option a ->Option bSource#

(<$) :: a ->Option b ->Option aSource#

FunctorLastSource#

Since: 4.9.0.0

Instance details

Defined inData.Semigroup

Methods

fmap :: (a -> b) ->Last a ->Last bSource#

(<$) :: a ->Last b ->Last aSource#

FunctorFirstSource#

Since: 4.9.0.0

Instance details

Defined inData.Semigroup

Methods

fmap :: (a -> b) ->First a ->First bSource#

(<$) :: a ->First b ->First aSource#

FunctorMaxSource#

Since: 4.9.0.0

Instance details

Defined inData.Semigroup

Methods

fmap :: (a -> b) ->Max a ->Max bSource#

(<$) :: a ->Max b ->Max aSource#

FunctorMinSource#

Since: 4.9.0.0

Instance details

Defined inData.Semigroup

Methods

fmap :: (a -> b) ->Min a ->Min bSource#

(<$) :: a ->Min b ->Min aSource#

FunctorComplexSource#

Since: 4.9.0.0

Instance details

Defined inData.Complex

Methods

fmap :: (a -> b) ->Complex a ->Complex bSource#

(<$) :: a ->Complex b ->Complex aSource#

Functor (Either a)Source#

Since: 3.0

Instance details

Defined inData.Either

Methods

fmap :: (a0 -> b) ->Either a a0 ->Either a bSource#

(<$) :: a0 ->Either a b ->Either a a0Source#

Functor (V1 ::Type ->Type)Source#

Since: 4.9.0.0

Instance details

Defined inGHC.Generics

Methods

fmap :: (a -> b) ->V1 a ->V1 bSource#

(<$) :: a ->V1 b ->V1 aSource#

Functor (U1 ::Type ->Type)Source#

Since: 4.9.0.0

Instance details

Defined inGHC.Generics

Methods

fmap :: (a -> b) ->U1 a ->U1 bSource#

(<$) :: a ->U1 b ->U1 aSource#

Functor ((,) a)Source#

Since: 2.1

Instance details

Defined inGHC.Base

Methods

fmap :: (a0 -> b) -> (a, a0) -> (a, b)Source#

(<$) :: a0 -> (a, b) -> (a, a0)Source#

Functor (ST s)Source#

Since: 2.1

Instance details

Defined inGHC.ST

Methods

fmap :: (a -> b) ->ST s a ->ST s bSource#

(<$) :: a ->ST s b ->ST s aSource#

Functor (Proxy ::Type ->Type)Source#

Since: 4.7.0.0

Instance details

Defined inData.Proxy

Methods

fmap :: (a -> b) ->Proxy a ->Proxy bSource#

(<$) :: a ->Proxy b ->Proxy aSource#

Arrow a =>Functor (ArrowMonad a)Source#

Since: 4.6.0.0

Instance details

Defined inControl.Arrow

Methods

fmap :: (a0 -> b) ->ArrowMonad a a0 ->ArrowMonad a bSource#

(<$) :: a0 ->ArrowMonad a b ->ArrowMonad a a0Source#

Monad m =>Functor (WrappedMonad m)Source#

Since: 2.1

Instance details

Defined inControl.Applicative

Methods

fmap :: (a -> b) ->WrappedMonad m a ->WrappedMonad m bSource#

(<$) :: a ->WrappedMonad m b ->WrappedMonad m aSource#

Functor (ST s)Source#

Since: 2.1

Instance details

Defined inControl.Monad.ST.Lazy.Imp

Methods

fmap :: (a -> b) ->ST s a ->ST s bSource#

(<$) :: a ->ST s b ->ST s aSource#

Functor (Arg a)Source#

Since: 4.9.0.0

Instance details

Defined inData.Semigroup

Methods

fmap :: (a0 -> b) ->Arg a a0 ->Arg a bSource#

(<$) :: a0 ->Arg a b ->Arg a a0Source#

Functor f =>Functor (Rec1 f)Source#

Since: 4.9.0.0

Instance details

Defined inGHC.Generics

Methods

fmap :: (a -> b) ->Rec1 f a ->Rec1 f bSource#

(<$) :: a ->Rec1 f b ->Rec1 f aSource#

Functor (URecChar ::Type ->Type)Source#

Since: 4.9.0.0

Instance details

Defined inGHC.Generics

Methods

fmap :: (a -> b) ->URecChar a ->URecChar bSource#

(<$) :: a ->URecChar b ->URecChar aSource#

Functor (URecDouble ::Type ->Type)Source#

Since: 4.9.0.0

Instance details

Defined inGHC.Generics

Methods

fmap :: (a -> b) ->URecDouble a ->URecDouble bSource#

(<$) :: a ->URecDouble b ->URecDouble aSource#

Functor (URecFloat ::Type ->Type)Source#

Since: 4.9.0.0

Instance details

Defined inGHC.Generics

Methods

fmap :: (a -> b) ->URecFloat a ->URecFloat bSource#

(<$) :: a ->URecFloat b ->URecFloat aSource#

Functor (URecInt ::Type ->Type)Source#

Since: 4.9.0.0

Instance details

Defined inGHC.Generics

Methods

fmap :: (a -> b) ->URecInt a ->URecInt bSource#

(<$) :: a ->URecInt b ->URecInt aSource#

Functor (URecWord ::Type ->Type)Source#

Since: 4.9.0.0

Instance details

Defined inGHC.Generics

Methods

fmap :: (a -> b) ->URecWord a ->URecWord bSource#

(<$) :: a ->URecWord b ->URecWord aSource#

Functor (URec (Ptr ()) ::Type ->Type)Source#

Since: 4.9.0.0

Instance details

Defined inGHC.Generics

Methods

fmap :: (a -> b) ->URec (Ptr ()) a ->URec (Ptr ()) bSource#

(<$) :: a ->URec (Ptr ()) b ->URec (Ptr ()) aSource#

Functor f =>Functor (Alt f)Source#

Since: 4.8.0.0

Instance details

Defined inData.Semigroup.Internal

Methods

fmap :: (a -> b) ->Alt f a ->Alt f bSource#

(<$) :: a ->Alt f b ->Alt f aSource#

Functor f =>Functor (Ap f)Source#

Since: 4.12.0.0

Instance details

Defined inData.Monoid

Methods

fmap :: (a -> b) ->Ap f a ->Ap f bSource#

(<$) :: a ->Ap f b ->Ap f aSource#

Functor (Const m ::Type ->Type)Source#

Since: 2.1

Instance details

Defined inData.Functor.Const

Methods

fmap :: (a -> b) ->Const m a ->Const m bSource#

(<$) :: a ->Const m b ->Const m aSource#

Arrow a =>Functor (WrappedArrow a b)Source#

Since: 2.1

Instance details

Defined inControl.Applicative

Methods

fmap :: (a0 -> b0) ->WrappedArrow a b a0 ->WrappedArrow a b b0Source#

(<$) :: a0 ->WrappedArrow a b b0 ->WrappedArrow a b a0Source#

Functor ((->) r ::Type ->Type)Source#

Since: 2.1

Instance details

Defined inGHC.Base

Methods

fmap :: (a -> b) -> (r -> a) -> r -> bSource#

(<$) :: a -> (r -> b) -> r -> aSource#

Functor (K1 i c ::Type ->Type)Source#

Since: 4.9.0.0

Instance details

Defined inGHC.Generics

Methods

fmap :: (a -> b) ->K1 i c a ->K1 i c bSource#

(<$) :: a ->K1 i c b ->K1 i c aSource#

(Functor f,Functor g) =>Functor (f:+: g)Source#

Since: 4.9.0.0

Instance details

Defined inGHC.Generics

Methods

fmap :: (a -> b) -> (f:+: g) a -> (f:+: g) bSource#

(<$) :: a -> (f:+: g) b -> (f:+: g) aSource#

(Functor f,Functor g) =>Functor (f:*: g)Source#

Since: 4.9.0.0

Instance details

Defined inGHC.Generics

Methods

fmap :: (a -> b) -> (f:*: g) a -> (f:*: g) bSource#

(<$) :: a -> (f:*: g) b -> (f:*: g) aSource#

(Functor f,Functor g) =>Functor (Sum f g)Source#

Since: 4.9.0.0

Instance details

Defined inData.Functor.Sum

Methods

fmap :: (a -> b) ->Sum f g a ->Sum f g bSource#

(<$) :: a ->Sum f g b ->Sum f g aSource#

(Functor f,Functor g) =>Functor (Product f g)Source#

Since: 4.9.0.0

Instance details

Defined inData.Functor.Product

Methods

fmap :: (a -> b) ->Product f g a ->Product f g bSource#

(<$) :: a ->Product f g b ->Product f g aSource#

Functor f =>Functor (M1 i c f)Source#

Since: 4.9.0.0

Instance details

Defined inGHC.Generics

Methods

fmap :: (a -> b) ->M1 i c f a ->M1 i c f bSource#

(<$) :: a ->M1 i c f b ->M1 i c f aSource#

(Functor f,Functor g) =>Functor (f:.: g)Source#

Since: 4.9.0.0

Instance details

Defined inGHC.Generics

Methods

fmap :: (a -> b) -> (f:.: g) a -> (f:.: g) bSource#

(<$) :: a -> (f:.: g) b -> (f:.: g) aSource#

(Functor f,Functor g) =>Functor (Compose f g)Source#

Since: 4.9.0.0

Instance details

Defined inData.Functor.Compose

Methods

fmap :: (a -> b) ->Compose f g a ->Compose f g bSource#

(<$) :: a ->Compose f g b ->Compose f g aSource#

(<$) ::Functor f => a -> f b -> f ainfixl 4Source#

Replace all locations in the input with the same value. The default definition isfmap .const, but this may be overridden with a more efficient version.

($>) ::Functor f => f a -> b -> f binfixl 4Source#

Flipped version of<$.

Examples

Expand

Replace the contents of aMaybeInt with a constantString:

>>>Nothing $> "foo"Nothing>>>Just 90210 $> "foo"Just "foo"

Replace the contents of anEitherIntInt with a constantString, resulting in anEitherIntString:

>>>Left 8675309 $> "foo"Left 8675309>>>Right 8675309 $> "foo"Right "foo"

Replace each element of a list with a constantString:

>>>[1,2,3] $> "foo"["foo","foo","foo"]

Replace the second element of a pair with a constantString:

>>>(1,2) $> "foo"(1,"foo")

Since: 4.7.0.0

(<$>) ::Functor f => (a -> b) -> f a -> f binfixl 4Source#

An infix synonym forfmap.

The name of this operator is an allusion to$. Note the similarities between their types:

 ($)  ::              (a -> b) ->   a ->   b(<$>) :: Functor f => (a -> b) -> f a -> f b

Whereas$ is function application,<$> is function application lifted over aFunctor.

Examples

Expand

Convert from aMaybeInt to aMaybeString usingshow:

>>>show <$> NothingNothing>>>show <$> Just 3Just "3"

Convert from anEitherIntInt to anEitherIntString usingshow:

>>>show <$> Left 17Left 17>>>show <$> Right 17Right "17"

Double each element of a list:

>>>(*2) <$> [1,2,3][2,4,6]

Applyeven to the second element of a pair:

>>>even <$> (2,2)(2,True)

(<&>) ::Functor f => f a -> (a -> b) -> f binfixl 1Source#

Flipped version of<$>.

(<&>) =flipfmap

Examples

Expand

Apply(+1) to a list, aJust and aRight:

>>>Just 2 <&> (+1)Just 3
>>>[1,2,3] <&> (+1)[2,3,4]
>>>Right 3 <&> (+1)Right 4

Since: 4.11.0.0

void ::Functor f => f a -> f ()Source#

void value discards or ignores the result of evaluation, such as the return value of anIO action.

Examples

Expand

Replace the contents of aMaybeInt with unit:

>>>void NothingNothing>>>void (Just 3)Just ()

Replace the contents of anEitherIntInt with unit, resulting in anEitherInt '()':

>>>void (Left 8675309)Left 8675309>>>void (Right 8675309)Right ()

Replace every element of a list with unit:

>>>void [1,2,3][(),(),()]

Replace the second element of a pair with unit:

>>>void (1,2)(1,())

Discard the result of anIO action:

>>>mapM print [1,2]12[(),()]>>>void $ mapM print [1,2]12

Produced byHaddock version 2.20.0


[8]ページ先頭

©2009-2025 Movatter.jp