functor-combinators-0.4.1.1: Tools for functor combinator-based program design
Copyright(c) Justin Le 2019
LicenseBSD3
Maintainerjustin@jle.im
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe-Inferred
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

Instances details
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 #

Methods

associating :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type). (FunctorBy Night f, FunctorBy Night g, FunctorBy Night h) => Night f (Night g h) <~> Night (Night f g) h Source #

appendNE :: forall (f :: Type -> Type). Night (NonEmptyBy Night f) (NonEmptyBy Night f) ~> NonEmptyBy Night f Source #

matchNE :: forall (f :: Type -> Type). FunctorBy Night f => NonEmptyBy Night f ~> (f :+: Night f (NonEmptyBy Night f)) Source #

consNE :: forall (f :: Type -> Type). Night f (NonEmptyBy Night f) ~> NonEmptyBy Night f Source #

toNonEmptyBy :: forall (f :: Type -> Type). Night f f ~> NonEmptyBy Night f 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 :: forall (g :: Type -> Type) (h :: Type -> Type). (g ~> f) -> (h ~> f) -> Night g h ~> f Source #

Matchable Night Not Source #

Since: 0.3.0.0

Instance details

Defined in Data.HBifunctor.Tensor

Methods

unsplitNE :: forall (f :: Type -> Type). FunctorBy Night f => Night f (ListBy Night f) ~> NonEmptyBy Night f Source #

matchLB :: forall (f :: Type -> Type). FunctorBy Night f => ListBy Night f ~> (Not :+: NonEmptyBy Night 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 #

Methods

intro1 :: forall (f :: Type -> Type). f ~> Night f Not Source #

intro2 :: forall (g :: Type -> Type). g ~> Night Not g Source #

elim1 :: forall (f :: Type -> Type). FunctorBy Night f => Night f Not ~> f Source #

elim2 :: forall (g :: Type -> Type). FunctorBy Night g => Night Not g ~> g Source #

appendLB :: forall (f :: Type -> Type). Night (ListBy Night f) (ListBy Night f) ~> ListBy Night f Source #

splitNE :: forall (f :: Type -> Type). NonEmptyBy Night f ~> Night f (ListBy Night f) Source #

splittingLB :: forall (f :: Type -> Type). ListBy Night f <~> (Not :+: Night f (ListBy Night f)) Source #

toListBy :: forall (f :: Type -> Type). Night f f ~> ListBy Night f Source #

fromNE :: forall (f :: Type -> Type). NonEmptyBy Night f ~> ListBy Night f Source #

HBifunctor Night Source #

Since: 0.3.0.0

Instance details

Defined in Data.HFunctor.Internal

Methods

hleft :: forall (f :: k -> Type) (j :: k -> Type) (g :: k -> Type). (f ~> j) -> Night f g ~> Night j g Source #

hright :: forall (g :: k -> Type) (l :: k -> Type) (f :: k -> Type). (g ~> l) -> Night f g ~> Night f l Source #

hbimap :: forall (f :: k -> Type) (j :: k -> Type) (g :: k -> Type) (l :: k -> Type). (f ~> j) -> (g ~> l) -> Night f g ~> Night j l Source #

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' -> a) -> Night f g a -> 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 #

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 #

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 #

type FunctorBy Night Source # 
Instance details

Defined in Data.HBifunctor.Associative

type NonEmptyBy 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.

necide :: Decide f => Night f f ~> f Source #

Squash the two items in a Night using their natural Decide instances.

Since: 0.4.0.0

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

Instances details
Contravariant Not Source # 
Instance details

Defined in Data.Functor.Contravariant.Night

Methods

contramap :: (a' -> a) -> Not a -> 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 #

Matchable Night Not Source #

Since: 0.3.0.0

Instance details

Defined in Data.HBifunctor.Tensor

Methods

unsplitNE :: forall (f :: Type -> Type). FunctorBy Night f => Night f (ListBy Night f) ~> NonEmptyBy Night f Source #

matchLB :: forall (f :: Type -> Type). FunctorBy Night f => ListBy Night f ~> (Not :+: NonEmptyBy Night f) Source #

Matchable Night Not Source # 
Instance details

Defined in Data.HBifunctor.Tensor

Methods

unsplitNE :: forall (f :: Type -> Type). FunctorBy Night f => Night f (ListBy Night f) ~> NonEmptyBy Night f Source #

matchLB :: forall (f :: Type -> Type). FunctorBy Night f => ListBy Night f ~> (Not :+: NonEmptyBy Night 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 #

Methods

intro1 :: forall (f :: Type -> Type). f ~> Night f Not Source #

intro2 :: forall (g :: Type -> Type). g ~> Night Not g Source #

elim1 :: forall (f :: Type -> Type). FunctorBy Night f => Night f Not ~> f Source #

elim2 :: forall (g :: Type -> Type). FunctorBy Night g => Night Not g ~> g Source #

appendLB :: forall (f :: Type -> Type). Night (ListBy Night f) (ListBy Night f) ~> ListBy Night f Source #

splitNE :: forall (f :: Type -> Type). NonEmptyBy Night f ~> Night f (ListBy Night f) Source #

splittingLB :: forall (f :: Type -> Type). ListBy Night f <~> (Not :+: Night f (ListBy Night f)) Source #

toListBy :: forall (f :: Type -> Type). Night f f ~> ListBy Night f Source #

fromNE :: forall (f :: Type -> Type). NonEmptyBy Night f ~> ListBy Night f Source #

Tensor Night Not Source # 
Instance details

Defined in Data.HBifunctor.Tensor

Associated Types

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

Methods

intro1 :: forall (f :: Type -> Type). f ~> Night f Not Source #

intro2 :: forall (g :: Type -> Type). g ~> Night Not g Source #

elim1 :: forall (f :: Type -> Type). FunctorBy Night f => Night f Not ~> f Source #

elim2 :: forall (g :: Type -> Type). FunctorBy Night g => Night Not g ~> g Source #

appendLB :: forall (f :: Type -> Type). Night (ListBy Night f) (ListBy Night f) ~> ListBy Night f Source #

splitNE :: forall (f :: Type -> Type). NonEmptyBy Night f ~> Night f (ListBy Night f) Source #

splittingLB :: forall (f :: Type -> Type). ListBy Night f <~> (Not :+: Night f (ListBy Night f)) Source #

toListBy :: forall (f :: Type -> Type). Night f f ~> ListBy Night f Source #

fromNE :: forall (f :: Type -> Type). NonEmptyBy Night f ~> ListBy Night f Source #

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 #

Inplus f => MonoidIn Night Not f Source #

Since: 0.4.0.0

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 #

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 #

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 #

Inalt (Chain Night Not f) Source #

Since: 0.4.0.0

Instance details

Defined in Data.HFunctor.Chain

Methods

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

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

Inplus (Chain Night Not f) Source #

Since: 0.4.0.0

Instance details

Defined in Data.HFunctor.Chain

Methods

reject :: (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