Copyright | (c) 2016 Stephen Diehl (c) 2016-2018 Serokell (c) 2018-2023 Kowainik |
---|---|
License | MIT |
Maintainer | Kowainik <xrom.xkov@gmail.com> |
Stability | Stable |
Portability | Portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Relude.Applicative
Contents
Description
This module contains reexports of Applicative
and related functional.
Additionally, it provides convenient combinators to work with Applicative
.
Synopsis
- class Applicative f => Alternative (f :: Type -> Type) where
- class Functor f => Applicative (f :: Type -> Type) where
- newtype Const a (b :: k) = Const {
- getConst :: a
- newtype ZipList a = ZipList {
- getZipList :: [a]
- liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
- optional :: Alternative f => f a -> f (Maybe a)
- (<**>) :: Applicative f => f a -> f (a -> b) -> f b
- pass :: Applicative f => f ()
- appliedTo :: Applicative f => f a -> f (a -> b) -> f b
Reexports
Main data types and functions reexported from Control.Applicative.
class Applicative f => Alternative (f :: Type -> Type) where #
Instances
class Functor f => Applicative (f :: Type -> Type) where #
Instances
Applicative ZipList | |
Applicative Complex | |
Applicative Identity | |
Applicative First | |
Applicative Last | |
Applicative Down | |
Applicative First | |
Applicative Last | |
Applicative Max | |
Applicative Min | |
Applicative Dual | |
Applicative Product | |
Applicative Sum | |
Applicative NonEmpty | |
Applicative STM | |
Applicative Par1 | |
Applicative P | |
Applicative ReadP | |
Applicative ReadPrec | |
Applicative Put | |
Applicative Seq | |
Applicative Tree | |
Applicative IO | |
Applicative Q | |
Applicative Maybe | |
Applicative Solo | |
Applicative List | |
Monad m => Applicative (WrappedMonad m) | |
Defined in Control.Applicative Methods pure :: a -> WrappedMonad m a # (<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b # liftA2 :: (a -> b -> c) -> WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m c # (*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b # (<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a # | |
Arrow a => Applicative (ArrowMonad a) | |
Defined in Control.Arrow Methods pure :: a0 -> ArrowMonad a a0 # (<*>) :: ArrowMonad a (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b # liftA2 :: (a0 -> b -> c) -> ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a c # (*>) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a b # (<*) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a a0 # | |
Applicative (Either e) | |
Applicative (Proxy :: Type -> Type) | |
Applicative (U1 :: Type -> Type) | |
(Functor m, Monad m) => Applicative (MaybeT m) | |
Monoid a => Applicative ((,) a) | |
Arrow a => Applicative (WrappedArrow a b) | |
Defined in Control.Applicative Methods pure :: a0 -> WrappedArrow a b a0 # (<*>) :: WrappedArrow a b (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 # liftA2 :: (a0 -> b0 -> c) -> WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b c # (*>) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b b0 # (<*) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 # | |
Applicative m => Applicative (Kleisli m a) | |
Defined in Control.Arrow | |
Monoid m => Applicative (Const m :: Type -> Type) | |
Applicative f => Applicative (Ap f) | |
Applicative f => Applicative (Alt f) | |
(Generic1 f, Applicative (Rep1 f)) => Applicative (Generically1 f) | |
Defined in GHC.Generics Methods pure :: a -> Generically1 f a # (<*>) :: Generically1 f (a -> b) -> Generically1 f a -> Generically1 f b # liftA2 :: (a -> b -> c) -> Generically1 f a -> Generically1 f b -> Generically1 f c # (*>) :: Generically1 f a -> Generically1 f b -> Generically1 f b # (<*) :: Generically1 f a -> Generically1 f b -> Generically1 f a # | |
Applicative f => Applicative (Rec1 f) | |
(Applicative f, Monad f) => Applicative (WhenMissing f x) | |
Defined in Data.IntMap.Internal Methods pure :: a -> WhenMissing f x a # (<*>) :: WhenMissing f x (a -> b) -> WhenMissing f x a -> WhenMissing f x b # liftA2 :: (a -> b -> c) -> WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x c # (*>) :: WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x b # (<*) :: WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x a # | |
(Monoid w, Functor m, Monad m) => Applicative (AccumT w m) | |
Defined in Control.Monad.Trans.Accum | |
(Functor m, Monad m) => Applicative (ExceptT e m) | |
Defined in Control.Monad.Trans.Except | |
Applicative m => Applicative (IdentityT m) | |
Defined in Control.Monad.Trans.Identity | |
Applicative m => Applicative (ReaderT r m) | |
Defined in Control.Monad.Trans.Reader | |
(Functor m, Monad m) => Applicative (SelectT r m) | |
Defined in Control.Monad.Trans.Select | |
(Functor m, Monad m) => Applicative (StateT s m) | |
Defined in Control.Monad.Trans.State.Lazy | |
(Functor m, Monad m) => Applicative (StateT s m) | |
Defined in Control.Monad.Trans.State.Strict | |
(Functor m, Monad m) => Applicative (WriterT w m) | |
Defined in Control.Monad.Trans.Writer.CPS | |
(Monoid w, Applicative m) => Applicative (WriterT w m) | |
Defined in Control.Monad.Trans.Writer.Lazy | |
(Monoid w, Applicative m) => Applicative (WriterT w m) | |
Defined in Control.Monad.Trans.Writer.Strict | |
(Monoid a, Monoid b) => Applicative ((,,) a b) | |
(Applicative f, Applicative g) => Applicative (Product f g) | |
Defined in Data.Functor.Product | |
(Applicative f, Applicative g) => Applicative (f :*: g) | |
Monoid c => Applicative (K1 i c :: Type -> Type) | |
(Monad f, Applicative f) => Applicative (WhenMatched f x y) | |
Defined in Data.IntMap.Internal Methods pure :: a -> WhenMatched f x y a # (<*>) :: WhenMatched f x y (a -> b) -> WhenMatched f x y a -> WhenMatched f x y b # liftA2 :: (a -> b -> c) -> WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y c # (*>) :: WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y b # (<*) :: WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y a # | |
(Applicative f, Monad f) => Applicative (WhenMissing f k x) | |
Defined in Data.Map.Internal Methods pure :: a -> WhenMissing f k x a # (<*>) :: WhenMissing f k x (a -> b) -> WhenMissing f k x a -> WhenMissing f k x b # liftA2 :: (a -> b -> c) -> WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x c # (*>) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x b # (<*) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x a # | |
Applicative (ContT r m) | |
Defined in Control.Monad.Trans.Cont | |
(Monoid a, Monoid b, Monoid c) => Applicative ((,,,) a b c) | |
Defined in GHC.Base | |
Applicative ((->) r) | |
(Applicative f, Applicative g) => Applicative (Compose f g) | |
Defined in Data.Functor.Compose | |
(Applicative f, Applicative g) => Applicative (f :.: g) | |
Applicative f => Applicative (M1 i c f) | |
(Monad f, Applicative f) => Applicative (WhenMatched f k x y) | |
Defined in Data.Map.Internal Methods pure :: a -> WhenMatched f k x y a # (<*>) :: WhenMatched f k x y (a -> b) -> WhenMatched f k x y a -> WhenMatched f k x y b # liftA2 :: (a -> b -> c) -> WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y c # (*>) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y b # (<*) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y a # | |
(Functor m, Monad m) => Applicative (RWST r w s m) | |
Defined in Control.Monad.Trans.RWS.CPS | |
(Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) | |
Defined in Control.Monad.Trans.RWS.Lazy | |
(Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) | |
Defined in Control.Monad.Trans.RWS.Strict |
Instances
Generic1 (Const a :: k -> Type) | |
Bifoldable (Const :: Type -> Type -> Type) | |
Bifunctor (Const :: Type -> Type -> Type) | |
Bitraversable (Const :: Type -> Type -> Type) | |
Defined in Data.Bitraversable Methods bitraverse :: Applicative f => (a -> f c) -> (b -> f d) -> Const a b -> f (Const c d) # | |
NFData2 (Const :: Type -> Type -> Type) | |
Defined in Control.DeepSeq | |
Hashable2 (Const :: Type -> Type -> Type) | |
Defined in Data.Hashable.Class | |
Foldable (Const m :: Type -> Type) | |
Defined in Data.Functor.Const Methods fold :: Monoid m0 => Const m m0 -> m0 # foldMap :: Monoid m0 => (a -> m0) -> Const m a -> m0 # foldMap' :: Monoid m0 => (a -> m0) -> Const m a -> m0 # foldr :: (a -> b -> b) -> b -> Const m a -> b # foldr' :: (a -> b -> b) -> b -> Const m a -> b foldl :: (b -> a -> b) -> b -> Const m a -> b foldl' :: (b -> a -> b) -> b -> Const m a -> b # foldr1 :: (a -> a -> a) -> Const m a -> a foldl1 :: (a -> a -> a) -> Const m a -> a elem :: Eq a => a -> Const m a -> Bool maximum :: Ord a => Const m a -> a minimum :: Ord a => Const m a -> a | |
Contravariant (Const a :: Type -> Type) | |
Traversable (Const m :: Type -> Type) | |
Monoid m => Applicative (Const m :: Type -> Type) | |
Functor (Const m :: Type -> Type) | |
NFData a => NFData1 (Const a :: Type -> Type) | |
Defined in Control.DeepSeq | |
Hashable a => Hashable1 (Const a :: Type -> Type) | |
Defined in Data.Hashable.Class | |
(Typeable k, Data a, Typeable b) => Data (Const a b) | |
Defined in Data.Data Methods gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Const a b -> c (Const a b) gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Const a b) toConstr :: Const a b -> Constr dataTypeOf :: Const a b -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Const a b)) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Const a b)) gmapT :: (forall b0. Data b0 => b0 -> b0) -> Const a b -> Const a b gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Const a b -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Const a b -> r gmapQ :: (forall d. Data d => d -> u) -> Const a b -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Const a b -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Const a b -> m (Const a b) gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Const a b -> m (Const a b) gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Const a b -> m (Const a b) | |
IsString a => IsString (Const a b) | |
Defined in Data.String Methods fromString :: String -> Const a b # | |
Storable a => Storable (Const a b) | |
Defined in Data.Functor.Const | |
Monoid a => Monoid (Const a b) | |
Semigroup a => Semigroup (Const a b) | |
Bits a => Bits (Const a b) | |
Defined in Data.Functor.Const Methods (.&.) :: Const a b -> Const a b -> Const a b (.|.) :: Const a b -> Const a b -> Const a b xor :: Const a b -> Const a b -> Const a b # complement :: Const a b -> Const a b shift :: Const a b -> Int -> Const a b rotate :: Const a b -> Int -> Const a b setBit :: Const a b -> Int -> Const a b clearBit :: Const a b -> Int -> Const a b complementBit :: Const a b -> Int -> Const a b testBit :: Const a b -> Int -> Bool bitSizeMaybe :: Const a b -> Maybe Int shiftL :: Const a b -> Int -> Const a b unsafeShiftL :: Const a b -> Int -> Const a b shiftR :: Const a b -> Int -> Const a b unsafeShiftR :: Const a b -> Int -> Const a b rotateL :: Const a b -> Int -> Const a b | |
FiniteBits a => FiniteBits (Const a b) | |
Defined in Data.Functor.Const Methods finiteBitSize :: Const a b -> Int countLeadingZeros :: Const a b -> Int countTrailingZeros :: Const a b -> Int | |
Bounded a => Bounded (Const a b) | |
Enum a => Enum (Const a b) | |
Defined in Data.Functor.Const Methods succ :: Const a b -> Const a b # pred :: Const a b -> Const a b # fromEnum :: Const a b -> Int # enumFrom :: Const a b -> [Const a b] # enumFromThen :: Const a b -> Const a b -> [Const a b] # enumFromTo :: Const a b -> Const a b -> [Const a b] # enumFromThenTo :: Const a b -> Const a b -> Const a b -> [Const a b] # | |
Floating a => Floating (Const a b) | |
Defined in Data.Functor.Const Methods exp :: Const a b -> Const a b # sqrt :: Const a b -> Const a b # (**) :: Const a b -> Const a b -> Const a b # logBase :: Const a b -> Const a b -> Const a b # sin :: Const a b -> Const a b # cos :: Const a b -> Const a b # tan :: Const a b -> Const a b # asin :: Const a b -> Const a b # acos :: Const a b -> Const a b # atan :: Const a b -> Const a b # sinh :: Const a b -> Const a b # cosh :: Const a b -> Const a b # tanh :: Const a b -> Const a b # asinh :: Const a b -> Const a b # acosh :: Const a b -> Const a b # atanh :: Const a b -> Const a b # log1p :: Const a b -> Const a b expm1 :: Const a b -> Const a b | |
RealFloat a => RealFloat (Const a b) | |
Defined in Data.Functor.Const Methods floatRadix :: Const a b -> Integer # floatDigits :: Const a b -> Int # floatRange :: Const a b -> (Int, Int) # decodeFloat :: Const a b -> (Integer, Int) # encodeFloat :: Integer -> Int -> Const a b # significand :: Const a b -> Const a b scaleFloat :: Int -> Const a b -> Const a b isInfinite :: Const a b -> Bool # isDenormalized :: Const a b -> Bool # isNegativeZero :: Const a b -> Bool # | |
Generic (Const a b) | |
Ix a => Ix (Const a b) | |
Defined in Data.Functor.Const Methods range :: (Const a b, Const a b) -> [Const a b] index :: (Const a b, Const a b) -> Const a b -> Int unsafeIndex :: (Const a b, Const a b) -> Const a b -> Int inRange :: (Const a b, Const a b) -> Const a b -> Bool rangeSize :: (Const a b, Const a b) -> Int unsafeRangeSize :: (Const a b, Const a b) -> Int | |
Num a => Num (Const a b) | |
Defined in Data.Functor.Const | |
Read a => Read (Const a b) | |
Defined in Data.Functor.Const | |
Fractional a => Fractional (Const a b) | |
Integral a => Integral (Const a b) | |
Defined in Data.Functor.Const Methods quot :: Const a b -> Const a b -> Const a b # rem :: Const a b -> Const a b -> Const a b # div :: Const a b -> Const a b -> Const a b # mod :: Const a b -> Const a b -> Const a b # quotRem :: Const a b -> Const a b -> (Const a b, Const a b) # divMod :: Const a b -> Const a b -> (Const a b, Const a b) # | |
Real a => Real (Const a b) | |
Defined in Data.Functor.Const Methods toRational :: Const a b -> Rational # | |
RealFrac a => RealFrac (Const a b) | |
Show a => Show (Const a b) | |
NFData a => NFData (Const a b) | |
Defined in Control.DeepSeq | |
Eq a => Eq (Const a b) | |
Ord a => Ord (Const a b) | |
Hashable a => Hashable (Const a b) | |
Defined in Data.Hashable.Class | |
type Rep1 (Const a :: k -> Type) | |
type Rep (Const a b) | |
Defined in Data.Functor.Const |
Constructors
ZipList | |
Fields
|
Instances
Foldable ZipList | |
Defined in Control.Applicative Methods fold :: Monoid m => ZipList m -> m # foldMap :: Monoid m => (a -> m) -> ZipList a -> m # foldMap' :: Monoid m => (a -> m) -> ZipList a -> m # foldr :: (a -> b -> b) -> b -> ZipList a -> b # foldr' :: (a -> b -> b) -> b -> ZipList a -> b foldl :: (b -> a -> b) -> b -> ZipList a -> b foldl' :: (b -> a -> b) -> b -> ZipList a -> b # foldr1 :: (a -> a -> a) -> ZipList a -> a foldl1 :: (a -> a -> a) -> ZipList a -> a elem :: Eq a => a -> ZipList a -> Bool maximum :: Ord a => ZipList a -> a minimum :: Ord a => ZipList a -> a | |
Traversable ZipList | |
Alternative ZipList | |
Applicative ZipList | |
Functor ZipList | |
NFData1 ZipList | |
Defined in Control.DeepSeq | |
Generic1 ZipList | |
Data a => Data (ZipList a) | |
Defined in Data.Data Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ZipList a -> c (ZipList a) gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ZipList a) toConstr :: ZipList a -> Constr dataTypeOf :: ZipList a -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (ZipList a)) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ZipList a)) gmapT :: (forall b. Data b => b -> b) -> ZipList a -> ZipList a gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ZipList a -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ZipList a -> r gmapQ :: (forall d. Data d => d -> u) -> ZipList a -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> ZipList a -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> ZipList a -> m (ZipList a) gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ZipList a -> m (ZipList a) gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ZipList a -> m (ZipList a) | |
Generic (ZipList a) | |
IsList (ZipList a) | |
Read a => Read (ZipList a) | |
Defined in Control.Applicative | |
Show a => Show (ZipList a) | |
NFData a => NFData (ZipList a) | |
Defined in Control.DeepSeq | |
Eq a => Eq (ZipList a) | |
Ord a => Ord (ZipList a) | |
type Rep1 ZipList | |
Defined in Control.Applicative | |
type Rep (ZipList a) | |
Defined in Control.Applicative | |
type Item (ZipList a) | |
Defined in GHC.IsList type Item (ZipList a) = a |
liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d #
optional :: Alternative f => f a -> f (Maybe a) #
(<**>) :: Applicative f => f a -> f (a -> b) -> f b #
Combinators
pass :: Applicative f => f () Source #
Shorter alias for pure ()
.
>>>
pass :: Maybe ()
Just ()
Useful shortcut when need an empty action:
printJust :: Maybe Int -> IO () printJust mInt = case mInt of Just i -> putStrLn $ "Number: " ++ show i Nothing -> pass
appliedTo :: Applicative f => f a -> f (a -> b) -> f b Source #
Named version of the <**>
operator, which is <*>
but flipped. It is
helpful for chaining applicative operations in forward applications using
&
.
>>>
Just (+ 1) & appliedTo (Just 2)
Just 3>>>
Just (+) & appliedTo (Just 1) & appliedTo (Just 2)
Just 3>>>
Nothing & appliedTo (Just 2)
Nothing
Since: 0.5.0