Copyright | (C) 2021 Edward Kmett |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | provisional |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Data.Functor.Contravariant.Decide
Description
Synopsis
Documentation
class Contravariant f => Decide f where #
The contravariant analogue of Alt
.
If one thinks of f a
as a consumer of a
s, then decide
allows one
to handle the consumption of a value by choosing to handle it via
exactly one of two independent consumers. It redirects the input
completely into one of two consumers.
decide
takes the "decision" method and the two potential consumers,
and returns the wrapped/combined consumer.
Mathematically, a functor being an instance of Decide
means that it is
"semigroupoidal" with respect to the contravariant "either-based" Day
convolution (data EitherDay f g a = forall b c. EitherDay (f b) (g c) (a -> Either b c)
).
That is, it is possible to define a function (f
in a way that is associative.EitherDay
f) a ->
f a
Since: 5.3.6
Methods
decide :: (a -> Either b c) -> f b -> f c -> f a #
Takes the "decision" method and the two potential consumers, and returns the wrapped/combined consumer.
Instances
Decide Comparison # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decide Equivalence # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decide Predicate # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decide (Op r) # | Unlike Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decide (Proxy :: Type -> Type) # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decide (U1 :: Type -> Type) # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decide (V1 :: Type -> Type) # | Has no Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decidable f => Decide (WrappedDivisible f) # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide Methods decide :: (a -> Either b c) -> WrappedDivisible f b -> WrappedDivisible f c -> WrappedDivisible f a # | |
Divise m => Decide (MaybeT m) # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decide f => Decide (Alt f) # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decide f => Decide (Rec1 f) # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decide f => Decide (Backwards f) # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decide f => Decide (IdentityT f) # | Since: 5.3.6 |
Decide m => Decide (ReaderT r m) # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decide m => Decide (StateT s m) # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decide m => Decide (StateT s m) # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decide m => Decide (WriterT w m) # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decide m => Decide (WriterT w m) # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decide f => Decide (Reverse f) # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
(Decide f, Decide g) => Decide (Product f g) # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
(Decide f, Decide g) => Decide (f :*: g) # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
(Apply f, Decide g) => Decide (Compose f g) # | Unlike Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
(Apply f, Decide g) => Decide (f :.: g) # | Unlike Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decide f => Decide (M1 i c f) # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decide m => Decide (RWST r w s m) # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide | |
Decide m => Decide (RWST r w s m) # | Since: 5.3.6 |
Defined in Data.Functor.Contravariant.Decide |
gdecide :: (Generic1 f, Decide (Rep1 f)) => (a -> Either b c) -> f b -> f c -> f a #
Generic decide
. Caveats:
- Will not compile if
f
is a sum type. - Will not compile if
f
contains fields that do not mention its type variable. -XDeriveGeneric
is not smart enough to make instances where the type variable appears in negative position.
Since: 5.3.8