semigroupoids-5.0.0.4: 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 Source

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 Source

<|> without a required empty

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

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

Instances

Alt [] Source 

Methods

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

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

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

Alt IO Source

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

Methods

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

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

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

Alt Maybe Source 

Methods

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

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

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

Alt IntMap Source 
Alt Seq Source 

Methods

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

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

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

Alt Option Source 
Alt NonEmpty Source 
Alt (Either a) Source 

Methods

(<!>) :: Either a b -> Either a b -> Either a b Source

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

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

MonadPlus m => Alt (WrappedMonad m) Source 
Alt f => Alt (IdentityT f) Source 
Ord k => Alt (Map k) Source 

Methods

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

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

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

Alt f => Alt (Reverse f) Source 

Methods

(<!>) :: Reverse f a -> Reverse f a -> Reverse f a Source

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

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

Alt f => Alt (Backwards f) Source 
(Bind f, Monad f) => Alt (MaybeT f) Source 

Methods

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

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

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

Apply f => Alt (ListT f) Source 

Methods

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

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

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

Alt f => Alt (Lift f) Source 

Methods

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

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

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

Alternative f => Alt (WrappedApplicative f) Source 
ArrowPlus a => Alt (WrappedArrow a b) Source 
(Alt f, Alt g) => Alt (Product f g) Source 

Methods

(<!>) :: Product f g a -> Product f g a -> Product f g a Source

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

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

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

Methods

(<!>) :: Compose f g a -> Compose f g a -> Compose f g a Source

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

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

Alt f => Alt (WriterT w f) Source 

Methods

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

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

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

Alt f => Alt (WriterT w f) Source 

Methods

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

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

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

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

Methods

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

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

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

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

Methods

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

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

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

Alt f => Alt (StateT e f) Source 

Methods

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

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

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

Alt f => Alt (StateT e f) Source 

Methods

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

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

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

Alt f => Alt (ReaderT e f) Source 

Methods

(<!>) :: ReaderT e f a -> ReaderT e f a -> ReaderT e f a Source

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

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

Alt f => Alt (Static f a) Source 

Methods

(<!>) :: Static f a b -> Static f a b -> Static f a b Source

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

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

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

Methods

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

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

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

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

Methods

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

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

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