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

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
 Source # Since: 0.3.0.0 Instance detailsDefined in Data.HBifunctor.Associative Associated Typestype NonEmptyBy Night :: (Type -> Type) -> Type -> Type Source #type FunctorBy Night :: (Type -> Type) -> Constraint Source # Methodsassociating :: 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 # Source # Since: 0.3.0.0 Instance detailsDefined in Data.HFunctor.Internal Methodshleft :: 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 # Source # Since: 0.3.0.0 Instance detailsDefined in Data.HBifunctor.Associative Methodsbiretract :: Night f f ~> f Source #binterpret :: forall (g :: Type -> Type) (h :: Type -> Type). (g ~> f) -> (h ~> f) -> Night g h ~> f Source # Source # Since: 0.3.0.0 Instance detailsDefined in Data.HBifunctor.Tensor Associated Typestype ListBy Night :: (Type -> Type) -> Type -> Type Source # Methodsintro1 :: 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 # Source # Since: 0.3.0.0 Instance detailsDefined in Data.HBifunctor.Tensor MethodsunsplitNE :: 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 # Source # Instances of Conclude are monoids in the monoidal category on Night. Instance detailsDefined in Data.HBifunctor.Tensor Methods Contravariant (Night f g) Source # Instance detailsDefined in Data.Functor.Contravariant.Night Methodscontramap :: (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 detailsDefined in Data.Functor.Contravariant.Night Methodsinvmap :: (a -> b) -> (b -> a) -> Night f g a -> Night f g b # 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 detailsDefined in Data.HFunctor.Chain Methodsdecide :: (a -> Either b c) -> Chain1 Night f b -> Chain1 Night f c -> Chain1 Night f a Source # Source # Since: 0.3.0.0 Instance detailsDefined in Data.HFunctor.Chain Methodsdecide :: (a -> Either b c) -> Chain Night Not f b -> Chain Night Not f c -> Chain Night Not f a Source # 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 detailsDefined in Data.HFunctor.Chain Methodsconclude :: (a -> Void) -> Chain Night Not f a Source # type NonEmptyBy Night Source # Instance detailsDefined in Data.HBifunctor.Associative type NonEmptyBy Night = Dec1 type FunctorBy Night Source # Instance detailsDefined in Data.HBifunctor.Associative type ListBy Night Source # Instance detailsDefined in Data.HBifunctor.Tensor type ListBy Night = Dec 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. The left identity of Night is Not; this is one side of that isomorphism. The right identity of Night is Not; this is one side of that isomorphism. The left identity of Night is Not; this is one side of that isomorphism. 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 Fieldsrefute :: a -> Void #### Instances Instances details  Source # Instance detailsDefined in Data.Functor.Contravariant.Night Methodscontramap :: (a -> b) -> Not b -> Not a #(>$) :: b -> Not b -> Not a # Source # Since: 0.3.1.0 Instance detailsDefined in Data.Functor.Contravariant.Night Methodsinvmap :: (a -> b) -> (b -> a) -> Not a -> Not b # Source # Since: 0.3.0.0 Instance detailsDefined in Data.HBifunctor.Tensor Associated Typestype ListBy Night :: (Type -> Type) -> Type -> Type Source # Methodsintro1 :: 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 # Source # Instance detailsDefined in Data.HBifunctor.Tensor Associated Typestype ListBy Night :: (Type -> Type) -> Type -> Type Source # Methodsintro1 :: 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 # Source # Since: 0.3.0.0 Instance detailsDefined in Data.HBifunctor.Tensor MethodsunsplitNE :: 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 # Source # Instance detailsDefined in Data.HBifunctor.Tensor MethodsunsplitNE :: 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 # Source # Instances of Conclude are monoids in the monoidal category on Night. Instance detailsDefined in Data.HBifunctor.Tensor Methods Semigroup (Not a) Source # Instance detailsDefined 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 # Source # Since: 0.3.0.0 Instance detailsDefined in Data.HFunctor.Chain Methodsdecide :: (a -> Either b c) -> Chain Night Not f b -> Chain Night Not f c -> Chain Night Not f a Source # 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 detailsDefined in Data.HFunctor.Chain Methodsconclude :: (a -> Void) -> Chain Night Not f a Source #

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

Since: 0.3.1.0