| Copyright | (c) Justin Le 2025 |
|---|---|
| License | BSD3 |
| Maintainer | justin@jle.im |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.Functor.Contravariant.Night
Description
Synopsis
- data Night (a :: Type -> Type) (b :: Type -> Type) c where
- night :: f a -> g b -> Night f g (Either a b)
- runNight :: forall (h :: Type -> Type) (f :: Type -> Type) (g :: Type -> Type). Decide h => (f ~> h) -> (g ~> h) -> Night f g ~> h
- necide :: forall (f :: Type -> Type). Decide f => Night f f ~> f
- assoc :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) x. Night f (Night g h) x -> Night (Night f g) h x
- unassoc :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) x. Night (Night f g) h x -> Night f (Night g h) x
- swapped :: forall (f :: Type -> Type) (g :: Type -> Type) x. Night f g x -> Night g f x
- trans1 :: forall (f :: Type -> Type) (h :: Type -> Type) (g :: Type -> Type). (f ~> h) -> Night f g ~> Night h g
- trans2 :: forall (g :: Type -> Type) (h :: Type -> Type) (f :: Type -> Type). (g ~> h) -> Night f g ~> Night f h
- intro1 :: g x -> Night Not g x
- intro2 :: f x -> Night f Not x
- elim1 :: forall (g :: Type -> Type). Contravariant g => Night Not g ~> g
- elim2 :: forall (f :: Type -> Type). Contravariant f => Night f Not ~> f
- newtype Not a = Not {}
- refuted :: Not Void
Documentation
data Night (a :: Type -> Type) (b :: Type -> Type) c where Source #
A pairing of contravariant functors to create a new contravariant functor that represents the "choice" between the two.
A is a contravariant "consumer" of Night f g aa, 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 . This is a consumer of night x y :: Night f g (Either a b)s, and it consumes Either a bLeft 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 :: forall (a :: Type -> Type) b1 (b :: Type -> Type) c1 c. a b1 -> b c1 -> (c -> Either b1 c1) -> Night a b c |
Instances
runNight :: forall (h :: Type -> Type) (f :: Type -> Type) (g :: Type -> Type). Decide h => (f ~> h) -> (g ~> h) -> Night f g ~> h Source #
assoc :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) x. Night f (Night g h) x -> Night (Night f g) h x Source #
Night is associative.
unassoc :: forall (f :: Type -> Type) (g :: Type -> Type) (h :: Type -> Type) x. Night (Night f g) h x -> Night f (Night g h) x Source #
Night is associative.
swapped :: forall (f :: Type -> Type) (g :: Type -> Type) x. Night f g x -> Night g f x Source #
The two sides of a Night can be swapped.
trans1 :: forall (f :: Type -> Type) (h :: Type -> Type) (g :: Type -> Type). (f ~> h) -> Night f g ~> Night h g Source #
Hoist a function over the left side of a Night.
trans2 :: forall (g :: Type -> Type) (h :: Type -> Type) (f :: Type -> Type). (g ~> h) -> Night f g ~> Night f h Source #
Hoist a function over the right side of a Night.
A value of type is "proof" that Not aa is uninhabited.
Instances
| Contravariant Not Source # | |
| Invariant Not Source # | Since: 0.3.1.0 |
Defined in Data.Functor.Contravariant.Night | |
| Matchable Night Not Source # | Since: 0.3.0.0 |
| Matchable Night Not Source # | |
| Tensor Night Not Source # | Since: 0.3.0.0 |
Defined in Data.HBifunctor.Tensor 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 # | |
Defined in Data.HBifunctor.Tensor 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 |
| Inplus f => MonoidIn Night Not f Source # | Since: 0.4.0.0 |
| Semigroup (Not a) Source # | |
| Conclude (Chain Night Not f) Source # |
Since: 0.3.0.0 |
| Decide (Chain Night Not f) Source # | Since: 0.3.0.0 |
| Inalt (Chain Night Not f) Source # | Since: 0.4.0.0 |
| Inplus (Chain Night Not f) Source # | Since: 0.4.0.0 |