semigroupoids-5.3.7: Semigroupoids: Category sans id
Copyright (C) 2011-2015 Edward Kmett
License BSD-style (see the file LICENSE)
Maintainer Edward Kmett <ekmett@gmail.com>
Stability provisional
Portability portable
Safe Haskell Trustworthy
Language Haskell2010

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 distribution" law of MonadPlus with respect to <.> :

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

IO , Either a , ExceptT e m and STM instead satisfy the "left catch" law:

pure a <!> b = pure a

Maybe and Identity satisfy both "left distribution" and "left catch".

These variations 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

Instances details
Alt [] Source #
Instance details

Defined in Data.Functor.Alt

Methods

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

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

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

Alt Maybe Source #
Instance details

Defined in Data.Functor.Alt

Alt IO Source #

This instance does not actually satisfy the ( <.> ) right distributive law It instead satisfies the "left catch" law

Instance details

Defined in Data.Functor.Alt

Alt First Source #
Instance details

Defined in Data.Functor.Alt

Alt Last Source #
Instance details

Defined in Data.Functor.Alt

Alt Option Source #
Instance details

Defined in Data.Functor.Alt

Alt Identity Source #

Choose the first option every time. While 'choose the last option' every time is also valid, this instance satisfies more laws.

Since: 5.3.6

Instance details

Defined in Data.Functor.Alt

Alt First Source #
Instance details

Defined in Data.Functor.Alt

Alt Last Source #
Instance details

Defined in Data.Functor.Alt

Alt NonEmpty Source #
Instance details

Defined in Data.Functor.Alt

Alt IntMap Source #
Instance details

Defined in Data.Functor.Alt

Alt Seq Source #
Instance details

Defined in Data.Functor.Alt

Alt ( Either a) Source #
Instance details

Defined in Data.Functor.Alt

Alt ( V1 :: Type -> Type ) Source #
Instance details

Defined in Data.Functor.Alt

Alt ( U1 :: Type -> Type ) Source #
Instance details

Defined in Data.Functor.Alt

MonadPlus m => Alt ( WrappedMonad m) Source #
Instance details

Defined in Data.Functor.Alt

Alt ( Proxy :: Type -> Type ) Source #
Instance details

Defined in Data.Functor.Alt

Ord k => Alt ( Map k) Source #
Instance details

Defined in Data.Functor.Alt

Alt f => Alt ( Lift f) Source #
Instance details

Defined in Data.Functor.Alt

( Functor f, Monad f) => Alt ( MaybeT f) Source #
Instance details

Defined in Data.Functor.Alt

Apply f => Alt ( ListT f) Source #
Instance details

Defined in Data.Functor.Alt

( Hashable k, Eq k) => Alt ( HashMap k) Source #
Instance details

Defined in Data.Functor.Alt

Alternative f => Alt ( WrappedApplicative f) Source #
Instance details

Defined in Data.Functor.Alt

Alt f => Alt ( Rec1 f) Source #
Instance details

Defined in Data.Functor.Alt

ArrowPlus a => Alt ( WrappedArrow a b) Source #
Instance details

Defined in Data.Functor.Alt

Alt f => Alt ( IdentityT f) Source #
Instance details

Defined in Data.Functor.Alt

Alt f => Alt ( Reverse f) Source #
Instance details

Defined in Data.Functor.Alt

Alt f => Alt ( WriterT w f) Source #
Instance details

Defined in Data.Functor.Alt

Alt f => Alt ( WriterT w f) Source #
Instance details

Defined in Data.Functor.Alt

Alt f => Alt ( WriterT w f) Source #

Since: 5.3.6

Instance details

Defined in Data.Functor.Alt

Alt f => Alt ( StateT e f) Source #
Instance details

Defined in Data.Functor.Alt

Alt f => Alt ( StateT e f) Source #
Instance details

Defined in Data.Functor.Alt

Alt f => Alt ( ReaderT e f) Source #
Instance details

Defined in Data.Functor.Alt

( Functor f, Monad f, Semigroup e) => Alt ( ExceptT e f) Source #
Instance details

Defined in Data.Functor.Alt

( Functor f, Monad f) => Alt ( ErrorT e f) Source #
Instance details

Defined in Data.Functor.Alt

Alt f => Alt ( Backwards f) Source #
Instance details

Defined in Data.Functor.Alt

Alt f => Alt ( Static f a) Source #
Instance details

Defined in Data.Semigroupoid.Static

( Alt f, Alt g) => Alt (f :*: g) Source #
Instance details

Defined in Data.Functor.Alt

Methods

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

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

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

( Alt f, Alt g) => Alt ( Product f g) Source #
Instance details

Defined in Data.Functor.Alt

Alt f => Alt ( M1 i c f) Source #
Instance details

Defined in Data.Functor.Alt

Methods

(<!>) :: M1 i c f a -> M1 i c f a -> M1 i c f a Source #

some :: Applicative ( M1 i c f) => M1 i c f a -> M1 i c f [a] Source #

many :: Applicative ( M1 i c f) => M1 i c f a -> M1 i c f [a] Source #

( Alt f, Functor g) => Alt ( Compose f g) Source #
Instance details

Defined in Data.Functor.Alt

Alt f => Alt ( RWST r w s f) Source #
Instance details

Defined in Data.Functor.Alt

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 #
Instance details

Defined in Data.Functor.Alt

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 #

Since: 5.3.6

Instance details

Defined in Data.Functor.Alt

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 #

optional :: ( Alt f, Applicative f) => f a -> f ( Maybe a) Source #

One or none.