| Safe Haskell | Safe | 
|---|---|
| Language | Haskell2010 | 
Universum.Functor.Reexport
Description
This module reexports functionality regarding Functor type class.
Synopsis
- (&&&) :: Arrow a => a b c -> a b c' -> a b (c, c')
 - class Bifunctor (p :: Type -> Type -> Type) where
 - class Functor (f :: Type -> Type) where
 - void :: Functor f => f a -> f ()
 - ($>) :: Functor f => f a -> b -> f b
 - (<$>) :: Functor f => (a -> b) -> f a -> f b
 - newtype Compose (f :: k -> Type) (g :: k1 -> k) (a :: k1) = Compose {
- getCompose :: f (g a)
 
 - newtype Identity a = Identity {
- runIdentity :: a
 
 
Documentation
(&&&) :: Arrow a => a b c -> a b c' -> a b (c, c') infixr 3 #
Fanout: send the input to both argument arrows and combine their output.
The default definition may be overridden with a more efficient version if desired.
class Bifunctor (p :: Type -> Type -> Type) where #
A bifunctor is a type constructor that takes
 two type arguments and is a functor in both arguments. That
 is, unlike with Functor, a type constructor such as Either
 does not need to be partially applied for a Bifunctor
 instance, and the methods in this class permit mapping
 functions over the Left value or the Right value,
 or both at the same time.
Formally, the class Bifunctor represents a bifunctor
 from Hask -> Hask.
Intuitively it is a bifunctor where both the first and second arguments are covariant.
You can define a Bifunctor by either defining bimap or by
 defining both first and second.
If you supply bimap, you should ensure that:
bimapidid≡id
If you supply first and second, ensure:
firstid≡idsecondid≡id
If you supply both, you should also ensure:
bimapf g ≡firstf.secondg
These ensure by parametricity:
bimap(f.g) (h.i) ≡bimapf h.bimapg ifirst(f.g) ≡firstf.firstgsecond(f.g) ≡secondf.secondg
Since: base-4.8.0.0
Methods
bimap :: (a -> b) -> (c -> d) -> p a c -> p b d #
Map over both arguments at the same time.
bimapf g ≡firstf.secondg
Examples
>>>bimap toUpper (+1) ('j', 3)('J',4)
>>>bimap toUpper (+1) (Left 'j')Left 'J'
>>>bimap toUpper (+1) (Right 3)Right 4
Instances
| Bifunctor Either | Since: base-4.8.0.0  | 
| Bifunctor (,) | Since: base-4.8.0.0  | 
| Bifunctor Arg | Since: base-4.9.0.0  | 
| Bifunctor ((,,) x1) | Since: base-4.8.0.0  | 
| Bifunctor (Const :: Type -> Type -> Type) | Since: base-4.8.0.0  | 
| Bifunctor (K1 i :: Type -> Type -> Type) | Since: base-4.9.0.0  | 
| Bifunctor ((,,,) x1 x2) | Since: base-4.8.0.0  | 
| Bifunctor ((,,,,) x1 x2 x3) | Since: base-4.8.0.0  | 
| Bifunctor ((,,,,,) x1 x2 x3 x4) | Since: base-4.8.0.0  | 
| Bifunctor ((,,,,,,) x1 x2 x3 x4 x5) | Since: base-4.8.0.0  | 
class Functor (f :: Type -> Type) where #
A type f is a Functor if it provides a function fmap which, given any types a and b
lets you apply any function from (a -> b) to turn an f a into an f b, preserving the
structure of f. Furthermore f needs to adhere to the following:
Note, that the second law follows from the free theorem of the type fmap and
the first law, so you need only check that the former condition holds.
Minimal complete definition
Methods
fmap :: (a -> b) -> f a -> f b #
Using ApplicativeDo: '' can be understood as
 the fmap f asdo expression
do a <- as pure (f a)
with an inferred Functor constraint.
Instances
| Functor [] | Since: base-2.1  | 
| Functor Maybe | Since: base-2.1  | 
| Functor IO | Since: base-2.1  | 
| Functor Par1 | Since: base-4.9.0.0  | 
| Functor Q | |
| Functor Complex | Since: base-4.9.0.0  | 
| Functor Min | Since: base-4.9.0.0  | 
| Functor Max | Since: base-4.9.0.0  | 
| Functor First | Since: base-4.9.0.0  | 
| Functor Last | Since: base-4.9.0.0  | 
| Functor Option | Since: base-4.9.0.0  | 
| Functor ZipList | Since: base-2.1  | 
| Functor Identity | Since: base-4.8.0.0  | 
| Functor STM | Since: base-4.3.0.0  | 
| Functor First | Since: base-4.8.0.0  | 
| Functor Last | Since: base-4.8.0.0  | 
| Functor Dual | Since: base-4.8.0.0  | 
| Functor Sum | Since: base-4.8.0.0  | 
| Functor Product | Since: base-4.8.0.0  | 
| Functor Down | Since: base-4.11.0.0  | 
| Functor ReadPrec | Since: base-2.1  | 
| Functor ReadP | Since: base-2.1  | 
| Functor NonEmpty | Since: base-4.9.0.0  | 
| Functor Put | |
| Functor IntMap | |
| Functor Tree | |
| Functor Seq | |
| Functor FingerTree | |
Defined in Data.Sequence.Internal Methods fmap :: (a -> b) -> FingerTree a -> FingerTree b # (<$) :: a -> FingerTree b -> FingerTree a #  | |
| Functor Digit | |
| Functor Node | |
| Functor Elem | |
| Functor ViewL | |
| Functor ViewR | |
| Functor SmallArray | |
Defined in Data.Primitive.SmallArray Methods fmap :: (a -> b) -> SmallArray a -> SmallArray b # (<$) :: a -> SmallArray b -> SmallArray a #  | |
| Functor Array | |
| Functor Vector | |
| Functor Id | |
| Functor Box | |
| Functor P | Since: base-4.8.0.0  | 
Defined in Text.ParserCombinators.ReadP  | |
| Functor (Either a) | Since: base-3.0  | 
| Functor (V1 :: Type -> Type) | Since: base-4.9.0.0  | 
| Functor (U1 :: Type -> Type) | Since: base-4.9.0.0  | 
| Functor ((,) a) | Since: base-2.1  | 
| Functor (Array i) | Since: base-2.1  | 
| Functor (Arg a) | Since: base-4.9.0.0  | 
| Monad m => Functor (WrappedMonad m) | Since: base-2.1  | 
Defined in Control.Applicative Methods fmap :: (a -> b) -> WrappedMonad m a -> WrappedMonad m b # (<$) :: a -> WrappedMonad m b -> WrappedMonad m a #  | |
| Arrow a => Functor (ArrowMonad a) | Since: base-4.6.0.0  | 
Defined in Control.Arrow Methods fmap :: (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b # (<$) :: a0 -> ArrowMonad a b -> ArrowMonad a a0 #  | |
| Functor (Proxy :: Type -> Type) | Since: base-4.7.0.0  | 
| Functor (Map k) | |
| Functor m => Functor (MaybeT m) | |
| Monad m => Functor (Handler m) | |
| Functor m => Functor (ListT m) | |
| Functor (HashMap k) | |
| Functor f => Functor (Rec1 f) | Since: base-4.9.0.0  | 
| Functor (URec Char :: Type -> Type) | Since: base-4.9.0.0  | 
| Functor (URec Double :: Type -> Type) | Since: base-4.9.0.0  | 
| Functor (URec Float :: Type -> Type) | Since: base-4.9.0.0  | 
| Functor (URec Int :: Type -> Type) | Since: base-4.9.0.0  | 
| Functor (URec Word :: Type -> Type) | Since: base-4.9.0.0  | 
| Functor (URec (Ptr ()) :: Type -> Type) | Since: base-4.9.0.0  | 
| Functor ((,,) a b) | Since: base-4.14.0.0  | 
| Arrow a => Functor (WrappedArrow a b) | Since: base-2.1  | 
Defined in Control.Applicative Methods fmap :: (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 # (<$) :: a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 #  | |
| Functor m => Functor (Kleisli m a) | Since: base-4.14.0.0  | 
| Functor (Const m :: Type -> Type) | Since: base-2.1  | 
| Functor f => Functor (Ap f) | Since: base-4.12.0.0  | 
| Functor f => Functor (Alt f) | Since: base-4.8.0.0  | 
| (Applicative f, Monad f) => Functor (WhenMissing f x) | Since: containers-0.5.9  | 
Defined in Data.IntMap.Internal Methods fmap :: (a -> b) -> WhenMissing f x a -> WhenMissing f x b # (<$) :: a -> WhenMissing f x b -> WhenMissing f x a #  | |
| Functor m => Functor (ExceptT e m) | |
| Functor m => Functor (StateT s m) | |
| Functor m => Functor (ReaderT r m) | |
| Monad m => Functor (Focusing m s) | |
| Functor (k (May s)) => Functor (FocusingMay k s) | |
Defined in Lens.Micro.Mtl.Internal Methods fmap :: (a -> b) -> FocusingMay k s a -> FocusingMay k s b # (<$) :: a -> FocusingMay k s b -> FocusingMay k s a #  | |
| Functor (Effect m r) | |
| Functor m => Functor (IdentityT m) | |
| Functor m => Functor (ErrorT e m) | |
| Functor m => Functor (StateT s m) | |
| Functor m => Functor (WriterT w m) | |
| Functor m => Functor (WriterT w m) | |
| Monad m => Functor (Bundle m v) | |
| Functor (Bazaar a b) | |
Defined in Lens.Micro  | |
| Functor m => Functor (StateT s m) | |
Defined in Lens.Micro  | |
| Functor ((->) r :: Type -> Type) | Since: base-2.1  | 
| Functor (K1 i c :: Type -> Type) | Since: base-4.9.0.0  | 
| (Functor f, Functor g) => Functor (f :+: g) | Since: base-4.9.0.0  | 
| (Functor f, Functor g) => Functor (f :*: g) | Since: base-4.9.0.0  | 
| Functor ((,,,) a b c) | Since: base-4.14.0.0  | 
| (Functor f, Functor g) => Functor (Product f g) | Since: base-4.9.0.0  | 
| (Functor f, Functor g) => Functor (Sum f g) | Since: base-4.9.0.0  | 
| Functor f => Functor (WhenMatched f x y) | Since: containers-0.5.9  | 
Defined in Data.IntMap.Internal Methods fmap :: (a -> b) -> WhenMatched f x y a -> WhenMatched f x y b # (<$) :: a -> WhenMatched f x y b -> WhenMatched f x y a #  | |
| (Applicative f, Monad f) => Functor (WhenMissing f k x) | Since: containers-0.5.9  | 
Defined in Data.Map.Internal Methods fmap :: (a -> b) -> WhenMissing f k x a -> WhenMissing f k x b # (<$) :: a -> WhenMissing f k x b -> WhenMissing f k x a #  | |
| Monad m => Functor (FocusingWith w m s) | |
Defined in Lens.Micro.Mtl.Internal Methods fmap :: (a -> b) -> FocusingWith w m s a -> FocusingWith w m s b # (<$) :: a -> FocusingWith w m s b -> FocusingWith w m s a #  | |
| Functor (k (s, w)) => Functor (FocusingPlus w k s) | |
Defined in Lens.Micro.Mtl.Internal Methods fmap :: (a -> b) -> FocusingPlus w k s a -> FocusingPlus w k s b # (<$) :: a -> FocusingPlus w k s b -> FocusingPlus w k s a #  | |
| Functor (k (f s)) => Functor (FocusingOn f k s) | |
Defined in Lens.Micro.Mtl.Internal Methods fmap :: (a -> b) -> FocusingOn f k s a -> FocusingOn f k s b # (<$) :: a -> FocusingOn f k s b -> FocusingOn f k s a #  | |
| Functor (k (Err e s)) => Functor (FocusingErr e k s) | |
Defined in Lens.Micro.Mtl.Internal Methods fmap :: (a -> b) -> FocusingErr e k s a -> FocusingErr e k s b # (<$) :: a -> FocusingErr e k s b -> FocusingErr e k s a #  | |
| Functor f => Functor (M1 i c f) | Since: base-4.9.0.0  | 
| (Functor f, Functor g) => Functor (f :.: g) | Since: base-4.9.0.0  | 
| (Functor f, Functor g) => Functor (Compose f g) | Since: base-4.9.0.0  | 
| Functor f => Functor (WhenMatched f k x y) | Since: containers-0.5.9  | 
Defined in Data.Map.Internal Methods fmap :: (a -> b) -> WhenMatched f k x y a -> WhenMatched f k x y b # (<$) :: a -> WhenMatched f k x y b -> WhenMatched f k x y a #  | |
| Functor m => Functor (RWST r w s m) | |
| Functor (EffectRWS w st m s) | |
| Functor m => Functor (RWST r w s m) | |
void :: Functor f => f a -> f () #
 discards or ignores the result of evaluation, such
 as the return value of an void valueIO action.
Using ApplicativeDo: '' can be understood as the
 void asdo expression
do as pure ()
with an inferred Functor constraint.
Examples
Replace the contents of a  with unit:Maybe Int
>>>void NothingNothing>>>void (Just 3)Just ()
Replace the contents of an 
 with unit, resulting in an Either Int Int:Either Int ()
>>>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 an IO action:
>>>mapM print [1,2]1 2 [(),()]>>>void $ mapM print [1,2]1 2
($>) :: Functor f => f a -> b -> f b infixl 4 #
Flipped version of <$.
Using ApplicativeDo: 'as ' can be understood as the
 $> bdo expression
do as pure b
with an inferred Functor constraint.
Examples
Replace the contents of a  with a constant
 Maybe IntString:
>>>Nothing $> "foo"Nothing>>>Just 90210 $> "foo"Just "foo"
Replace the contents of an 
 with a constant Either Int IntString, resulting in an :Either
 Int String
>>>Left 8675309 $> "foo"Left 8675309>>>Right 8675309 $> "foo"Right "foo"
Replace each element of a list with a constant String:
>>>[1,2,3] $> "foo"["foo","foo","foo"]
Replace the second element of a pair with a constant String:
>>>(1,2) $> "foo"(1,"foo")
Since: base-4.7.0.0
(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 #
An infix synonym for fmap.
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 a Functor.
Examples
Convert from a  to a Maybe Int using Maybe
 Stringshow:
>>>show <$> NothingNothing>>>show <$> Just 3Just "3"
Convert from an  to an
 Either Int IntEither IntString using show:
>>>show <$> Left 17Left 17>>>show <$> Right 17Right "17"
Double each element of a list:
>>>(*2) <$> [1,2,3][2,4,6]
Apply even to the second element of a pair:
>>>even <$> (2,2)(2,True)
newtype Compose (f :: k -> Type) (g :: k1 -> k) (a :: k1) infixr 9 #
Right-to-left composition of functors. The composition of applicative functors is always applicative, but the composition of monads is not always a monad.
Constructors
| Compose infixr 9 | |
Fields 
  | |
Instances
| Functor f => Generic1 (Compose f g :: k -> Type) | Since: base-4.9.0.0  | 
| TestEquality f => TestEquality (Compose f g :: k2 -> Type) | The deduction (via generativity) that if  Since: base-4.14.0.0  | 
Defined in Data.Functor.Compose  | |
| Unbox (f (g a)) => Vector Vector (Compose f g a) | |
Defined in Data.Vector.Unboxed.Base Methods basicUnsafeFreeze :: PrimMonad m => Mutable Vector (PrimState m) (Compose f g a) -> m (Vector (Compose f g a)) # basicUnsafeThaw :: PrimMonad m => Vector (Compose f g a) -> m (Mutable Vector (PrimState m) (Compose f g a)) # basicLength :: Vector (Compose f g a) -> Int # basicUnsafeSlice :: Int -> Int -> Vector (Compose f g a) -> Vector (Compose f g a) # basicUnsafeIndexM :: Monad m => Vector (Compose f g a) -> Int -> m (Compose f g a) # basicUnsafeCopy :: PrimMonad m => Mutable Vector (PrimState m) (Compose f g a) -> Vector (Compose f g a) -> m () # elemseq :: Vector (Compose f g a) -> Compose f g a -> b -> b #  | |
| Unbox (f (g a)) => MVector MVector (Compose f g a) | |
Defined in Data.Vector.Unboxed.Base Methods basicLength :: MVector s (Compose f g a) -> Int # basicUnsafeSlice :: Int -> Int -> MVector s (Compose f g a) -> MVector s (Compose f g a) # basicOverlaps :: MVector s (Compose f g a) -> MVector s (Compose f g a) -> Bool # basicUnsafeNew :: PrimMonad m => Int -> m (MVector (PrimState m) (Compose f g a)) # basicInitialize :: PrimMonad m => MVector (PrimState m) (Compose f g a) -> m () # basicUnsafeReplicate :: PrimMonad m => Int -> Compose f g a -> m (MVector (PrimState m) (Compose f g a)) # basicUnsafeRead :: PrimMonad m => MVector (PrimState m) (Compose f g a) -> Int -> m (Compose f g a) # basicUnsafeWrite :: PrimMonad m => MVector (PrimState m) (Compose f g a) -> Int -> Compose f g a -> m () # basicClear :: PrimMonad m => MVector (PrimState m) (Compose f g a) -> m () # basicSet :: PrimMonad m => MVector (PrimState m) (Compose f g a) -> Compose f g a -> m () # basicUnsafeCopy :: PrimMonad m => MVector (PrimState m) (Compose f g a) -> MVector (PrimState m) (Compose f g a) -> m () # basicUnsafeMove :: PrimMonad m => MVector (PrimState m) (Compose f g a) -> MVector (PrimState m) (Compose f g a) -> m () # basicUnsafeGrow :: PrimMonad m => MVector (PrimState m) (Compose f g a) -> Int -> m (MVector (PrimState m) (Compose f g a)) #  | |
| (Functor f, Functor g) => Functor (Compose f g) | Since: base-4.9.0.0  | 
| (Applicative f, Applicative g) => Applicative (Compose f g) | Since: base-4.9.0.0  | 
Defined in Data.Functor.Compose  | |
| (Foldable f, Foldable g) => Foldable (Compose f g) | Since: base-4.9.0.0  | 
Defined in Data.Functor.Compose Methods fold :: Monoid m => Compose f g m -> m # foldMap :: Monoid m => (a -> m) -> Compose f g a -> m # foldMap' :: Monoid m => (a -> m) -> Compose f g a -> m # foldr :: (a -> b -> b) -> b -> Compose f g a -> b # foldr' :: (a -> b -> b) -> b -> Compose f g a -> b # foldl :: (b -> a -> b) -> b -> Compose f g a -> b # foldl' :: (b -> a -> b) -> b -> Compose f g a -> b # foldr1 :: (a -> a -> a) -> Compose f g a -> a # foldl1 :: (a -> a -> a) -> Compose f g a -> a # toList :: Compose f g a -> [a] # null :: Compose f g a -> Bool # length :: Compose f g a -> Int # elem :: Eq a => a -> Compose f g a -> Bool # maximum :: Ord a => Compose f g a -> a # minimum :: Ord a => Compose f g a -> a #  | |
| (Traversable f, Traversable g) => Traversable (Compose f g) | Since: base-4.9.0.0  | 
Defined in Data.Functor.Compose  | |
| (Eq1 f, Eq1 g) => Eq1 (Compose f g) | Since: base-4.9.0.0  | 
| (Ord1 f, Ord1 g) => Ord1 (Compose f g) | Since: base-4.9.0.0  | 
Defined in Data.Functor.Compose  | |
| (Read1 f, Read1 g) => Read1 (Compose f g) | Since: base-4.9.0.0  | 
Defined in Data.Functor.Compose Methods liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Compose f g a) # liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Compose f g a] # liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Compose f g a) # liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Compose f g a] #  | |
| (Show1 f, Show1 g) => Show1 (Compose f g) | Since: base-4.9.0.0  | 
| (Alternative f, Applicative g) => Alternative (Compose f g) | Since: base-4.9.0.0  | 
| (NFData1 f, NFData1 g) => NFData1 (Compose f g) | Since: deepseq-1.4.3.0  | 
Defined in Control.DeepSeq  | |
| (Hashable1 f, Hashable1 g) => Hashable1 (Compose f g) | |
Defined in Data.Hashable.Class  | |
| (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) | Since: base-4.9.0.0  | 
| (Typeable a, Typeable f, Typeable g, Typeable k1, Typeable k2, Data (f (g a))) => Data (Compose f g a) | Since: base-4.9.0.0  | 
Defined in Data.Functor.Compose Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g0. g0 -> c g0) -> Compose f g a -> c (Compose f g a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Compose f g a) # toConstr :: Compose f g a -> Constr # dataTypeOf :: Compose f g a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Compose f g a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Compose f g a)) # gmapT :: (forall b. Data b => b -> b) -> Compose f g a -> Compose f g a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Compose f g a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Compose f g a -> r # gmapQ :: (forall d. Data d => d -> u) -> Compose f g a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Compose f g a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Compose f g a -> m (Compose f g a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Compose f g a -> m (Compose f g a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Compose f g a -> m (Compose f g a) #  | |
| (Ord1 f, Ord1 g, Ord a) => Ord (Compose f g a) | Since: base-4.9.0.0  | 
Defined in Data.Functor.Compose Methods compare :: Compose f g a -> Compose f g a -> Ordering # (<) :: Compose f g a -> Compose f g a -> Bool # (<=) :: Compose f g a -> Compose f g a -> Bool # (>) :: Compose f g a -> Compose f g a -> Bool # (>=) :: Compose f g a -> Compose f g a -> Bool #  | |
| (Read1 f, Read1 g, Read a) => Read (Compose f g a) | Since: base-4.9.0.0  | 
| (Show1 f, Show1 g, Show a) => Show (Compose f g a) | Since: base-4.9.0.0  | 
| Generic (Compose f g a) | Since: base-4.9.0.0  | 
| (NFData1 f, NFData1 g, NFData a) => NFData (Compose f g a) | Since: deepseq-1.4.3.0  | 
Defined in Control.DeepSeq  | |
| (Hashable1 f, Hashable1 g, Hashable a) => Hashable (Compose f g a) | In general,   | 
Defined in Data.Hashable.Class  | |
| Unbox (f (g a)) => Unbox (Compose f g a) | |
Defined in Data.Vector.Unboxed.Base  | |
| type Rep1 (Compose f g :: k -> Type) | |
Defined in Data.Functor.Compose  | |
| newtype MVector s (Compose f g a) | |
Defined in Data.Vector.Unboxed.Base  | |
| type Rep (Compose f g a) | |
Defined in Data.Functor.Compose  | |
| newtype Vector (Compose f g a) | |
Defined in Data.Vector.Unboxed.Base  | |
Identity functor and monad. (a non-strict monad)
Since: base-4.8.0.0
Constructors
| Identity | |
Fields 
  | |