functor-combinators-0.3.4.1: Tools for functor combinator-based program design

Copyright(c) Justin Le 2019
LicenseBSD3
Maintainerjustin@jle.im
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.Functor.Contravariant.Night

Description

Provides Night, a form of the day convolution that is contravariant and splits on Either.

Since: 0.3.0.0

Synopsis

Documentation

data Night :: (Type -> Type) -> (Type -> Type) -> Type -> Type where Source #

A pairing of contravariant functors to create a new contravariant functor that represents the "choice" between the two.

A Night f g a is a contravariant "consumer" of a, and it does this by either feeding the a to f, or feeding the a to g. Which one it gives it to happens at runtime depending what a is actually given.

For example, if we have x :: f a (a consumer of as) and y :: g b (a consumer of bs), then night x y :: Night f g (Either a b). This is a consumer of Either a bs, and it consumes Left branches by feeding it to x, and Right branches by feeding it to y.

Mathematically, this is a contravariant day convolution, except with a different choice of bifunctor (Either) than the typical one we talk about in Haskell (which uses (,)). Therefore, it is an alternative to the typical Day convolution --- hence, the name Night.

Constructors

Night :: f b -> g c -> (a -> Either b c) -> Night f g a 
Instances
Associative Night Source #

Since: 0.3.0.0

Instance details

Defined in Data.HBifunctor.Associative

Associated Types

type NonEmptyBy Night :: (Type -> Type) -> Type -> Type Source #

type FunctorBy Night :: (Type -> Type) -> Constraint Source #

HBifunctor Night Source #

Since: 0.3.0.0

Instance details

Defined in Data.HFunctor.Internal

Methods

hleft :: (f ~> j) -> Night f g ~> Night j g Source #

hright :: (g ~> l) -> Night f g ~> Night f l Source #

hbimap :: (f ~> j) -> (g ~> l) -> Night f g ~> Night j l Source #

Decide f => SemigroupIn Night f Source #

Since: 0.3.0.0

Instance details

Defined in Data.HBifunctor.Associative

Methods

biretract :: Night f f ~> f Source #

binterpret :: (g ~> f) -> (h ~> f) -> Night g h ~> f Source #

Tensor Night Not Source #

Since: 0.3.0.0

Instance details

Defined in Data.HBifunctor.Tensor

Associated Types

type ListBy Night :: (Type -> Type) -> Type -> Type Source #

Matchable Night Not Source #

Since: 0.3.0.0

Instance details

Defined in Data.HBifunctor.Tensor

Conclude f => MonoidIn Night Not f Source #

Instances of Conclude are monoids in the monoidal category on Night.

Instance details

Defined in Data.HBifunctor.Tensor

Methods

pureT :: Not ~> f Source #

Contravariant (Night f g) Source # 
Instance details

Defined in Data.Functor.Contravariant.Night

Methods

contramap :: (a -> b) -> Night f g b -> Night f g a #

(>$) :: b -> Night f g b -> Night f g a #

Invariant (Night f g) Source # 
Instance details

Defined in Data.Functor.Contravariant.Night

Methods

invmap :: (a -> b) -> (b -> a) -> Night f g a -> Night f g b #

Contravariant f => Decide (Chain1 Night f) Source #

Chain1 Night is the free "semigroup in the semigroupoidal category of endofunctors enriched by Night" --- aka, the free Decide.

Since: 0.3.0.0

Instance details

Defined in Data.HFunctor.Chain

Methods

decide :: (a -> Either b c) -> Chain1 Night f b -> Chain1 Night f c -> Chain1 Night f a Source #

Decide (Chain Night Not f) Source #

Since: 0.3.0.0

Instance details

Defined in Data.HFunctor.Chain

Methods

decide :: (a -> Either b c) -> Chain Night Not f b -> Chain Night Not f c -> Chain Night Not f a Source #

Conclude (Chain Night Not f) Source #

Chain Night Refutec is the free "monoid in the monoidal category of endofunctors enriched by Night" --- aka, the free Conclude.

Since: 0.3.0.0

Instance details

Defined in Data.HFunctor.Chain

Methods

conclude :: (a -> Void) -> Chain Night Not f a Source #

type NonEmptyBy Night Source # 
Instance details

Defined in Data.HBifunctor.Associative

type FunctorBy Night Source # 
Instance details

Defined in Data.HBifunctor.Associative

type ListBy Night Source # 
Instance details

Defined in Data.HBifunctor.Tensor

night :: f a -> g b -> Night f g (Either a b) Source #

Inject into a Night.

night x y is a consumer of Either a b; Left will be passed to x, and Right will be passed to y.

runNight :: Decide h => (f ~> h) -> (g ~> h) -> Night f g ~> h Source #

Interpret out of a Night into any instance of Decide by providing two interpreting functions.

assoc :: Night f (Night g h) ~> Night (Night f g) h Source #

Night is associative.

unassoc :: Night (Night f g) h ~> Night f (Night g h) Source #

Night is associative.

swapped :: Night f g ~> Night g f Source #

The two sides of a Night can be swapped.

trans1 :: (f ~> h) -> Night f g ~> Night h g Source #

Hoist a function over the left side of a Night.

trans2 :: (g ~> h) -> Night f g ~> Night f h Source #

Hoist a function over the right side of a Night.

intro1 :: g ~> Night Not g Source #

The left identity of Night is Not; this is one side of that isomorphism.

intro2 :: f ~> Night f Not Source #

The right identity of Night is Not; this is one side of that isomorphism.

elim1 :: Contravariant g => Night Not g ~> g Source #

The left identity of Night is Not; this is one side of that isomorphism.

elim2 :: Contravariant f => Night f Not ~> f Source #

The right identity of Night is Not; this is one side of that isomorphism.

newtype Not a Source #

A value of type Not a is "proof" that a is uninhabited.

Constructors

Not 

Fields

Instances
Contravariant Not Source # 
Instance details

Defined in Data.Functor.Contravariant.Night

Methods

contramap :: (a -> b) -> Not b -> Not a #

(>$) :: b -> Not b -> Not a #

Invariant Not Source #

Since: 0.3.1.0

Instance details

Defined in Data.Functor.Contravariant.Night

Methods

invmap :: (a -> b) -> (b -> a) -> Not a -> Not b #

Tensor Night Not Source #

Since: 0.3.0.0

Instance details

Defined in Data.HBifunctor.Tensor

Associated Types

type ListBy Night :: (Type -> Type) -> Type -> Type Source #

Tensor Night Not Source # 
Instance details

Defined in Data.HBifunctor.Tensor

Associated Types

type ListBy Night :: (Type -> Type) -> Type -> Type Source #

Matchable Night Not Source #

Since: 0.3.0.0

Instance details

Defined in Data.HBifunctor.Tensor

Matchable Night Not Source # 
Instance details

Defined in Data.HBifunctor.Tensor

Conclude f => MonoidIn Night Not f Source #

Instances of Conclude are monoids in the monoidal category on Night.

Instance details

Defined in Data.HBifunctor.Tensor

Methods

pureT :: Not ~> f Source #

Semigroup (Not a) Source # 
Instance details

Defined in Data.Functor.Contravariant.Night

Methods

(<>) :: Not a -> Not a -> Not a #

sconcat :: NonEmpty (Not a) -> Not a #

stimes :: Integral b => b -> Not a -> Not a #

Decide (Chain Night Not f) Source #

Since: 0.3.0.0

Instance details

Defined in Data.HFunctor.Chain

Methods

decide :: (a -> Either b c) -> Chain Night Not f b -> Chain Night Not f c -> Chain Night Not f a Source #

Conclude (Chain Night Not f) Source #

Chain Night Refutec is the free "monoid in the monoidal category of endofunctors enriched by Night" --- aka, the free Conclude.

Since: 0.3.0.0

Instance details

Defined in Data.HFunctor.Chain

Methods

conclude :: (a -> Void) -> Chain Night Not f a Source #

refuted :: Not Void Source #

A useful shortcut for a common usage: Void is always not so.

Since: 0.3.1.0