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.Divisible.Free

Description

Provides free structures for the various typeclasses of the Divisible hierarchy.

Since: 0.3.0.0

Synopsis

Documentation

newtype Div f a Source #

The free Divisible. Used to sequence multiple contravariant consumers, splitting out the input across all consumers.

This type is essentially ListF; the only reason why it has to exist separately outside of ListF is because the current typeclass hierarchy isn't compatible with both the covariant Interpret instance (requiring Plus) and the contravariant Interpret instance (requiring Divisible).

The wrapping in Coyoneda is also to provide a usable Associative instance for the contravariant Day.

Constructors

Div 

Fields

Bundled Patterns

pattern Conquer :: Div f a

Pattern matching on an empty Div.

Before v0.3.3.0, this used to be the concrete constructor of Div. After, it is now an abstract pattern.

pattern Divide :: (a -> (b, c)) -> f b -> Div f c -> Div f a

Pattern matching on a non-empty Div, exposing the raw f instead of having it wrapped in a Coyoneda. This is the analogue of Pure and essentially treats the "cons" of the Div as a contravariant day convolution.

Before v0.3.3.0, this used to be the concrete constructor of Div. After, it is now an abstract pattern.

Instances

Instances details
FreeOf Divisible Div Source #

Since: 0.3.0.0

Instance details

Defined in Data.HFunctor.Final

Associated Types

type FreeFunctorBy Div :: (Type -> Type) -> Constraint Source #

Methods

fromFree :: forall (f :: Type -> Type). Div f ~> Final Divisible f Source #

toFree :: forall (f :: Type -> Type). FreeFunctorBy Div f => Final Divisible f ~> Div f Source #

HTraversable Div Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

htraverse :: forall h f g (a :: k1). Applicative h => (forall (x :: k). f x -> h (g x)) -> Div f a -> h (Div g a) Source #

Divisible f => Interpret Div (f :: Type -> Type) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

retract :: Div f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Div g ~> f Source #

Contravariant (Div f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

contramap :: (a' -> a) -> Div f a -> Div f a' #

(>$) :: b -> Div f b -> Div f a #

Divisible (Div f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

divide :: (a -> (b, c)) -> Div f b -> Div f c -> Div f a #

conquer :: Div f a #

Divise (Div f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

divise :: (a -> (b, c)) -> Div f b -> Div f c -> Div f a Source #

divised :: Div f a -> Div f b -> Div f (a, b) Source #

Inplicative (Div f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

knot :: a -> Div f a Source #

Inply (Div f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

gather :: (b -> c -> a) -> (a -> (b, c)) -> Div f b -> Div f c -> Div f a Source #

gathered :: Div f a -> Div f b -> Div f (a, b) Source #

Invariant (Div f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

invmap :: (a -> b) -> (b -> a) -> Div f a -> Div f b #

Inject Div Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

inject :: forall (f :: k -> Type). f ~> Div f Source #

HFunctor Div Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

hmap :: forall (f :: k -> Type) (g :: k -> Type). (f ~> g) -> Div f ~> Div g Source #

type FreeFunctorBy Div Source # 
Instance details

Defined in Data.HFunctor.Final

hoistDiv :: forall f g. (f ~> g) -> Div f ~> Div g Source #

Map over the undering context in a Div.

liftDiv :: f ~> Div f Source #

Inject a single action in f into a Div f.

runDiv :: forall f g. Divisible g => (f ~> g) -> Div f ~> g Source #

Interpret a Div into a context g, provided g is Divisible.

divListF :: forall f. Contravariant f => Div f ~> ListF f Source #

Div is isomorphic to ListF for contravariant f. This witnesses one way of that isomorphism.

listFDiv :: ListF f ~> Div f Source #

Div is isomorphic to ListF for contravariant f. This witnesses one way of that isomorphism.

newtype Div1 f a Source #

The free Divise: a non-empty version of Div.

This type is essentially NonEmptyF; the only reason why it has to exist separately outside of NonEmptyF is because the current typeclass hierarchy isn't compatible with both the covariant Interpret instance (requiring Plus) and the contravariant Interpret instance (requiring Divisible).

The wrapping in Coyoneda is also to provide a usable Associative instance for the contravariant Day.

Constructors

Div1 

Fields

Bundled Patterns

pattern Div1_ :: (a -> (b, c)) -> f b -> Div f c -> Div1 f a

Pattern matching on a Div1, exposing the raw f instead of having it wrapped in a Coyoneda. This is the analogue of Ap1 and essentially treats the "cons" of the Div1 as a contravariant day convolution.

Before v0.3.3.0, this used to be the concrete constructor of Div1. After, it is now an abstract pattern.

Since: 0.3.3.0

Instances

Instances details
FreeOf Divise Div1 Source #

Since: 0.3.0.0

Instance details

Defined in Data.HFunctor.Final

Associated Types

type FreeFunctorBy Div1 :: (Type -> Type) -> Constraint Source #

Methods

fromFree :: forall (f :: Type -> Type). Div1 f ~> Final Divise f Source #

toFree :: forall (f :: Type -> Type). FreeFunctorBy Div1 f => Final Divise f ~> Div1 f Source #

HTraversable Div1 Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

htraverse :: forall h f g (a :: k1). Applicative h => (forall (x :: k). f x -> h (g x)) -> Div1 f a -> h (Div1 g a) Source #

HTraversable1 Div1 Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

htraverse1 :: forall h f g (a :: k1). Apply h => (forall (x :: k). f x -> h (g x)) -> Div1 f a -> h (Div1 g a) Source #

Divise f => Interpret Div1 (f :: Type -> Type) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

retract :: Div1 f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Div1 g ~> f Source #

Contravariant (Div1 f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

contramap :: (a' -> a) -> Div1 f a -> Div1 f a' #

(>$) :: b -> Div1 f b -> Div1 f a #

Divise (Div1 f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

divise :: (a -> (b, c)) -> Div1 f b -> Div1 f c -> Div1 f a Source #

divised :: Div1 f a -> Div1 f b -> Div1 f (a, b) Source #

Inply (Div1 f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

gather :: (b -> c -> a) -> (a -> (b, c)) -> Div1 f b -> Div1 f c -> Div1 f a Source #

gathered :: Div1 f a -> Div1 f b -> Div1 f (a, b) Source #

Invariant (Div1 f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

invmap :: (a -> b) -> (b -> a) -> Div1 f a -> Div1 f b #

Inject Div1 Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

inject :: forall (f :: k -> Type). f ~> Div1 f Source #

HFunctor Div1 Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

hmap :: forall (f :: k -> Type) (g :: k -> Type). (f ~> g) -> Div1 f ~> Div1 g Source #

type FreeFunctorBy Div1 Source # 
Instance details

Defined in Data.HFunctor.Final

hoistDiv1 :: (f ~> g) -> Div1 f ~> Div1 g Source #

Map over the underlying context in a Div1.

liftDiv1 :: f ~> Div1 f Source #

Inject a single action in f into a Div f.

toDiv :: Div1 f ~> Div f Source #

A Div1 is a "non-empty" Div; this function "forgets" the non-empty property and turns it back into a normal Div.

runDiv1 :: Divise g => (f ~> g) -> Div1 f ~> g Source #

Interpret a Div1 into a context g, provided g is Divise.

div1NonEmptyF :: Contravariant f => Div1 f ~> NonEmptyF f Source #

Div1 is isomorphic to NonEmptyF for contravariant f. This witnesses one way of that isomorphism.

nonEmptyFDiv1 :: NonEmptyF f ~> Div1 f Source #

Div1 is isomorphic to NonEmptyF for contravariant f. This witnesses one way of that isomorphism.

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

The free Decide. Used to aggregate multiple possible consumers, directing the input into an appropriate consumer.

Constructors

Lose :: (a -> Void) -> Dec f a 
Choose :: (a -> Either b c) -> f b -> Dec f c -> Dec f a 

Instances

Instances details
Inject Dec Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

inject :: forall (f :: k -> Type). f ~> Dec f Source #

FreeOf Conclude Dec Source #

Since: 0.3.0.0

Instance details

Defined in Data.HFunctor.Final

Associated Types

type FreeFunctorBy Dec :: (Type -> Type) -> Constraint Source #

Methods

fromFree :: forall (f :: Type -> Type). Dec f ~> Final Conclude f Source #

toFree :: forall (f :: Type -> Type). FreeFunctorBy Dec f => Final Conclude f ~> Dec f Source #

HTraversable Dec Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

htraverse :: forall h f g (a :: k1). Applicative h => (forall (x :: k). f x -> h (g x)) -> Dec f a -> h (Dec g a) Source #

HFunctor Dec Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

hmap :: forall (f :: k -> Type) (g :: k -> Type). (f ~> g) -> Dec f ~> Dec g Source #

Conclude f => Interpret Dec (f :: Type -> Type) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

retract :: Dec f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Dec g ~> f Source #

Contravariant (Dec f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

contramap :: (a' -> a) -> Dec f a -> Dec f a' #

(>$) :: b -> Dec f b -> Dec f a #

Conclude (Dec f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

conclude :: (a -> Void) -> Dec f a Source #

Decide (Dec f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

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

Inalt (Dec f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

swerve :: (b -> a) -> (c -> a) -> (a -> Either b c) -> Dec f b -> Dec f c -> Dec f a Source #

swerved :: Dec f a -> Dec f b -> Dec f (Either a b) Source #

Inplus (Dec f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

reject :: (a -> Void) -> Dec f a Source #

Invariant (Dec f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

invmap :: (a -> b) -> (b -> a) -> Dec f a -> Dec f b #

type FreeFunctorBy Dec Source # 
Instance details

Defined in Data.HFunctor.Final

hoistDec :: forall f g. (f ~> g) -> Dec f ~> Dec g Source #

Map over the underlying context in a Dec.

liftDec :: f ~> Dec f Source #

Inject a single action in f into a Dec f.

runDec :: forall f g. Conclude g => (f ~> g) -> Dec f ~> g Source #

Interpret a Dec into a context g, provided g is Conclude.

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

The free Decide: a non-empty version of Dec.

Constructors

Dec1 :: (a -> Either b c) -> f b -> Dec f c -> Dec1 f a 

Instances

Instances details
Inject Dec1 Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

inject :: forall (f :: k -> Type). f ~> Dec1 f Source #

FreeOf Decide Dec1 Source #

Since: 0.3.0.0

Instance details

Defined in Data.HFunctor.Final

Associated Types

type FreeFunctorBy Dec1 :: (Type -> Type) -> Constraint Source #

Methods

fromFree :: forall (f :: Type -> Type). Dec1 f ~> Final Decide f Source #

toFree :: forall (f :: Type -> Type). FreeFunctorBy Dec1 f => Final Decide f ~> Dec1 f Source #

HTraversable Dec1 Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

htraverse :: forall h f g (a :: k1). Applicative h => (forall (x :: k). f x -> h (g x)) -> Dec1 f a -> h (Dec1 g a) Source #

HTraversable1 Dec1 Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

htraverse1 :: forall h f g (a :: k1). Apply h => (forall (x :: k). f x -> h (g x)) -> Dec1 f a -> h (Dec1 g a) Source #

HFunctor Dec1 Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

hmap :: forall (f :: k -> Type) (g :: k -> Type). (f ~> g) -> Dec1 f ~> Dec1 g Source #

Decide f => Interpret Dec1 (f :: Type -> Type) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

retract :: Dec1 f ~> f Source #

interpret :: forall (g :: k -> Type). (g ~> f) -> Dec1 g ~> f Source #

Contravariant (Dec1 f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

contramap :: (a' -> a) -> Dec1 f a -> Dec1 f a' #

(>$) :: b -> Dec1 f b -> Dec1 f a #

Decide (Dec1 f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

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

Inalt (Dec1 f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

swerve :: (b -> a) -> (c -> a) -> (a -> Either b c) -> Dec1 f b -> Dec1 f c -> Dec1 f a Source #

swerved :: Dec1 f a -> Dec1 f b -> Dec1 f (Either a b) Source #

Invariant (Dec1 f) Source # 
Instance details

Defined in Data.Functor.Contravariant.Divisible.Free

Methods

invmap :: (a -> b) -> (b -> a) -> Dec1 f a -> Dec1 f b #

type FreeFunctorBy Dec1 Source # 
Instance details

Defined in Data.HFunctor.Final

hoistDec1 :: forall f g. (f ~> g) -> Dec1 f ~> Dec1 g Source #

Map over the undering context in a Dec1.

liftDec1 :: f ~> Dec1 f Source #

Inject a single action in f into a Dec1 f.

toDec :: Dec1 f a -> Dec f a Source #

A Dec1 is a "non-empty" Dec; this function "forgets" the non-empty property and turns it back into a normal Dec.

runDec1 :: Decide g => (f ~> g) -> Dec1 f ~> g Source #

Interpret a Dec1 into a context g, provided g is Decide.