semigroupoids-5.1: Semigroupoids: Category sans id

Copyright(C) 2011-2015 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityprovisional
Portabilityportable
Safe HaskellSafe
LanguageHaskell98

Data.Functor.Alt

Description

 

Synopsis

Documentation

class Functor f => Alt f where #

Laws:

<!> is associative:             (a <!> b) <!> c = a <!> (b <!> c)
<$> left-distributes over <!>:  f <$> (a <!> b) = (f <$> a) <!> (f <$> b)

If extended to an Alternative then <!> should equal <|>.

Ideally, an instance of Alt also satisfies the "left distributon" law of MonadPlus with respect to <.>:

<.> right-distributes over <!>: (a <!> b) <.> c = (a <.> c) <!> (b <.> c)

But Maybe, IO, Either a, ErrorT e m, and STM satisfy the alternative "left catch" law instead:

pure a <!> b = pure a

However, this variation cannot be stated purely in terms of the dependencies of Alt.

When and if MonadPlus is successfully refactored, this class should also be refactored to remove these instances.

The right distributive law should extend in the cases where the a Bind or Monad is provided to yield variations of the right distributive law:

(m <!> n) >>- f = (m >>- f) <!> (m >>- f)
(m <!> n) >>= f = (m >>= f) <!> (m >>= f)

Minimal complete definition

(<!>)

Methods

(<!>) :: f a -> f a -> f a infixl 3 #

<|> without a required empty

some :: Applicative f => f a -> f [a] #

many :: Applicative f => f a -> f [a] #

Instances

Alt [] # 

Methods

(<!>) :: [a] -> [a] -> [a] #

some :: Applicative [] => [a] -> [[a]] #

many :: Applicative [] => [a] -> [[a]] #

Alt Maybe # 

Methods

(<!>) :: Maybe a -> Maybe a -> Maybe a #

some :: Applicative Maybe => Maybe a -> Maybe [a] #

many :: Applicative Maybe => Maybe a -> Maybe [a] #

Alt IO #

This instance does not actually satisfy the (<.>) right distributive law It instead satisfies the Left-Catch law

Methods

(<!>) :: IO a -> IO a -> IO a #

some :: Applicative IO => IO a -> IO [a] #

many :: Applicative IO => IO a -> IO [a] #

Alt Option # 

Methods

(<!>) :: Option a -> Option a -> Option a #

some :: Applicative Option => Option a -> Option [a] #

many :: Applicative Option => Option a -> Option [a] #

Alt NonEmpty # 
Alt IntMap # 

Methods

(<!>) :: IntMap a -> IntMap a -> IntMap a #

some :: Applicative IntMap => IntMap a -> IntMap [a] #

many :: Applicative IntMap => IntMap a -> IntMap [a] #

Alt Seq # 

Methods

(<!>) :: Seq a -> Seq a -> Seq a #

some :: Applicative Seq => Seq a -> Seq [a] #

many :: Applicative Seq => Seq a -> Seq [a] #

Alt (Either a) # 

Methods

(<!>) :: Either a a -> Either a a -> Either a a #

some :: Applicative (Either a) => Either a a -> Either a [a] #

many :: Applicative (Either a) => Either a a -> Either a [a] #

MonadPlus m => Alt (WrappedMonad m) # 
Ord k => Alt (Map k) # 

Methods

(<!>) :: Map k a -> Map k a -> Map k a #

some :: Applicative (Map k) => Map k a -> Map k [a] #

many :: Applicative (Map k) => Map k a -> Map k [a] #

Alt f => Alt (Lift f) # 

Methods

(<!>) :: Lift f a -> Lift f a -> Lift f a #

some :: Applicative (Lift f) => Lift f a -> Lift f [a] #

many :: Applicative (Lift f) => Lift f a -> Lift f [a] #

(Bind f, Monad f) => Alt (MaybeT f) # 

Methods

(<!>) :: MaybeT f a -> MaybeT f a -> MaybeT f a #

some :: Applicative (MaybeT f) => MaybeT f a -> MaybeT f [a] #

many :: Applicative (MaybeT f) => MaybeT f a -> MaybeT f [a] #

Apply f => Alt (ListT f) # 

Methods

(<!>) :: ListT f a -> ListT f a -> ListT f a #

some :: Applicative (ListT f) => ListT f a -> ListT f [a] #

many :: Applicative (ListT f) => ListT f a -> ListT f [a] #

Alternative f => Alt (WrappedApplicative f) # 
ArrowPlus a => Alt (WrappedArrow a b) # 

Methods

(<!>) :: WrappedArrow a b a -> WrappedArrow a b a -> WrappedArrow a b a #

some :: Applicative (WrappedArrow a b) => WrappedArrow a b a -> WrappedArrow a b [a] #

many :: Applicative (WrappedArrow a b) => WrappedArrow a b a -> WrappedArrow a b [a] #

Alt f => Alt (IdentityT * f) # 

Methods

(<!>) :: IdentityT * f a -> IdentityT * f a -> IdentityT * f a #

some :: Applicative (IdentityT * f) => IdentityT * f a -> IdentityT * f [a] #

many :: Applicative (IdentityT * f) => IdentityT * f a -> IdentityT * f [a] #

Alt f => Alt (Reverse * f) # 

Methods

(<!>) :: Reverse * f a -> Reverse * f a -> Reverse * f a #

some :: Applicative (Reverse * f) => Reverse * f a -> Reverse * f [a] #

many :: Applicative (Reverse * f) => Reverse * f a -> Reverse * f [a] #

Alt f => Alt (Backwards * f) # 

Methods

(<!>) :: Backwards * f a -> Backwards * f a -> Backwards * f a #

some :: Applicative (Backwards * f) => Backwards * f a -> Backwards * f [a] #

many :: Applicative (Backwards * f) => Backwards * f a -> Backwards * f [a] #

Alt f => Alt (WriterT w f) # 

Methods

(<!>) :: WriterT w f a -> WriterT w f a -> WriterT w f a #

some :: Applicative (WriterT w f) => WriterT w f a -> WriterT w f [a] #

many :: Applicative (WriterT w f) => WriterT w f a -> WriterT w f [a] #

Alt f => Alt (WriterT w f) # 

Methods

(<!>) :: WriterT w f a -> WriterT w f a -> WriterT w f a #

some :: Applicative (WriterT w f) => WriterT w f a -> WriterT w f [a] #

many :: Applicative (WriterT w f) => WriterT w f a -> WriterT w f [a] #

Alt f => Alt (StateT e f) # 

Methods

(<!>) :: StateT e f a -> StateT e f a -> StateT e f a #

some :: Applicative (StateT e f) => StateT e f a -> StateT e f [a] #

many :: Applicative (StateT e f) => StateT e f a -> StateT e f [a] #

Alt f => Alt (StateT e f) # 

Methods

(<!>) :: StateT e f a -> StateT e f a -> StateT e f a #

some :: Applicative (StateT e f) => StateT e f a -> StateT e f [a] #

many :: Applicative (StateT e f) => StateT e f a -> StateT e f [a] #

(Bind f, Monad f, Semigroup e) => Alt (ExceptT e f) # 

Methods

(<!>) :: ExceptT e f a -> ExceptT e f a -> ExceptT e f a #

some :: Applicative (ExceptT e f) => ExceptT e f a -> ExceptT e f [a] #

many :: Applicative (ExceptT e f) => ExceptT e f a -> ExceptT e f [a] #

(Bind f, Monad f) => Alt (ErrorT e f) # 

Methods

(<!>) :: ErrorT e f a -> ErrorT e f a -> ErrorT e f a #

some :: Applicative (ErrorT e f) => ErrorT e f a -> ErrorT e f [a] #

many :: Applicative (ErrorT e f) => ErrorT e f a -> ErrorT e f [a] #

Alt f => Alt (Static f a) # 

Methods

(<!>) :: Static f a a -> Static f a a -> Static f a a #

some :: Applicative (Static f a) => Static f a a -> Static f a [a] #

many :: Applicative (Static f a) => Static f a a -> Static f a [a] #

(Alt f, Alt g) => Alt (Product * f g) # 

Methods

(<!>) :: Product * f g a -> Product * f g a -> Product * f g a #

some :: Applicative (Product * f g) => Product * f g a -> Product * f g [a] #

many :: Applicative (Product * f g) => Product * f g a -> Product * f g [a] #

Alt f => Alt (ReaderT * e f) # 

Methods

(<!>) :: ReaderT * e f a -> ReaderT * e f a -> ReaderT * e f a #

some :: Applicative (ReaderT * e f) => ReaderT * e f a -> ReaderT * e f [a] #

many :: Applicative (ReaderT * e f) => ReaderT * e f a -> ReaderT * e f [a] #

(Alt f, Functor g) => Alt (Compose * * f g) # 

Methods

(<!>) :: Compose * * f g a -> Compose * * f g a -> Compose * * f g a #

some :: Applicative (Compose * * f g) => Compose * * f g a -> Compose * * f g [a] #

many :: Applicative (Compose * * f g) => Compose * * f g a -> Compose * * f g [a] #

Alt f => Alt (RWST r w s f) # 

Methods

(<!>) :: RWST r w s f a -> RWST r w s f a -> RWST r w s f a #

some :: Applicative (RWST r w s f) => RWST r w s f a -> RWST r w s f [a] #

many :: Applicative (RWST r w s f) => RWST r w s f a -> RWST r w s f [a] #

Alt f => Alt (RWST r w s f) # 

Methods

(<!>) :: RWST r w s f a -> RWST r w s f a -> RWST r w s f a #

some :: Applicative (RWST r w s f) => RWST r w s f a -> RWST r w s f [a] #

many :: Applicative (RWST r w s f) => RWST r w s f a -> RWST r w s f [a] #