semigroupoids-5.3.3: Semigroupoids: Category sans id

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

Data.Functor.Semialternative

Description

 
Synopsis

Documentation

class Functor f => Semialternative 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 Semialternativeernative then <!> should equal <|>.

Ideally, an instance of Semialternative 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 Semialternative.

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 Semimonad 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
Semialternative [] Source # 
Instance details

Defined in Data.Functor.Semialternative

Methods

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

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

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

Semialternative Maybe Source # 
Instance details

Defined in Data.Functor.Semialternative

Methods

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

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

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

Semialternative 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.Semialternative

Methods

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

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

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

Semialternative First Source # 
Instance details

Defined in Data.Functor.Semialternative

Methods

(<!>) :: First a -> First a -> First a Source #

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

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

Semialternative Last Source # 
Instance details

Defined in Data.Functor.Semialternative

Methods

(<!>) :: Last a -> Last a -> Last a Source #

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

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

Semialternative Option Source # 
Instance details

Defined in Data.Functor.Semialternative

Semialternative First Source # 
Instance details

Defined in Data.Functor.Semialternative

Methods

(<!>) :: First a -> First a -> First a Source #

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

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

Semialternative Last Source # 
Instance details

Defined in Data.Functor.Semialternative

Methods

(<!>) :: Last a -> Last a -> Last a Source #

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

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

Semialternative NonEmpty Source # 
Instance details

Defined in Data.Functor.Semialternative

Semialternative IntMap Source # 
Instance details

Defined in Data.Functor.Semialternative

Semialternative Seq Source # 
Instance details

Defined in Data.Functor.Semialternative

Methods

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

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

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

Semialternative (Either a) Source # 
Instance details

Defined in Data.Functor.Semialternative

Methods

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

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

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

Semialternative (V1 :: * -> *) Source # 
Instance details

Defined in Data.Functor.Semialternative

Methods

(<!>) :: V1 a -> V1 a -> V1 a Source #

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

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

Semialternative (U1 :: * -> *) Source # 
Instance details

Defined in Data.Functor.Semialternative

Methods

(<!>) :: U1 a -> U1 a -> U1 a Source #

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

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

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

Defined in Data.Functor.Semialternative

Semialternative (Proxy :: * -> *) Source # 
Instance details

Defined in Data.Functor.Semialternative

Methods

(<!>) :: Proxy a -> Proxy a -> Proxy a Source #

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

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

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

Defined in Data.Functor.Semialternative

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 #

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

Defined in Data.Functor.Semialternative

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 #

(Semimonad f, Monad f) => Semialternative (MaybeT f) Source # 
Instance details

Defined in Data.Functor.Semialternative

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 #

Semiapplicative f => Semialternative (ListT f) Source # 
Instance details

Defined in Data.Functor.Semialternative

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 #

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

Defined in Data.Functor.Semialternative

Methods

(<!>) :: HashMap k a -> HashMap k a -> HashMap k a Source #

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

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

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

Defined in Data.Functor.Semialternative

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

Defined in Data.Functor.Semialternative

Methods

(<!>) :: Rec1 f a -> Rec1 f a -> Rec1 f a Source #

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

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

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

Defined in Data.Functor.Semialternative

Methods

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

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

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

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

Defined in Data.Functor.Semialternative

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 #

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

Defined in Data.Functor.Semialternative

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 #

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

Defined in Data.Functor.Semialternative

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 #

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

Defined in Data.Functor.Semialternative

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 #

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

Defined in Data.Functor.Semialternative

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 #

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

Defined in Data.Functor.Semialternative

(Semimonad f, Monad f, Semigroup e) => Semialternative (ExceptT e f) Source # 
Instance details

Defined in Data.Functor.Semialternative

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 #

(Semimonad f, Monad f) => Semialternative (ErrorT e f) Source # 
Instance details

Defined in Data.Functor.Semialternative

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 #

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

Defined in Data.Functor.Semialternative

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

Defined in Data.Semigroupoid.Static

Methods

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

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

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

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

Defined in Data.Functor.Semialternative

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 #

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

Defined in Data.Functor.Semialternative

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 #

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

Defined in Data.Functor.Semialternative

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 #

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

Defined in Data.Functor.Semialternative

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 #

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

Defined in Data.Functor.Semialternative

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 #

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

Defined in Data.Functor.Semialternative

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 #

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

Defined in Data.Functor.Semialternative

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 :: (Semialternative f, Applicative f) => f a -> f (Maybe a) Source #

One or none.