Copyright | (c) Justin Le 2019 |
---|---|
License | BSD3 |
Maintainer | justin@jle.im |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Documentation
class Contravariant f => Decide f where Source #
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
"semgroupoidal" 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
decide :: (a -> Either b c) -> f b -> f c -> f a Source #
Takes the "decision" method and the two potential consumers, and returns the wrapped/combined consumer.