| 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
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 and ExceptT e mSTM 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
Instances
| 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 |
| Alt First Source # | |
| Alt Last Source # | |
| Alt First Source # | |
| Alt Last Source # | |
| Alt IntMap Source # | |
| Alt Seq Source # | |
| Alt IO Source # | This instance does not actually satisfy the ( |
| Alt NonEmpty Source # | |
| Alt Maybe Source # | |
| Alt [] Source # | |
| MonadPlus m => Alt (WrappedMonad m) Source # | |
| Alt (Either a) Source # | |
| Alt (Proxy :: Type -> Type) Source # | |
| Alt (U1 :: Type -> Type) Source # | |
| Alt (V1 :: Type -> Type) Source # | |
| Ord k => Alt (Map k) Source # | |
| Alternative f => Alt (WrappedApplicative f) Source # | |
Defined in Data.Functor.Alt Methods (<!>) :: WrappedApplicative f a -> WrappedApplicative f a -> WrappedApplicative f a Source # some :: Applicative (WrappedApplicative f) => WrappedApplicative f a -> WrappedApplicative f [a] Source # many :: Applicative (WrappedApplicative f) => WrappedApplicative f a -> WrappedApplicative f [a] Source # | |
| Alt f => Alt (Lift f) Source # | |
| Apply f => Alt (ListT f) Source # | |
| (Functor f, Monad f) => Alt (MaybeT f) Source # | |
| (Hashable k, Eq k) => Alt (HashMap k) Source # | |
| ArrowPlus a => Alt (WrappedArrow a b) Source # | |
Defined in Data.Functor.Alt | |
| Alt f => Alt (Rec1 f) Source # | |
| Alt f => Alt (Static f a) Source # | |
| Alt f => Alt (Backwards f) Source # | |
| (Functor f, Monad f) => Alt (ErrorT e f) Source # | |
| (Functor f, Monad f, Semigroup e) => Alt (ExceptT e f) Source # | |
| Alt f => Alt (IdentityT f) Source # | |
| Alt f => Alt (ReaderT e f) Source # | |
| Alt f => Alt (StateT e f) Source # | |
| Alt f => Alt (StateT e f) Source # | |
| Alt f => Alt (WriterT w f) Source # | Since: 5.3.6 |
| Alt f => Alt (WriterT w f) Source # | |
| Alt f => Alt (WriterT w f) Source # | |
| Alt f => Alt (Reverse f) Source # | |
| (Alt f, Alt g) => Alt (Product f g) Source # | |
| (Alt f, Alt g) => Alt (f :*: g) Source # | |
| (Alt f, Functor g) => Alt (Compose f g) Source # | |
| Alt f => Alt (M1 i c f) Source # | |
| Alt f => Alt (RWST r w s f) Source # | Since: 5.3.6 |
| Alt f => Alt (RWST r w s f) Source # | |
| Alt f => Alt (RWST r w s f) Source # | |
module Data.Functor.Apply