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

Data.Functor.Combinator

Description

Functor combinators and tools (typeclasses and utiility functions) to manipulate them. This is the main "entrypoint" of the library.

Classes include:

• HFunctor and HBifunctor, used to swap out the functors that the combinators modify
• Interpret, Associative, Monoidal, used to inject and interpret functor values with respect to their combinators.

We have some helpful utility functions, as well, built on top of these typeclasses.

The second half of this module exports the various useful functor combinators that can modify functors to add extra functionality, or join two functors together and mix them in different ways. Use them to build your final structure by combining simpler ones in composable ways!

See https://blog.jle.im/entry/functor-combinatorpedia.html and the README for a tutorial and a rundown on each different functor combinator.

Synopsis

# Classes

A lot of type signatures are stated in terms of ~>. ~> represents a "natural transformation" between two functors: a value of type f ~> g is a value of type 'f a -> g a that works for any a@.

type (~>) (f :: k -> Type) (g :: k -> Type) = forall (x :: k). f x -> g x infixr 0 #

A natural transformation from f to g.

type (<~>) f g = forall p a. Profunctor p => p (g a) (g a) -> p (f a) (f a) infixr 0 Source #

The type of an isomorphism between two functors. f <~> g means that f and g are isomorphic to each other.

We can effectively use an f <~> g with:

viewF   :: (f <~> g) -> f a -> g a
reviewF :: (f <~> g) -> g a -> a a


Use viewF to extract the "f to g" function, and reviewF to extract the "g to f" function. Reviewing and viewing the same value (or vice versa) leaves the value unchanged.

One nice thing is that we can compose isomorphisms using . from Prelude:

(.) :: f <~> g
-> g <~> h
-> f <~> h


Another nice thing about this representation is that we have the "identity" isomorphism by using id from Prelude.

id :: f <~> g


As a convention, most isomorphisms have form "X-ing", where the forwards function is "ing". For example, we have:

splittingSF :: Monoidal t => SF t a <~> t f (MF t f)
splitSF     :: Monoidal t => SF t a  ~> t f (MF t f)


## Single Functors

Classes that deal with single-functor combinators, that enhance a single functor.

class HFunctor t where Source #

An HFunctor can be thought of a unary "functor transformer" --- a basic functor combinator. It takes a functor as input and returns a functor as output.

It "enhances" a functor with extra structure (sort of like how a monad transformer enhances a Monad with extra structure).

As a uniform inteface, we can "swap the underlying functor" (also sometimes called "hoisting"). This is what hmap does: it lets us swap out the f in a t f for a t g.

For example, the free monad Free takes a Functor and returns a new Functor. In the process, it provides a monadic structure over f. hmap lets us turn a Free f into a Free g: a monad built over f can be turned into a monad built over g.

For the ability to move in and out of the enhanced functor, see Inject and Interpret.

This class is similar to MFunctor from Control.Monad.Morph, but instances must work without a Monad constraint.

This class is also found in the hschema library with the same name.

Methods

hmap :: (f ~> g) -> t f ~> t g Source #

If we can turn an f into a g, then we can turn a t f into a t g.

It must be the case that

hmap id == id


Essentially, t f adds some "extra structure" to f. hmap must swap out the functor, without affecting the added structure.

For example, ListF f a is essentially a list of f as. If we hmap to swap out the f as for g as, then we must ensure that the "added structure" (here, the number of items in the list, and the ordering of those items) remains the same. So, hmap must preserve the number of items in the list, and must maintain the ordering.

The law hmap id == id is a way of formalizing this property.

Instances
 Source # Instance detailsDefined in Data.Functor.Apply.Free Methodshmap :: (f ~> g) -> Ap1 f ~> Ap1 g Source # HFunctor (Reverse :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Reverse f ~> Reverse g Source # HFunctor (Backwards :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Backwards f ~> Backwards g Source # HFunctor (IdentityT :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> IdentityT f ~> IdentityT g Source # HFunctor (Flagged :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Flagged f ~> Flagged g Source # HFunctor (Steps :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Steps f ~> Steps g Source # HFunctor (Step :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Step f ~> Step g Source # HFunctor (Void2 :: (k1 -> Type) -> k2 -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Void2 f ~> Void2 g Source # HFunctor (ReaderT r :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> ReaderT r f ~> ReaderT r g Source # HFunctor (Sum f :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f0 ~> g) -> Sum f f0 ~> Sum f g Source # HFunctor (Product f :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f0 ~> g) -> Product f f0 ~> Product f g Source # HFunctor ((:+:) f :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f0 ~> g) -> (f :+: f0) ~> (f :+: g) Source # HFunctor ((:*:) f :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f0 ~> g) -> (f :*: f0) ~> (f :*: g) Source # HFunctor (ProxyF :: (k1 -> Type) -> k2 -> Type) Source # Instance detailsDefined in Data.HFunctor Methodshmap :: (f ~> g) -> ProxyF f ~> ProxyF g Source # HFunctor t => HFunctor (HLift t :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor Methodshmap :: (f ~> g) -> HLift t f ~> HLift t g Source # HFunctor t => HFunctor (HFree t :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor Methodshmap :: (f ~> g) -> HFree t f ~> HFree t g Source # HBifunctor t => HFunctor (Chain1 t :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Chain Methodshmap :: (f ~> g) -> Chain1 t f ~> Chain1 t g Source # HFunctor (M1 i c :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> M1 i c f ~> M1 i c g Source # Functor f => HFunctor ((:.:) f :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f0 ~> g) -> (f :.: f0) ~> (f :.: g) Source # HFunctor (Joker f :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f0 ~> g) -> Joker f f0 ~> Joker f g Source # HFunctor (ConstF e :: (k1 -> Type) -> k2 -> Type) Source # Instance detailsDefined in Data.HFunctor Methodshmap :: (f ~> g) -> ConstF e f ~> ConstF e g Source # HFunctor (LeftF f :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HBifunctor Methodshmap :: (f0 ~> g) -> LeftF f f0 ~> LeftF f g Source # HFunctor (RightF f :: (k1 -> Type) -> k1 -> Type) Source # Instance detailsDefined in Data.HBifunctor Methodshmap :: (f0 ~> g) -> RightF f f0 ~> RightF f g Source # HFunctor (RightF f :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HBifunctor Methodshmap :: (f0 ~> g) -> RightF f f0 ~> RightF f g Source # HBifunctor t => HFunctor (WrappedHBifunctor t f :: (k1 -> Type) -> k2 -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f0 ~> g) -> WrappedHBifunctor t f f0 ~> WrappedHBifunctor t f g Source # HFunctor (Void3 f :: (k2 -> Type) -> k1 -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f0 ~> g) -> Void3 f f0 ~> Void3 f g Source # HBifunctor t => HFunctor (Chain t i :: (k1 -> Type) -> k2 -> Type) Source # Instance detailsDefined in Data.HFunctor.Chain Methodshmap :: (f ~> g) -> Chain t i f ~> Chain t i g Source # HFunctor (CoRec :: (k -> Type) -> [k] -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> CoRec f ~> CoRec g Source # HFunctor (Rec :: (k -> Type) -> [k] -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Rec f ~> Rec g Source # HFunctor (Tagged :: (k -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Tagged f ~> Tagged g Source # Source # Note that there is no Interpret or Bind instance, because inject requires Functor f. Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> MaybeT f ~> MaybeT g Source # Source # Note that there is no Interpret or Bind instance, because inject requires Functor f. Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> F f ~> F g Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Ap f ~> Ap g Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Ap f ~> Ap g Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Ap f ~> Ap g Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Alt f ~> Alt g Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Yoneda f ~> Yoneda g Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Coyoneda f ~> Coyoneda g Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methods Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> MaybeApply f ~> MaybeApply g Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Lift f ~> Lift g Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> ListF f ~> ListF g Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> NonEmptyF f ~> NonEmptyF g Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> MaybeF f ~> MaybeF g Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Free1 f ~> Free1 g Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Free f ~> Free g Source # HFunctor (EnvT e :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> EnvT e f ~> EnvT e g Source # HFunctor (Day f :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f0 ~> g) -> Day f f0 ~> Day f g Source # HFunctor (These1 f :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f0 ~> g) -> These1 f f0 ~> These1 f g Source # HFunctor (MapF k :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> MapF k f ~> MapF k g Source # HFunctor (NEMapF k :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> NEMapF k f ~> NEMapF k g Source # HFunctor (Comp f :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f0 ~> g) -> Comp f f0 ~> Comp f g Source # HFunctor (Final c :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor.Final Methodshmap :: (f ~> g) -> Final c f ~> Final c g Source # (HFunctor s, HFunctor t) => HFunctor (ComposeT s t :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> ComposeT s t f ~> ComposeT s t g Source #

class HFunctor t => Inject t where Source #

A typeclass for HFunctors where you can "inject" an f a into a t f a:

inject :: f a -> t f a


If you think of t f a as an "enhanced f", then inject allows you to use an f as its enhanced form.

With the exception of directly pattern matching on the result, inject itself is not too useful in the general case without Interpret to allow us to interpret or retrieve back the f.

Methods

inject :: f ~> t f Source #

Lift from f into the enhanced t f structure. Analogous to lift from MonadTrans.

Note that this lets us "lift" a f a; if you want to lift an a with a -> t f a, check if t f is an instance of Applicative or Pointed.

Instances
 Source # Instance detailsDefined in Data.Functor.Apply.Free Methodsinject :: f ~> Ap1 f Source # Inject (Reverse :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor Methods Inject (Backwards :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor Methods Inject (IdentityT :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor Methods Inject (Flagged :: (k -> Type) -> k -> Type) Source # Injects with False.Equivalent to instance for EnvT Any and HLift IdentityT. Instance detailsDefined in Data.HFunctor Methods Inject (Steps :: (k -> Type) -> k -> Type) Source # Injects into a singleton map at 0; same behavior as NEMapF (Sum Natural). Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> Steps f Source # Inject (Step :: (k -> Type) -> k -> Type) Source # Injects with 0.Equivalent to instance for EnvT (Sum Natural). Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> Step f Source # HFunctor t => Inject (HFree t :: (k -> Type) -> k -> Type) Source # HFree is the "free HBind and Inject" for any HFunctor Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> HFree t f Source # HFunctor t => Inject (HLift t :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> HLift t f Source # Inject (ProxyF :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor Methods Inject (ReaderT r :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> ReaderT r f Source # Inject (Sum f :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f0 ~> Sum f f0 Source # Inject ((:+:) f :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f0 ~> (f :+: f0) Source # HBifunctor t => Inject (Chain1 t :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Chain Methodsinject :: f ~> Chain1 t f Source # Monoid e => Inject (ConstF e :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> ConstF e f Source # Inject (M1 i c :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> M1 i c f Source # Applicative f => Inject ((:.:) f :: (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f0 ~> (f :.: f0) Source # Inject (RightF f :: (k1 -> Type) -> k1 -> Type) Source # Instance detailsDefined in Data.HBifunctor Methodsinject :: f0 ~> RightF f f0 Source # Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> Ap f Source # Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> Ap f Source # Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> Ap f Source # Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> Alt f Source # Source # Instance detailsDefined in Data.HFunctor Methods Source # Instance detailsDefined in Data.HFunctor Methods Source # Instance detailsDefined in Data.HFunctor Methods Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> Lift f Source # Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> ListF f Source # Source # Instance detailsDefined in Data.HFunctor Methods Source # Instance detailsDefined in Data.HFunctor Methods Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> Free1 f Source # Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> Free f Source # Monoid e => Inject (EnvT e :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> EnvT e f Source # Inject (These1 f :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f0 ~> These1 f f0 Source # Monoid k => Inject (MapF k :: (Type -> Type) -> Type -> Type) Source # Injects into a singleton map at mempty. Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> MapF k f Source # Monoid k => Inject (NEMapF k :: (Type -> Type) -> Type -> Type) Source # Injects into a singleton map at mempty. Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> NEMapF k f Source # Applicative f => Inject (Comp f :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f0 ~> Comp f f0 Source # Inject (Final c :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor.Final Methodsinject :: f ~> Final c f Source # Plus f => Inject ((:*:) f :: (Type -> Type) -> Type -> Type) Source # Only uses zero Instance detailsDefined in Data.HFunctor Methodsinject :: f0 ~> (f :*: f0) Source # Plus f => Inject (Product f :: (Type -> Type) -> Type -> Type) Source # Only uses zero Instance detailsDefined in Data.HFunctor Methodsinject :: f0 ~> Product f f0 Source # (Inject s, Inject t) => Inject (ComposeT s t :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> ComposeT s t f Source # (Tensor t, i ~ I t) => Inject (Chain t i :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor.Chain Methodsinject :: f ~> Chain t i f Source #

class Inject t => Interpret t where Source #

An Interpret lets us move in and out of the "enhanced" Functor.

For example, Free f is f enhanced with monadic structure. We get:

inject    :: f a -> Free f a
interpret :: Monad m => (forall x. f x -> m x) -> Free f a -> m a


inject will let us use our f inside the enhanced Free f. interpret will let us "extract" the f from a Free f if we can give an interpreting function that interprets f into some target Monad.

The type family C tells us the typeclass constraint of the "target" functor. For Free, it is Monad, but for other Interpret instances, we might have other constraints.

We enforce that:

interpret id . inject == id
-- or
retract . inject == id


That is, if we lift a value into our structure, then immediately interpret it out as itself, it should lave the value unchanged.

Minimal complete definition

Associated Types

type C t :: (Type -> Type) -> Constraint Source #

The constraint on the target context of interpret. It's basically the constraint that allows you to "exit" or "run" an Interpret.

Methods

retract :: C t f => t f ~> f Source #

Remove the f out of the enhanced t f structure, provided that f satisfies the necessary constraints. If it doesn't, it needs to be properly interpreted out.

interpret :: C t g => (f ~> g) -> t f ~> g Source #

Given an "interpeting function" from f to g, interpret the f out of the t f into a final context g.

Instances
 Source # A free Applicative Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C Ap :: (Type -> Type) -> Constraint Source # Methodsretract :: C Ap f => Ap f ~> f Source #interpret :: C Ap g => (f ~> g) -> Ap f ~> g Source # Source # A free Applicative Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C Ap :: (Type -> Type) -> Constraint Source # Methodsretract :: C Ap f => Ap f ~> f Source #interpret :: C Ap g => (f ~> g) -> Ap f ~> g Source # Source # A free Applicative Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C Ap :: (Type -> Type) -> Constraint Source # Methodsretract :: C Ap f => Ap f ~> f Source #interpret :: C Ap g => (f ~> g) -> Ap f ~> g Source # Source # A free Alternative Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C Alt :: (Type -> Type) -> Constraint Source # Methodsretract :: C Alt f => Alt f ~> f Source #interpret :: C Alt g => (f ~> g) -> Alt f ~> g Source # Source # A free Functor Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C Coyoneda :: (Type -> Type) -> Constraint Source # Methodsinterpret :: C Coyoneda g => (f ~> g) -> Coyoneda f ~> g Source # Source # Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C WrappedApplicative :: (Type -> Type) -> Constraint Source # Methodsinterpret :: C WrappedApplicative g => (f ~> g) -> WrappedApplicative f ~> g Source # Source # A free Pointed Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C MaybeApply :: (Type -> Type) -> Constraint Source # Methodsinterpret :: C MaybeApply g => (f ~> g) -> MaybeApply f ~> g Source # Source # A free Pointed Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C Lift :: (Type -> Type) -> Constraint Source # Methodsretract :: C Lift f => Lift f ~> f Source #interpret :: C Lift g => (f ~> g) -> Lift f ~> g Source # Source # A free Plus Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C ListF :: (Type -> Type) -> Constraint Source # Methodsretract :: C ListF f => ListF f ~> f Source #interpret :: C ListF g => (f ~> g) -> ListF f ~> g Source # Source # A free Alt Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C NonEmptyF :: (Type -> Type) -> Constraint Source # Methodsinterpret :: C NonEmptyF g => (f ~> g) -> NonEmptyF f ~> g Source # Source # Technically, C is over-constrained: we only need zero :: f a, but we don't really have that typeclass in any standard hierarchies. We use Plus here instead, but we never use . This would only go wrong in situations where your type supports zero but not , like instances of MonadFail without MonadPlus. Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C MaybeF :: (Type -> Type) -> Constraint Source # Methodsretract :: C MaybeF f => MaybeF f ~> f Source #interpret :: C MaybeF g => (f ~> g) -> MaybeF f ~> g Source # Source # A free Bind Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C Free1 :: (Type -> Type) -> Constraint Source # Methodsretract :: C Free1 f => Free1 f ~> f Source #interpret :: C Free1 g => (f ~> g) -> Free1 f ~> g Source # Source # A free Monad Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C Free :: (Type -> Type) -> Constraint Source # Methodsretract :: C Free f => Free f ~> f Source #interpret :: C Free g => (f ~> g) -> Free f ~> g Source # Source # Instance detailsDefined in Data.Functor.Apply.Free Associated Typestype C Ap1 :: (Type -> Type) -> Constraint Source # Methodsretract :: C Ap1 f => Ap1 f ~> f Source #interpret :: C Ap1 g => (f ~> g) -> Ap1 f ~> g Source # Monoid e => Interpret (EnvT e) Source # This ignores the environment, so interpret /= hbind Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C (EnvT e) :: (Type -> Type) -> Constraint Source # Methodsretract :: C (EnvT e) f => EnvT e f ~> f Source #interpret :: C (EnvT e) g => (f ~> g) -> EnvT e f ~> g Source # Interpret (IdentityT :: (Type -> Type) -> Type -> Type) Source # A free Unconstrained Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C IdentityT :: (Type -> Type) -> Constraint Source # Methodsinterpret :: C IdentityT g => (f ~> g) -> IdentityT f ~> g Source # Source # Technically, C is over-constrained: we only need zero :: f a, but we don't really have that typeclass in any standard hierarchies. We use Plus here instead, but we never use . This would only go wrong in situations where your type supports zero but not , like instances of MonadFail without MonadPlus. Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C (These1 f) :: (Type -> Type) -> Constraint Source # Methodsretract :: C (These1 f) f0 => These1 f f0 ~> f0 Source #interpret :: C (These1 f) g => (f0 ~> g) -> These1 f f0 ~> g Source # Interpret (Reverse :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C Reverse :: (Type -> Type) -> Constraint Source # Methodsretract :: C Reverse f => Reverse f ~> f Source #interpret :: C Reverse g => (f ~> g) -> Reverse f ~> g Source # Interpret (Backwards :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C Backwards :: (Type -> Type) -> Constraint Source # Methodsinterpret :: C Backwards g => (f ~> g) -> Backwards f ~> g Source # Monoid k => Interpret (MapF k) Source # Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C (MapF k) :: (Type -> Type) -> Constraint Source # Methodsretract :: C (MapF k) f => MapF k f ~> f Source #interpret :: C (MapF k) g => (f ~> g) -> MapF k f ~> g Source # Monoid k => Interpret (NEMapF k) Source # Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C (NEMapF k) :: (Type -> Type) -> Constraint Source # Methodsretract :: C (NEMapF k) f => NEMapF k f ~> f Source #interpret :: C (NEMapF k) g => (f ~> g) -> NEMapF k f ~> g Source # Interpret (Step :: (Type -> Type) -> Type -> Type) Source # Equivalent to instance for EnvT (Sum Natural). Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C Step :: (Type -> Type) -> Constraint Source # Methodsretract :: C Step f => Step f ~> f Source #interpret :: C Step g => (f ~> g) -> Step f ~> g Source # Interpret (Steps :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C Steps :: (Type -> Type) -> Constraint Source # Methodsretract :: C Steps f => Steps f ~> f Source #interpret :: C Steps g => (f ~> g) -> Steps f ~> g Source # Interpret (Flagged :: (Type -> Type) -> Type -> Type) Source # Equivalent to instance for EnvT Any and HLift IdentityT. Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C Flagged :: (Type -> Type) -> Constraint Source # Methodsretract :: C Flagged f => Flagged f ~> f Source #interpret :: C Flagged g => (f ~> g) -> Flagged f ~> g Source # Source # Instance detailsDefined in Data.HFunctor.Final Associated Typestype C (Final c) :: (Type -> Type) -> Constraint Source # Methodsretract :: C (Final c) f => Final c f ~> f Source #interpret :: C (Final c) g => (f ~> g) -> Final c f ~> g Source # Source # Technically, C is over-constrained: we only need zero :: f a, but we don't really have that typeclass in any standard hierarchies. We use Plus here instead, but we never use . This would only go wrong in situations where your type supports zero but not , like instances of MonadFail without MonadPlus. Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C ((:+:) f) :: (Type -> Type) -> Constraint Source # Methodsretract :: C ((:+:) f) f0 => (f :+: f0) ~> f0 Source #interpret :: C ((:+:) f) g => (f0 ~> g) -> (f :+: f0) ~> g Source # Plus f => Interpret ((:*:) f) Source # Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C ((:*:) f) :: (Type -> Type) -> Constraint Source # Methodsretract :: C ((:*:) f) f0 => (f :*: f0) ~> f0 Source #interpret :: C ((:*:) f) g => (f0 ~> g) -> (f :*: f0) ~> g Source # Plus f => Interpret (Product f) Source # Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C (Product f) :: (Type -> Type) -> Constraint Source # Methodsretract :: C (Product f) f0 => Product f f0 ~> f0 Source #interpret :: C (Product f) g => (f0 ~> g) -> Product f f0 ~> g Source # Interpret (Sum f) Source # Technically, C is over-constrained: we only need zero :: f a, but we don't really have that typeclass in any standard hierarchies. We use Plus here instead, but we never use . This would only go wrong in situations where your type supports zero but not , like instances of MonadFail without MonadPlus. Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C (Sum f) :: (Type -> Type) -> Constraint Source # Methodsretract :: C (Sum f) f0 => Sum f f0 ~> f0 Source #interpret :: C (Sum f) g => (f0 ~> g) -> Sum f f0 ~> g Source # (Interpret s, Interpret t) => Interpret (ComposeT s t) Source # Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C (ComposeT s t) :: (Type -> Type) -> Constraint Source # Methodsretract :: C (ComposeT s t) f => ComposeT s t f ~> f Source #interpret :: C (ComposeT s t) g => (f ~> g) -> ComposeT s t f ~> g Source # Interpret (ReaderT r :: (Type -> Type) -> Type -> Type) Source # A free MonadReader, but only when applied to a Monad. Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C (ReaderT r) :: (Type -> Type) -> Constraint Source # Methodsretract :: C (ReaderT r) f => ReaderT r f ~> f Source #interpret :: C (ReaderT r) g => (f ~> g) -> ReaderT r f ~> g Source # Interpret (ProxyF :: (Type -> Type) -> Type -> Type) Source # The only way for this to obey retract . inject == id is to have it impossible to retract out of. Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C ProxyF :: (Type -> Type) -> Constraint Source # Methodsretract :: C ProxyF f => ProxyF f ~> f Source #interpret :: C ProxyF g => (f ~> g) -> ProxyF f ~> g Source # Interpret t => Interpret (HFree t) Source # Never uses inject Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C (HFree t) :: (Type -> Type) -> Constraint Source # Methodsretract :: C (HFree t) f => HFree t f ~> f Source #interpret :: C (HFree t) g => (f ~> g) -> HFree t f ~> g Source # Interpret t => Interpret (HLift t) Source # Never uses inject Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C (HLift t) :: (Type -> Type) -> Constraint Source # Methodsretract :: C (HLift t) f => HLift t f ~> f Source #interpret :: C (HLift t) g => (f ~> g) -> HLift t f ~> g Source # (HBifunctor t, Semigroupoidal t) => Interpret (Chain1 t) Source # Instance detailsDefined in Data.HFunctor.Chain Associated Typestype C (Chain1 t) :: (Type -> Type) -> Constraint Source # Methodsretract :: C (Chain1 t) f => Chain1 t f ~> f Source #interpret :: C (Chain1 t) g => (f ~> g) -> Chain1 t f ~> g Source # Interpret (M1 i c :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C (M1 i c) :: (Type -> Type) -> Constraint Source # Methodsretract :: C (M1 i c) f => M1 i c f ~> f Source #interpret :: C (M1 i c) g => (f ~> g) -> M1 i c f ~> g Source # Monoid e => Interpret (ConstF e :: (Type -> Type) -> Type -> Type) Source # The only way for this to obey retract . inject == id is to have it impossible to retract out of. Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C (ConstF e) :: (Type -> Type) -> Constraint Source # Methodsretract :: C (ConstF e) f => ConstF e f ~> f Source #interpret :: C (ConstF e) g => (f ~> g) -> ConstF e f ~> g Source # Interpret (RightF f :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor Associated Typestype C (RightF f) :: (Type -> Type) -> Constraint Source # Methodsretract :: C (RightF f) f0 => RightF f f0 ~> f0 Source #interpret :: C (RightF f) g => (f0 ~> g) -> RightF f f0 ~> g Source # (Monoidal t, i ~ I t) => Interpret (Chain t i) Source # We can collapse and interpret an Chain t i if we have Tensor t. Instance detailsDefined in Data.HFunctor.Chain Associated Typestype C (Chain t i) :: (Type -> Type) -> Constraint Source # Methodsretract :: C (Chain t i) f => Chain t i f ~> f Source #interpret :: C (Chain t i) g => (f ~> g) -> Chain t i f ~> g Source #

forI :: (Interpret t, C t g) => t f a -> (f ~> g) -> g a Source #

A convenient flipped version of interpret.

getI :: (Interpret t, C t (Const b)) => (forall x. f x -> b) -> t f a -> b Source #

Useful wrapper over interpret to allow you to directly extract a value b out of the t f a, if you can convert f x into b.

Note that depending on the constraints on the interpretation of t, you may have extra constraints on b.

• If C t is Unconstrained, there are no constraints on b
• If C t is Apply, b needs to be an instance of Semigroup
• If C t is Applicative, b needs to be an instance of Monoid

For some constraints (like Monad), this will not be usable.

-- get the length of the Map String in the Step.
collectI length
:: Step (Map String) Bool
-> Int


collectI :: (Interpret t, C t (Const [b])) => (forall x. f x -> b) -> t f a -> [b] Source #

Useful wrapper over getI to allow you to collect a b from all instances of f inside a t f a.

This will work if C t is Unconstrained, Apply, or Applicative.

-- get the lengths of all Map Strings in the Ap.
collectI length
:: Ap (Map String) Bool
-> [Int]


## Multi-Functors

Classes that deal with two-functor combinators, that "mix" two functors together in some way.

class HBifunctor t where Source #

A HBifunctor is like an HFunctor, but it enhances two different functors instead of just one.

Usually, it enhaces them "together" in some sort of combining way.

This typeclass provides a uniform instance for "swapping out" or "hoisting" the enhanced functors. We can hoist the first one with hleft, the second one with hright, or both at the same time with hbimap.

For example, the f :*: g type gives us "both f and g":

data (f :*: g) a = f a :*: g a


It combines both f and g into a unified structure --- here, it does it by providing both f and g.

The single law is:

hbimap id id == id


This ensures that hleft, hright, and hbimap do not affect the structure that t adds on top of the underlying functors.

Minimal complete definition

Methods

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

Swap out the first transformed functor.

hright :: (g ~> k) -> t f g ~> t f k Source #

Swap out the second transformed functor.

hbimap :: (f ~> j) -> (g ~> k) -> t f g ~> t j k Source #

Swap out both transformed functors at the same time.

Instances
 HBifunctor (Sum :: (k -> Type) -> (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshleft :: (f ~> j) -> Sum f g ~> Sum j g Source #hright :: (g ~> k0) -> Sum f g ~> Sum f k0 Source #hbimap :: (f ~> j) -> (g ~> k0) -> Sum f g ~> Sum j k0 Source # HBifunctor ((:+:) :: (k -> Type) -> (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshleft :: (f ~> j) -> (f :+: g) ~> (j :+: g) Source #hright :: (g ~> k0) -> (f :+: g) ~> (f :+: k0) Source #hbimap :: (f ~> j) -> (g ~> k0) -> (f :+: g) ~> (j :+: k0) Source # HBifunctor (Product :: (k -> Type) -> (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshleft :: (f ~> j) -> Product f g ~> Product j g Source #hright :: (g ~> k0) -> Product f g ~> Product f k0 Source #hbimap :: (f ~> j) -> (g ~> k0) -> Product f g ~> Product j k0 Source # HBifunctor ((:*:) :: (k -> Type) -> (k -> Type) -> k -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshleft :: (f ~> j) -> (f :*: g) ~> (j :*: g) Source #hright :: (g ~> k0) -> (f :*: g) ~> (f :*: k0) Source #hbimap :: (f ~> j) -> (g ~> k0) -> (f :*: g) ~> (j :*: k0) Source # HBifunctor (Joker :: (k2 -> Type) -> (k1 -> Type) -> k2 -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshleft :: (f ~> j) -> Joker f g ~> Joker j g Source #hright :: (g ~> k) -> Joker f g ~> Joker f k Source #hbimap :: (f ~> j) -> (g ~> k) -> Joker f g ~> Joker j k Source # HBifunctor (LeftF :: (k2 -> Type) -> (k1 -> Type) -> k2 -> Type) Source # Instance detailsDefined in Data.HBifunctor Methodshleft :: (f ~> j) -> LeftF f g ~> LeftF j g Source #hright :: (g ~> k) -> LeftF f g ~> LeftF f k Source #hbimap :: (f ~> j) -> (g ~> k) -> LeftF f g ~> LeftF j k Source # HBifunctor (RightF :: (k1 -> Type) -> (k2 -> Type) -> k2 -> Type) Source # Instance detailsDefined in Data.HBifunctor Methodshleft :: (f ~> j) -> RightF f g ~> RightF j g Source #hright :: (g ~> k) -> RightF f g ~> RightF f k Source #hbimap :: (f ~> j) -> (g ~> k) -> RightF f g ~> RightF j k Source # HBifunctor (Void3 :: (k1 -> Type) -> (k2 -> Type) -> k3 -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshleft :: (f ~> j) -> Void3 f g ~> Void3 j g Source #hright :: (g ~> k) -> Void3 f g ~> Void3 f k Source #hbimap :: (f ~> j) -> (g ~> k) -> Void3 f g ~> Void3 j k Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshleft :: (f ~> j) -> Day f g ~> Day j g Source #hright :: (g ~> k) -> Day f g ~> Day f k Source #hbimap :: (f ~> j) -> (g ~> k) -> Day f g ~> Day j k Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshleft :: (f ~> j) -> These1 f g ~> These1 j g Source #hright :: (g ~> k) -> These1 f g ~> These1 f k Source #hbimap :: (f ~> j) -> (g ~> k) -> These1 f g ~> These1 j k Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshleft :: (f ~> j) -> Comp f g ~> Comp j g Source #hright :: (g ~> k) -> Comp f g ~> Comp f k Source #hbimap :: (f ~> j) -> (g ~> k) -> Comp f g ~> Comp j k Source #

### Associative

class HBifunctor t => Associative t where Source #

An HBifunctor where it doesn't matter which binds first is Associative. Knowing this gives us a lot of power to rearrange the internals of our HFunctor at will.

For example, for the functor product:

data (f :*: g) a = f a :*: g a


We know that f :*: (g :*: h) is the same as (f :*: g) :*: h.

Methods

associating :: (Functor f, Functor g, Functor h) => t f (t g h) <~> t (t f g) h Source #

The isomorphism between t f (t g h) a and t (t f g) h a. To use this isomorphism, see assoc and disassoc.

Instances
 Source # Instance detailsDefined in Data.HBifunctor.Associative Methodsassociating :: (Functor f, Functor g, Functor h) => Day f (Day g h) <~> Day (Day f g) h Source # Source # Instance detailsDefined in Data.HBifunctor.Associative Methodsassociating :: (Functor f, Functor g, Functor h) => These1 f (These1 g h) <~> These1 (These1 f g) h Source # Source # Instance detailsDefined in Data.HBifunctor.Associative Methodsassociating :: (Functor f, Functor g, Functor h) => Comp f (Comp g h) <~> Comp (Comp f g) h Source # Associative ((:+:) :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Associative Methodsassociating :: (Functor f, Functor g, Functor h) => (f :+: (g :+: h)) <~> ((f :+: g) :+: h) Source # Associative ((:*:) :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Associative Methodsassociating :: (Functor f, Functor g, Functor h) => (f :*: (g :*: h)) <~> ((f :*: g) :*: h) Source # Associative (Product :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Associative Methodsassociating :: (Functor f, Functor g, Functor h) => Product f (Product g h) <~> Product (Product f g) h Source # Associative (Sum :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Associative Methodsassociating :: (Functor f, Functor g, Functor h) => Sum f (Sum g h) <~> Sum (Sum f g) h Source # Associative (Joker :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Associative Methodsassociating :: (Functor f, Functor g, Functor h) => Joker f (Joker g h) <~> Joker (Joker f g) h Source # Associative (LeftF :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Associative Methodsassociating :: (Functor f, Functor g, Functor h) => LeftF f (LeftF g h) <~> LeftF (LeftF f g) h Source # Associative (RightF :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Associative Methodsassociating :: (Functor f, Functor g, Functor h) => RightF f (RightF g h) <~> RightF (RightF f g) h Source # Associative (Void3 :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Associative Methodsassociating :: (Functor f, Functor g, Functor h) => Void3 f (Void3 g h) <~> Void3 (Void3 f g) h Source #

class (Associative t, Interpret (SF t)) => Semigroupoidal t where Source #

For some ts, you can represent the act of applying a functor f to t many times, as a single type. That is, there is some type SF t f that is equivalent to one of:

• f a -- 1 time
• t f f a -- 2 times
• t f (t f f) a -- 3 times
• t f (t f (t f f)) a -- 4 times
• t f (t f (t f (t f f))) a -- 5 times
• .. etc

This typeclass associates each t with its "induced semigroupoidal functor combinator" SF t.

This is useful because sometimes you might want to describe a type that can be t f f, t f (t f f), t f (t f (t f f)), etc.; "f applied to itself", with at least one f. This typeclass lets you use a type like NonEmptyF in terms of repeated applications of :*:, or Ap1 in terms of repeated applications of Day, or Free1 in terms of repeated applications of Comp, etc.

For example, f :*: f can be interpreted as "a free selection of two fs", allowing you to specify "I have to fs that I can use". If you want to specify "I want 1, 2, or many different fs that I can use", you can use NonEmptyF f.

At the high level, the main way to use a Semigroupoidal is with biretract and binterpret:

biretract :: t f f ~> f
binterpret :: (f ~> h) -> (g ~> h) -> t f g ~> h


which are like the HBifunctor versions of retract and interpret: they fully "mix" together the two inputs of t.

Also useful is:

toSF :: t f f a -> SF t f a


Which converts a t into its aggregate type SF.

In reality, most Semigroupoidal instances are also Monoidal instances, so you can think of the separation as mostly to help organize functionality. However, there are two non-monoidal semigroupoidal instances of note: LeftF and RightF, which are higher order analogues of the First and Last semigroups, roughly.

Minimal complete definition

Associated Types

type SF t :: (Type -> Type) -> Type -> Type Source #

The "semigroup functor combinator" generated by t.

A value of type SF t f a is equivalent to one of:

• f a
• t f f a
• t f (t f f) a
• t f (t f (t f f)) a
• t f (t f (t f (t f f))) a
• .. etc

For example, for :*:, we have NonEmptyF. This is because:

x             ~ NonEmptyF (x :| [])      ~ inject x
x :*: y       ~ NonEmptyF (x :| [y])     ~ toSF (x :*: y)
x :*: y :*: z ~ NonEmptyF (x :| [y,z])
-- etc.


You can create an "singleton" one with inject, or else one from a single t f f with toSF.

Methods

appendSF :: t (SF t f) (SF t f) ~> SF t f Source #

If a SF t f represents multiple applications of t f to itself, then we can also "append" two SF t fs applied to themselves into one giant SF t f containing all of the t fs.

consSF :: t f (SF t f) ~> SF t f Source #

Prepend an application of t f to the front of a SF t f.

toSF :: t f f ~> SF t f Source #

Embed a direct application of f to itself into a SF t f.

biretract :: CS t f => t f f ~> f Source #

The HBifunctor analogy of retract. It retracts both fs into a single f, effectively fully mixing them together.

binterpret :: CS t h => (f ~> h) -> (g ~> h) -> t f g ~> h Source #

The HBifunctor analogy of interpret. It takes two interpreting functions, and mixes them together into a target functor h.

Instances
 Source # Instance detailsDefined in Data.HBifunctor.Associative Associated Typestype SF Day :: (Type -> Type) -> Type -> Type Source # MethodsappendSF :: Day (SF Day f) (SF Day f) ~> SF Day f Source #matchSF :: Functor f => SF Day f ~> (f :+: Day f (SF Day f)) Source #consSF :: Day f (SF Day f) ~> SF Day f Source #toSF :: Day f f ~> SF Day f Source #biretract :: CS Day f => Day f f ~> f Source #binterpret :: CS Day h => (f ~> h) -> (g ~> h) -> Day f g ~> h Source # Source # Ideally here SF would be equivalent to MF, just like for :+:. This should be possible if we can write a bijection. This bijection should be possible in theory --- but it has not yet been implemented. Instance detailsDefined in Data.HBifunctor.Associative Associated Typestype SF These1 :: (Type -> Type) -> Type -> Type Source # MethodsmatchSF :: Functor f => SF These1 f ~> (f :+: These1 f (SF These1 f)) Source #biretract :: CS These1 f => These1 f f ~> f Source #binterpret :: CS These1 h => (f ~> h) -> (g ~> h) -> These1 f g ~> h Source # Source # Instance detailsDefined in Data.HBifunctor.Associative Associated Typestype SF Comp :: (Type -> Type) -> Type -> Type Source # MethodsappendSF :: Comp (SF Comp f) (SF Comp f) ~> SF Comp f Source #matchSF :: Functor f => SF Comp f ~> (f :+: Comp f (SF Comp f)) Source #consSF :: Comp f (SF Comp f) ~> SF Comp f Source #toSF :: Comp f f ~> SF Comp f Source #biretract :: CS Comp f => Comp f f ~> f Source #binterpret :: CS Comp h => (f ~> h) -> (g ~> h) -> Comp f g ~> h Source # Semigroupoidal ((:+:) :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Associative Associated Typestype SF (:+:) :: (Type -> Type) -> Type -> Type Source # MethodsmatchSF :: Functor f => SF (:+:) f ~> (f :+: (f :+: SF (:+:) f)) Source #consSF :: (f :+: SF (:+:) f) ~> SF (:+:) f Source #toSF :: (f :+: f) ~> SF (:+:) f Source #biretract :: CS (:+:) f => (f :+: f) ~> f Source #binterpret :: CS (:+:) h => (f ~> h) -> (g ~> h) -> (f :+: g) ~> h Source # Semigroupoidal ((:*:) :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Associative Associated Typestype SF (:*:) :: (Type -> Type) -> Type -> Type Source # MethodsmatchSF :: Functor f => SF (:*:) f ~> (f :+: (f :*: SF (:*:) f)) Source #consSF :: (f :*: SF (:*:) f) ~> SF (:*:) f Source #toSF :: (f :*: f) ~> SF (:*:) f Source #biretract :: CS (:*:) f => (f :*: f) ~> f Source #binterpret :: CS (:*:) h => (f ~> h) -> (g ~> h) -> (f :*: g) ~> h Source # Semigroupoidal (Product :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Associative Associated Typestype SF Product :: (Type -> Type) -> Type -> Type Source # MethodsmatchSF :: Functor f => SF Product f ~> (f :+: Product f (SF Product f)) Source #biretract :: CS Product f => Product f f ~> f Source #binterpret :: CS Product h => (f ~> h) -> (g ~> h) -> Product f g ~> h Source # Semigroupoidal (Sum :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Associative Associated Typestype SF Sum :: (Type -> Type) -> Type -> Type Source # MethodsappendSF :: Sum (SF Sum f) (SF Sum f) ~> SF Sum f Source #matchSF :: Functor f => SF Sum f ~> (f :+: Sum f (SF Sum f)) Source #consSF :: Sum f (SF Sum f) ~> SF Sum f Source #toSF :: Sum f f ~> SF Sum f Source #biretract :: CS Sum f => Sum f f ~> f Source #binterpret :: CS Sum h => (f ~> h) -> (g ~> h) -> Sum f g ~> h Source # Semigroupoidal (Joker :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Associative Associated Typestype SF Joker :: (Type -> Type) -> Type -> Type Source # MethodsmatchSF :: Functor f => SF Joker f ~> (f :+: Joker f (SF Joker f)) Source #biretract :: CS Joker f => Joker f f ~> f Source #binterpret :: CS Joker h => (f ~> h) -> (g ~> h) -> Joker f g ~> h Source # Semigroupoidal (LeftF :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Associative Associated Typestype SF LeftF :: (Type -> Type) -> Type -> Type Source # MethodsmatchSF :: Functor f => SF LeftF f ~> (f :+: LeftF f (SF LeftF f)) Source #biretract :: CS LeftF f => LeftF f f ~> f Source #binterpret :: CS LeftF h => (f ~> h) -> (g ~> h) -> LeftF f g ~> h Source # Semigroupoidal (RightF :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Associative Associated Typestype SF RightF :: (Type -> Type) -> Type -> Type Source # MethodsmatchSF :: Functor f => SF RightF f ~> (f :+: RightF f (SF RightF f)) Source #biretract :: CS RightF f => RightF f f ~> f Source #binterpret :: CS RightF h => (f ~> h) -> (g ~> h) -> RightF f g ~> h Source #

type CS t = C (SF t) Source #

Convenient alias for the constraint required for biretract, binterpret, etc.

It's usually a constraint on the target/result context of interpretation that allows you to "exit" or "run" a Semigroupoidal t.

biget :: (Semigroupoidal t, CS t (Const b)) => (forall x. f x -> b) -> (forall x. g x -> b) -> t f g a -> b Source #

Useful wrapper over binterpret to allow you to directly extract a value b out of the t f a, if you can convert f x into b.

Note that depending on the constraints on the interpretation of t, you may have extra constraints on b.

• If C (SF t) is Unconstrained, there are no constraints on b
• If C (SF t) is Apply, b needs to be an instance of Semigroup
• If C (SF t) is Applicative, b needs to be an instance of Monoid

For some constraints (like Monad), this will not be usable.

-- Return the length of either the list, or the Map, depending on which
--   one s in the +
biget length length
:: ([] :+: Map Int) Char
-> Int

-- Return the length of both the list and the map, added together
biget (Sum . length) (Sum . length)
:: Day [] (Map Int) Char
-> Sum Int


bicollect :: (Semigroupoidal t, CS t (Const [b])) => (forall x. f x -> b) -> (forall x. g x -> b) -> t f g a -> [b] Source #

Useful wrapper over biget to allow you to collect a b from all instances of f and g inside a t f g a.

This will work if C t is Unconstrained, Apply, or Applicative.

(!*!) :: (Semigroupoidal t, CS t h) => (f ~> h) -> (g ~> h) -> t f g ~> h infixr 5 Source #

Infix alias for binterpret

(!$!) :: (Semigroupoidal t, CS t (Const b)) => (forall x. f x -> b) -> (forall x. g x -> b) -> t f g a -> b infixr 5 Source # Infix alias for biget -- Return the length of either the list, or the Map, depending on which -- one s in the + length !$! length
:: ([] :+: Map Int) Char
-> Int

-- Return the length of both the list and the map, added together
Sum . length !$! Sum . length :: Day [] (Map Int) Char -> Sum Int  ### Tensor class Associative t => Tensor t where Source # An Associative HBifunctor can be a Tensor if there is some identity i where t i f is equivalent to just f. That is, "enhancing" f with t i does nothing. The methods in this class provide us useful ways of navigating a Tensor t with respect to this property. The Tensor is essentially the HBifunctor equivalent of Inject, with intro1 and intro2 taking the place of inject. Associated Types type I t :: Type -> Type Source # The identity of Tensor t. If you "combine" f with the identity, it leaves f unchanged. For example, the identity of :*: is Proxy. This is because (Proxy :*: f) a  is equivalent to just f a  :*:-ing f with Proxy gives you no additional structure. Another example: (V1 :+: f) a  is equivalent to just f a  because the L1 case is unconstructable. Methods intro1 :: f ~> t f (I t) Source # Because t f (I t) is equivalent to f, we can always "insert" f into t f (I t). This is analogous to inject from Inject, but for HBifunctors. intro2 :: g ~> t (I t) g Source # Because t (I t) g is equivalent to f, we can always "insert" g into t (I t) g. This is analogous to inject from Inject, but for HBifunctors. elim1 :: Functor f => t f (I t) ~> f Source # Witnesses the property that I t is the identity of t: t f (I t) always leaves f unchanged, so we can always just drop the I t. elim2 :: Functor g => t (I t) g ~> g Source # Witnesses the property that I t is the identity of t: t (I t) g always leaves g unchanged, so we can always just drop the I t. Instances  Source # Instance detailsDefined in Data.HBifunctor.Tensor Associated Typestype I Day :: Type -> Type Source # Methodsintro1 :: f ~> Day f (I Day) Source #intro2 :: g ~> Day (I Day) g Source #elim1 :: Functor f => Day f (I Day) ~> f Source #elim2 :: Functor g => Day (I Day) g ~> g Source # Source # Instance detailsDefined in Data.HBifunctor.Tensor Associated Typestype I These1 :: Type -> Type Source # Methodsintro1 :: f ~> These1 f (I These1) Source #intro2 :: g ~> These1 (I These1) g Source #elim1 :: Functor f => These1 f (I These1) ~> f Source #elim2 :: Functor g => These1 (I These1) g ~> g Source # Source # Instance detailsDefined in Data.HBifunctor.Tensor Associated Typestype I Comp :: Type -> Type Source # Methodsintro1 :: f ~> Comp f (I Comp) Source #intro2 :: g ~> Comp (I Comp) g Source #elim1 :: Functor f => Comp f (I Comp) ~> f Source #elim2 :: Functor g => Comp (I Comp) g ~> g Source # Tensor ((:+:) :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Tensor Associated Typestype I (:+:) :: Type -> Type Source # Methodsintro1 :: f ~> (f :+: I (:+:)) Source #intro2 :: g ~> (I (:+:) :+: g) Source #elim1 :: Functor f => (f :+: I (:+:)) ~> f Source #elim2 :: Functor g => (I (:+:) :+: g) ~> g Source # Tensor ((:*:) :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Tensor Associated Typestype I (:*:) :: Type -> Type Source # Methodsintro1 :: f ~> (f :*: I (:*:)) Source #intro2 :: g ~> (I (:*:) :*: g) Source #elim1 :: Functor f => (f :*: I (:*:)) ~> f Source #elim2 :: Functor g => (I (:*:) :*: g) ~> g Source # Tensor (Product :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Tensor Associated Typestype I Product :: Type -> Type Source # Methodsintro1 :: f ~> Product f (I Product) Source #intro2 :: g ~> Product (I Product) g Source #elim1 :: Functor f => Product f (I Product) ~> f Source #elim2 :: Functor g => Product (I Product) g ~> g Source # Tensor (Sum :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Tensor Associated Typestype I Sum :: Type -> Type Source # Methodsintro1 :: f ~> Sum f (I Sum) Source #intro2 :: g ~> Sum (I Sum) g Source #elim1 :: Functor f => Sum f (I Sum) ~> f Source #elim2 :: Functor g => Sum (I Sum) g ~> g Source # class (Tensor t, Semigroupoidal t, Interpret (MF t)) => Monoidal t where Source # A Monoidal t is a Semigroupoidal, in that it provides some type MF t f that is equivalent to one of: • I a -- 0 times • f a -- 1 time • t f f a -- 2 times • t f (t f f) a -- 3 times • t f (t f (t f f)) a -- 4 times • t f (t f (t f (t f f))) a -- 5 times • .. etc The difference is that unlike SF t, MF t has the "zero times" value. This typeclass lets you use a type like ListF in terms of repeated applications of :*:, or Ap in terms of repeated applications of Day, or Free in terms of repeated applications of Comp, etc. For example, f :*: f can be interpreted as "a free selection of two fs", allowing you to specify "I have to fs that I can use". If you want to specify "I want 0, 1, or many different fs that I can use", you can use ListF f. At the high level, the thing that Monoidal adds to Semigroupoidal is inL, inR, and nilMF: inL :: f a -> t f g a inR :: g a -> t f g a nilMF :: I a -> MF t f a  which are like the HBifunctor versions of inject: it lets you inject an f into t f g, so you can start doing useful mixing operations with it. nilMF lets you construct an "empty" MF t. Also useful is: toMF :: t f f a -> MF t f a  Which converts a t into its aggregate type MF Minimal complete definition Associated Types type MF t :: (Type -> Type) -> Type -> Type Source # The "monoidal functor combinator" induced by t. A value of type MF t f a is equivalent to one of: • I a -- zero fs • f a -- one f • t f f a -- two fs • t f (t f f) a -- three fs • t f (t f (t f f)) a • t f (t f (t f (t f f))) a • .. etc For example, for :*:, we have ListF. This is because: Proxy ~ ListF [] ~ nilMF @(:*:) x ~ ListF [x] ~ inject x x :*: y ~ ListF [x,y] ~ toMF (x :*: y) x :*: y :*: z ~ ListF [x,y,z] -- etc.  You can create an "empty" one with nilMF, a "singleton" one with inject, or else one from a single t f f with toMF. Methods appendMF :: t (MF t f) (MF t f) ~> MF t f Source # If a MF t f represents multiple applications of t f to itself, then we can also "append" two MF t fs applied to themselves into one giant MF t f containing all of the t fs. splitSF :: SF t f ~> t f (MF t f) Source # Lets you convert an SF t f into a single application of f to MF t f. Analogous to a function NonEmpty a -> (a, [a]) Note that this is not reversible in general unless we have Matchable t. toMF :: t f f ~> MF t f Source # Embed a direct application of f to itself into a MF t f. fromSF :: SF t f ~> MF t f Source # SF t f is "one or more fs", and 'MF t f is "zero or more fs". This function lets us convert from one to the other. This is analogous to a function NonEmpty a -> [a]. Note that because t is not inferrable from the input or output type, you should call this using -XTypeApplications: fromSF @(:*:) :: NonEmptyF f a -> ListF f a fromSF @Comp :: Free1 f a -> Free f a  pureT :: CM t f => I t ~> f Source # If we have an I t, we can generate an f based on how it interacts with t. Specialized (and simplified), this type is: pureT @Day :: Applicative f => Identity a -> f a -- pure pureT @Comp :: Monad f => Identity a -> f a -- return pureT @(:*:) :: Plus f => Proxy a -> f a -- zero  Note that because t appears nowhere in the input or output types, you must always use this with explicit type application syntax (like pureT @Day) upgradeC :: CM t f => proxy f -> (CS t f => r) -> r Source # If we have a constraint on the Monoidal satisfied, it should also imply the constraint on the Semigroupoidal. This is basically saying that C (SF t) should be a superclass of C (MF t). For example, for :*:, this type signature says that Alt is a superclass of Plus, so whenever you have Plus, you should always also have Alt. For Day, this type signature says that Apply is a superclass of Applicative, so whenever you have Applicative, you should always also have Apply. This is necessary because in the current class hierarchy, Apply isn't a true superclass of Applicative. upgradeC basically "imbues" f with an Apply instance based on its Applicative instance, so things can be easier to use. For example, let's say I have a type Parser that is an Applicative instance, but the source library does not define an Apply instance. I cannot use biretract or binterpret with it, even though I should be able to, because they require Apply. That is: biretract :: Day Parser Parser a -> Parser a  is a type error, because it requires Apply Parser. But, if we know that Parser has an Applicative instance, we can use: upgradeC @Day (Proxy @Parser) biretract :: Day Parser Parser a -> a  and this will now typecheck properly. Ideally, Parser would also have an Apply instance. But we cannot control this if an external library defines Parser. (Alternatively you can just use biretractT.) Note that you should only use this if f doesn't already have the SF constraint. If it does, this could lead to conflicting instances. Only use this with specific, concrete fs. Otherwise this is unsafe and can possibly break coherence guarantees. The proxy argument can be provided using something like Proxy @f, to specify which f you want to upgrade. Instances  Source # Instance detailsDefined in Data.HBifunctor.Tensor Associated Typestype MF Day :: (Type -> Type) -> Type -> Type Source # MethodsappendMF :: Day (MF Day f) (MF Day f) ~> MF Day f Source #splitSF :: SF Day f ~> Day f (MF Day f) Source #toMF :: Day f f ~> MF Day f Source #pureT :: CM Day f => I Day ~> f Source #upgradeC :: CM Day f => proxy f -> (CS Day f -> r) -> r Source # Source # Instance detailsDefined in Data.HBifunctor.Tensor Associated Typestype MF These1 :: (Type -> Type) -> Type -> Type Source # MethodsupgradeC :: CM These1 f => proxy f -> (CS These1 f -> r) -> r Source # Source # Instance detailsDefined in Data.HBifunctor.Tensor Associated Typestype MF Comp :: (Type -> Type) -> Type -> Type Source # MethodsappendMF :: Comp (MF Comp f) (MF Comp f) ~> MF Comp f Source #splitSF :: SF Comp f ~> Comp f (MF Comp f) Source #toMF :: Comp f f ~> MF Comp f Source #pureT :: CM Comp f => I Comp ~> f Source #upgradeC :: CM Comp f => proxy f -> (CS Comp f -> r) -> r Source # Monoidal ((:+:) :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Tensor Associated Typestype MF (:+:) :: (Type -> Type) -> Type -> Type Source # MethodstoMF :: (f :+: f) ~> MF (:+:) f Source #pureT :: CM (:+:) f => I (:+:) ~> f Source #upgradeC :: CM (:+:) f => proxy f -> (CS (:+:) f -> r) -> r Source # Monoidal ((:*:) :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Tensor Associated Typestype MF (:*:) :: (Type -> Type) -> Type -> Type Source # MethodstoMF :: (f :*: f) ~> MF (:*:) f Source #pureT :: CM (:*:) f => I (:*:) ~> f Source #upgradeC :: CM (:*:) f => proxy f -> (CS (:*:) f -> r) -> r Source # Monoidal (Product :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Tensor Associated Typestype MF Product :: (Type -> Type) -> Type -> Type Source # MethodsupgradeC :: CM Product f => proxy f -> (CS Product f -> r) -> r Source # Monoidal (Sum :: (Type -> Type) -> (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HBifunctor.Tensor Associated Typestype MF Sum :: (Type -> Type) -> Type -> Type Source # MethodsappendMF :: Sum (MF Sum f) (MF Sum f) ~> MF Sum f Source #splitSF :: SF Sum f ~> Sum f (MF Sum f) Source #toMF :: Sum f f ~> MF Sum f Source #pureT :: CM Sum f => I Sum ~> f Source #upgradeC :: CM Sum f => proxy f -> (CS Sum f -> r) -> r Source # type CM t = C (MF t) Source # Convenient alias for the constraint required for inL, inR, pureT, etc. It's usually a constraint on the target/result context of interpretation that allows you to "exit" or "run" a Monoidal t. nilMF :: forall t f. Monoidal t => I t ~> MF t f Source # Create the "empty MF@. If MF t f represents multiple applications of t f with itself, then nilMF gives us "zero applications of f". Note that t cannot be inferred from the input or output type of nilMF, so this function must always be called with -XTypeApplications: nilMF @Day :: Identity ~> Ap f nilMF @Comp :: Identity ~> Free f nilMF @(:*:) :: Proxy ~> ListF f  consMF :: Monoidal t => t f (MF t f) ~> MF t f Source # Lets us "cons" an application of f to the front of an MF t f. inL :: forall t f g. (Monoidal t, CM t g) => f ~> t f g Source # Convenient wrapper over intro1 that lets us introduce an arbitrary functor g to the right of an f. You can think of this as an HBifunctor analogue of inject. inR :: forall t f g. (Monoidal t, CM t f) => g ~> t f g Source # Convenient wrapper over intro2 that lets us introduce an arbitrary functor f to the right of a g. You can think of this as an HBifunctor analogue of inject. outL :: (Tensor t, I t ~ Proxy, Functor f) => t f g ~> f Source # Convenient wrapper over elim1 that lets us drop one of the arguments of a Tensor for free, without requiring any extra constraints (like for binterpret). See prodOutL for a version that does not require Functor f, specifically for :*:. outR :: (Tensor t, I t ~ Proxy, Functor g) => t f g ~> g Source # Convenient wrapper over elim2 that lets us drop one of the arguments of a Tensor for free, without requiring any constraints (like for binterpret). See prodOutR for a version that does not require Functor g, specifically for :*:. # Combinators Functor combinators ** Single data Coyoneda (f :: Type -> Type) a where # A covariant Functor suitable for Yoneda reduction Constructors  Coyoneda :: forall (f :: Type -> Type) a b. (b -> a) -> f b -> Coyoneda f a Instances  Instance detailsDefined in Data.Functor.Coyoneda Methodslower :: Comonad w => Coyoneda w a -> w a # Instance detailsDefined in Data.Functor.Coyoneda Methodslift :: Monad m => m a -> Coyoneda m a # Source # A free Functor Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C Coyoneda :: (Type -> Type) -> Constraint Source # Methodsinterpret :: C Coyoneda g => (f ~> g) -> Coyoneda f ~> g Source # Source # Instance detailsDefined in Data.HFunctor.Final Methods Monad m => Monad (Coyoneda m) Instance detailsDefined in Data.Functor.Coyoneda Methods(>>=) :: Coyoneda m a -> (a -> Coyoneda m b) -> Coyoneda m b #(>>) :: Coyoneda m a -> Coyoneda m b -> Coyoneda m b #return :: a -> Coyoneda m a #fail :: String -> Coyoneda m a # Instance detailsDefined in Data.Functor.Coyoneda Methodsfmap :: (a -> b) -> Coyoneda f a -> Coyoneda f b #(<$) :: a -> Coyoneda f b -> Coyoneda f a # MonadFix f => MonadFix (Coyoneda f) Instance detailsDefined in Data.Functor.Coyoneda Methodsmfix :: (a -> Coyoneda f a) -> Coyoneda f a # Instance detailsDefined in Data.Functor.Coyoneda Methodspure :: a -> Coyoneda f a #(<*>) :: Coyoneda f (a -> b) -> Coyoneda f a -> Coyoneda f b #liftA2 :: (a -> b -> c) -> Coyoneda f a -> Coyoneda f b -> Coyoneda f c #(*>) :: Coyoneda f a -> Coyoneda f b -> Coyoneda f b #(<*) :: Coyoneda f a -> Coyoneda f b -> Coyoneda f a # Foldable f => Foldable (Coyoneda f) Instance detailsDefined in Data.Functor.Coyoneda Methodsfold :: Monoid m => Coyoneda f m -> m #foldMap :: Monoid m => (a -> m) -> Coyoneda f a -> m #foldr :: (a -> b -> b) -> b -> Coyoneda f a -> b #foldr' :: (a -> b -> b) -> b -> Coyoneda f a -> b #foldl :: (b -> a -> b) -> b -> Coyoneda f a -> b #foldl' :: (b -> a -> b) -> b -> Coyoneda f a -> b #foldr1 :: (a -> a -> a) -> Coyoneda f a -> a #foldl1 :: (a -> a -> a) -> Coyoneda f a -> a #toList :: Coyoneda f a -> [a] #null :: Coyoneda f a -> Bool #length :: Coyoneda f a -> Int #elem :: Eq a => a -> Coyoneda f a -> Bool #maximum :: Ord a => Coyoneda f a -> a #minimum :: Ord a => Coyoneda f a -> a #sum :: Num a => Coyoneda f a -> a #product :: Num a => Coyoneda f a -> a # Instance detailsDefined in Data.Functor.Coyoneda Methodstraverse :: Applicative f0 => (a -> f0 b) -> Coyoneda f a -> f0 (Coyoneda f b) #sequenceA :: Applicative f0 => Coyoneda f (f0 a) -> f0 (Coyoneda f a) #mapM :: Monad m => (a -> m b) -> Coyoneda f a -> m (Coyoneda f b) #sequence :: Monad m => Coyoneda f (m a) -> m (Coyoneda f a) # Instance detailsDefined in Data.Functor.Coyoneda Methodsdistribute :: Functor f0 => f0 (Coyoneda f a) -> Coyoneda f (f0 a) #collect :: Functor f0 => (a -> Coyoneda f b) -> f0 a -> Coyoneda f (f0 b) #distributeM :: Monad m => m (Coyoneda f a) -> Coyoneda f (m a) #collectM :: Monad m => (a -> Coyoneda f b) -> m a -> Coyoneda f (m b) # Instance detailsDefined in Data.Functor.Coyoneda Associated Typestype Rep (Coyoneda f) :: Type # Methodstabulate :: (Rep (Coyoneda f) -> a) -> Coyoneda f a #index :: Coyoneda f a -> Rep (Coyoneda f) -> a # Instance detailsDefined in Data.Functor.Coyoneda Methodsempty :: Coyoneda f a #(<|>) :: Coyoneda f a -> Coyoneda f a -> Coyoneda f a #some :: Coyoneda f a -> Coyoneda f [a] #many :: Coyoneda f a -> Coyoneda f [a] # MonadPlus f => MonadPlus (Coyoneda f) Instance detailsDefined in Data.Functor.Coyoneda Methodsmzero :: Coyoneda f a #mplus :: Coyoneda f a -> Coyoneda f a -> Coyoneda f a # Eq1 f => Eq1 (Coyoneda f) Instance detailsDefined in Data.Functor.Coyoneda MethodsliftEq :: (a -> b -> Bool) -> Coyoneda f a -> Coyoneda f b -> Bool # Ord1 f => Ord1 (Coyoneda f) Instance detailsDefined in Data.Functor.Coyoneda MethodsliftCompare :: (a -> b -> Ordering) -> Coyoneda f a -> Coyoneda f b -> Ordering # Read1 f => Read1 (Coyoneda f) Instance detailsDefined in Data.Functor.Coyoneda MethodsliftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Coyoneda f a) #liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Coyoneda f a] #liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (Coyoneda f a) #liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [Coyoneda f a] # (Functor f, Show1 f) => Show1 (Coyoneda f) Instance detailsDefined in Data.Functor.Coyoneda MethodsliftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Coyoneda f a -> ShowS #liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Coyoneda f a] -> ShowS # Comonad w => Comonad (Coyoneda w) Instance detailsDefined in Data.Functor.Coyoneda Methodsextract :: Coyoneda w a -> a #duplicate :: Coyoneda w a -> Coyoneda w (Coyoneda w a) #extend :: (Coyoneda w a -> b) -> Coyoneda w a -> Coyoneda w b # Foldable1 f => Foldable1 (Coyoneda f) Instance detailsDefined in Data.Functor.Coyoneda Methodsfold1 :: Semigroup m => Coyoneda f m -> m #foldMap1 :: Semigroup m => (a -> m) -> Coyoneda f a -> m #toNonEmpty :: Coyoneda f a -> NonEmpty a # Apply f => Apply (Coyoneda f) Instance detailsDefined in Data.Functor.Coyoneda Methods(<.>) :: Coyoneda f (a -> b) -> Coyoneda f a -> Coyoneda f b #(.>) :: Coyoneda f a -> Coyoneda f b -> Coyoneda f b #(<.) :: Coyoneda f a -> Coyoneda f b -> Coyoneda f a #liftF2 :: (a -> b -> c) -> Coyoneda f a -> Coyoneda f b -> Coyoneda f c # Instance detailsDefined in Data.Functor.Coyoneda Methodstraverse1 :: Apply f0 => (a -> f0 b) -> Coyoneda f a -> f0 (Coyoneda f b) #sequence1 :: Apply f0 => Coyoneda f (f0 b) -> f0 (Coyoneda f b) # Plus f => Plus (Coyoneda f) Instance detailsDefined in Data.Functor.Coyoneda Methodszero :: Coyoneda f a # Alt f => Alt (Coyoneda f) Instance detailsDefined in Data.Functor.Coyoneda Methods() :: Coyoneda f a -> Coyoneda f a -> Coyoneda f a #some :: Applicative (Coyoneda f) => Coyoneda f a -> Coyoneda f [a] #many :: Applicative (Coyoneda f) => Coyoneda f a -> Coyoneda f [a] # Bind m => Bind (Coyoneda m) Instance detailsDefined in Data.Functor.Coyoneda Methods(>>-) :: Coyoneda m a -> (a -> Coyoneda m b) -> Coyoneda m b #join :: Coyoneda m (Coyoneda m a) -> Coyoneda m a # Extend w => Extend (Coyoneda w) Instance detailsDefined in Data.Functor.Coyoneda Methodsduplicated :: Coyoneda w a -> Coyoneda w (Coyoneda w a) #extended :: (Coyoneda w a -> b) -> Coyoneda w a -> Coyoneda w b # Source # Instance detailsDefined in Data.HFunctor Methodshbind :: (f ~> Coyoneda g) -> Coyoneda f ~> Coyoneda g Source # Source # Instance detailsDefined in Data.HFunctor Methods Adjunction f g => Adjunction (Coyoneda f) (Coyoneda g) Instance detailsDefined in Data.Functor.Coyoneda Methodsunit :: a -> Coyoneda g (Coyoneda f a) #counit :: Coyoneda f (Coyoneda g a) -> a #leftAdjunct :: (Coyoneda f a -> b) -> a -> Coyoneda g b #rightAdjunct :: (a -> Coyoneda g b) -> Coyoneda f a -> b # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Coyoneda f ~> Coyoneda g Source # (Functor f, Eq1 f, Eq a) => Eq (Coyoneda f a) Instance detailsDefined in Data.Functor.Coyoneda Methods(==) :: Coyoneda f a -> Coyoneda f a -> Bool #(/=) :: Coyoneda f a -> Coyoneda f a -> Bool # (Functor f, Ord1 f, Ord a) => Ord (Coyoneda f a) Instance detailsDefined in Data.Functor.Coyoneda Methodscompare :: Coyoneda f a -> Coyoneda f a -> Ordering #(<) :: Coyoneda f a -> Coyoneda f a -> Bool #(<=) :: Coyoneda f a -> Coyoneda f a -> Bool #(>) :: Coyoneda f a -> Coyoneda f a -> Bool #(>=) :: Coyoneda f a -> Coyoneda f a -> Bool #max :: Coyoneda f a -> Coyoneda f a -> Coyoneda f a #min :: Coyoneda f a -> Coyoneda f a -> Coyoneda f a # Read (f a) => Read (Coyoneda f a) Instance detailsDefined in Data.Functor.Coyoneda MethodsreadsPrec :: Int -> ReadS (Coyoneda f a) #readList :: ReadS [Coyoneda f a] #readPrec :: ReadPrec (Coyoneda f a) # (Functor f, Show1 f, Show a) => Show (Coyoneda f a) Instance detailsDefined in Data.Functor.Coyoneda MethodsshowsPrec :: Int -> Coyoneda f a -> ShowS #show :: Coyoneda f a -> String #showList :: [Coyoneda f a] -> ShowS # type C Coyoneda Source # Instance detailsDefined in Data.HFunctor.Interpret type C Coyoneda = Functor type Rep (Coyoneda f) Instance detailsDefined in Data.Functor.Coyoneda type Rep (Coyoneda f) = Rep f

newtype ListF f a Source #

A list of f as. Can be used to describe a product of many different values of type f a.

This is the Free Plus.

Constructors

 ListF FieldsrunListF :: [f a]
Instances
 Source # A free Plus Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C ListF :: (Type -> Type) -> Constraint Source # Methodsretract :: C ListF f => ListF f ~> f Source #interpret :: C ListF g => (f ~> g) -> ListF f ~> g Source # Source # Instance detailsDefined in Data.HFunctor.Final Methods Functor f => Functor (ListF f) Source # Instance detailsDefined in Control.Applicative.ListF Methodsfmap :: (a -> b) -> ListF f a -> ListF f b #(<$) :: a -> ListF f b -> ListF f a # Applicative f => Applicative (ListF f) Source # Instance detailsDefined in Control.Applicative.ListF Methodspure :: a -> ListF f a #(<*>) :: ListF f (a -> b) -> ListF f a -> ListF f b #liftA2 :: (a -> b -> c) -> ListF f a -> ListF f b -> ListF f c #(*>) :: ListF f a -> ListF f b -> ListF f b #(<*) :: ListF f a -> ListF f b -> ListF f a # Foldable f => Foldable (ListF f) Source # Instance detailsDefined in Control.Applicative.ListF Methodsfold :: Monoid m => ListF f m -> m #foldMap :: Monoid m => (a -> m) -> ListF f a -> m #foldr :: (a -> b -> b) -> b -> ListF f a -> b #foldr' :: (a -> b -> b) -> b -> ListF f a -> b #foldl :: (b -> a -> b) -> b -> ListF f a -> b #foldl' :: (b -> a -> b) -> b -> ListF f a -> b #foldr1 :: (a -> a -> a) -> ListF f a -> a #foldl1 :: (a -> a -> a) -> ListF f a -> a #toList :: ListF f a -> [a] #null :: ListF f a -> Bool #length :: ListF f a -> Int #elem :: Eq a => a -> ListF f a -> Bool #maximum :: Ord a => ListF f a -> a #minimum :: Ord a => ListF f a -> a #sum :: Num a => ListF f a -> a #product :: Num a => ListF f a -> a # Traversable f => Traversable (ListF f) Source # Instance detailsDefined in Control.Applicative.ListF Methodstraverse :: Applicative f0 => (a -> f0 b) -> ListF f a -> f0 (ListF f b) #sequenceA :: Applicative f0 => ListF f (f0 a) -> f0 (ListF f a) #mapM :: Monad m => (a -> m b) -> ListF f a -> m (ListF f b) #sequence :: Monad m => ListF f (m a) -> m (ListF f a) # Applicative f => Alternative (ListF f) Source # Instance detailsDefined in Control.Applicative.ListF Methodsempty :: ListF f a #(<|>) :: ListF f a -> ListF f a -> ListF f a #some :: ListF f a -> ListF f [a] #many :: ListF f a -> ListF f [a] # Eq1 f => Eq1 (ListF f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftEq :: (a -> b -> Bool) -> ListF f a -> ListF f b -> Bool # Ord1 f => Ord1 (ListF f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftCompare :: (a -> b -> Ordering) -> ListF f a -> ListF f b -> Ordering # Read1 f => Read1 (ListF f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (ListF f a) #liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [ListF f a] #liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (ListF f a) #liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [ListF f a] # Show1 f => Show1 (ListF f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> ListF f a -> ShowS #liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [ListF f a] -> ShowS # Apply f => Apply (ListF f) Source # Instance detailsDefined in Control.Applicative.ListF Methods(<.>) :: ListF f (a -> b) -> ListF f a -> ListF f b #(.>) :: ListF f a -> ListF f b -> ListF f b #(<.) :: ListF f a -> ListF f b -> ListF f a #liftF2 :: (a -> b -> c) -> ListF f a -> ListF f b -> ListF f c # Pointed f => Pointed (ListF f) Source # Instance detailsDefined in Control.Applicative.ListF Methodspoint :: a -> ListF f a # Functor f => Plus (ListF f) Source # Instance detailsDefined in Control.Applicative.ListF Methodszero :: ListF f a # Functor f => Alt (ListF f) Source # Instance detailsDefined in Control.Applicative.ListF Methods() :: ListF f a -> ListF f a -> ListF f a #some :: Applicative (ListF f) => ListF f a -> ListF f [a] #many :: Applicative (ListF f) => ListF f a -> ListF f [a] # Source # Instance detailsDefined in Data.HFunctor Methodshbind :: (f ~> ListF g) -> ListF f ~> ListF g Source # Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> ListF f Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> ListF f ~> ListF g Source # Eq (f a) => Eq (ListF f a) Source # Instance detailsDefined in Control.Applicative.ListF Methods(==) :: ListF f a -> ListF f a -> Bool #(/=) :: ListF f a -> ListF f a -> Bool # (Typeable f, Typeable a, Data (f a)) => Data (ListF f a) Source # Instance detailsDefined in Control.Applicative.ListF Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ListF f a -> c (ListF f a) #gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ListF f a) #toConstr :: ListF f a -> Constr #dataTypeOf :: ListF f a -> DataType #dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (ListF f a)) #dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ListF f a)) #gmapT :: (forall b. Data b => b -> b) -> ListF f a -> ListF f a #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ListF f a -> r #gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ListF f a -> r #gmapQ :: (forall d. Data d => d -> u) -> ListF f a -> [u] #gmapQi :: Int -> (forall d. Data d => d -> u) -> ListF f a -> u #gmapM :: Monad m => (forall d. Data d => d -> m d) -> ListF f a -> m (ListF f a) #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ListF f a -> m (ListF f a) #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ListF f a -> m (ListF f a) # Ord (f a) => Ord (ListF f a) Source # Instance detailsDefined in Control.Applicative.ListF Methodscompare :: ListF f a -> ListF f a -> Ordering #(<) :: ListF f a -> ListF f a -> Bool #(<=) :: ListF f a -> ListF f a -> Bool #(>) :: ListF f a -> ListF f a -> Bool #(>=) :: ListF f a -> ListF f a -> Bool #max :: ListF f a -> ListF f a -> ListF f a #min :: ListF f a -> ListF f a -> ListF f a # Read (f a) => Read (ListF f a) Source # Instance detailsDefined in Control.Applicative.ListF MethodsreadsPrec :: Int -> ReadS (ListF f a) #readList :: ReadS [ListF f a] #readPrec :: ReadPrec (ListF f a) #readListPrec :: ReadPrec [ListF f a] # Show (f a) => Show (ListF f a) Source # Instance detailsDefined in Control.Applicative.ListF MethodsshowsPrec :: Int -> ListF f a -> ShowS #show :: ListF f a -> String #showList :: [ListF f a] -> ShowS # Generic (ListF f a) Source # Instance detailsDefined in Control.Applicative.ListF Associated Typestype Rep (ListF f a) :: Type -> Type # Methodsfrom :: ListF f a -> Rep (ListF f a) x #to :: Rep (ListF f a) x -> ListF f a # Semigroup (ListF f a) Source # Instance detailsDefined in Control.Applicative.ListF Methods(<>) :: ListF f a -> ListF f a -> ListF f a #sconcat :: NonEmpty (ListF f a) -> ListF f a #stimes :: Integral b => b -> ListF f a -> ListF f a # Monoid (ListF f a) Source # Instance detailsDefined in Control.Applicative.ListF Methodsmempty :: ListF f a #mappend :: ListF f a -> ListF f a -> ListF f a #mconcat :: [ListF f a] -> ListF f a # type C ListF Source # Instance detailsDefined in Data.HFunctor.Interpret type C ListF = Plus type Rep (ListF f a) Source # Instance detailsDefined in Control.Applicative.ListF type Rep (ListF f a) = D1 (MetaData "ListF" "Control.Applicative.ListF" "functor-combinators-0.1.1.1-B2oyFu2GVTM8ySAuzVPoNk" True) (C1 (MetaCons "ListF" PrefixI True) (S1 (MetaSel (Just "runListF") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [f a]))) newtype NonEmptyF f a Source # A non-empty list of f as. Can be used to describe a product between many different possible values of type f a. Essentially: NonEmptyF f ~ f -- one f :+: (f :*: f) -- two f's :+: (f :*: f :*: f) -- three f's :+: (f :*: f :*: f :*: f) -- four f's :+: ... -- etc.  This is the Free Plus. Constructors  NonEmptyF FieldsrunNonEmptyF :: NonEmpty (f a) Bundled Patterns  pattern ProdNonEmpty :: (f :*: ListF f) a -> NonEmptyF f a Treat a NonEmptyF f as a product between an f and a ListF f.nonEmptyProd is the record accessor. Instances  Source # A free Alt Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C NonEmptyF :: (Type -> Type) -> Constraint Source # Methodsinterpret :: C NonEmptyF g => (f ~> g) -> NonEmptyF f ~> g Source # Source # Instance detailsDefined in Data.HFunctor.Final Methods Functor f => Functor (NonEmptyF f) Source # Instance detailsDefined in Control.Applicative.ListF Methodsfmap :: (a -> b) -> NonEmptyF f a -> NonEmptyF f b #(<$) :: a -> NonEmptyF f b -> NonEmptyF f a # Source # Instance detailsDefined in Control.Applicative.ListF Methodspure :: a -> NonEmptyF f a #(<*>) :: NonEmptyF f (a -> b) -> NonEmptyF f a -> NonEmptyF f b #liftA2 :: (a -> b -> c) -> NonEmptyF f a -> NonEmptyF f b -> NonEmptyF f c #(*>) :: NonEmptyF f a -> NonEmptyF f b -> NonEmptyF f b #(<*) :: NonEmptyF f a -> NonEmptyF f b -> NonEmptyF f a # Foldable f => Foldable (NonEmptyF f) Source # Instance detailsDefined in Control.Applicative.ListF Methodsfold :: Monoid m => NonEmptyF f m -> m #foldMap :: Monoid m => (a -> m) -> NonEmptyF f a -> m #foldr :: (a -> b -> b) -> b -> NonEmptyF f a -> b #foldr' :: (a -> b -> b) -> b -> NonEmptyF f a -> b #foldl :: (b -> a -> b) -> b -> NonEmptyF f a -> b #foldl' :: (b -> a -> b) -> b -> NonEmptyF f a -> b #foldr1 :: (a -> a -> a) -> NonEmptyF f a -> a #foldl1 :: (a -> a -> a) -> NonEmptyF f a -> a #toList :: NonEmptyF f a -> [a] #null :: NonEmptyF f a -> Bool #length :: NonEmptyF f a -> Int #elem :: Eq a => a -> NonEmptyF f a -> Bool #maximum :: Ord a => NonEmptyF f a -> a #minimum :: Ord a => NonEmptyF f a -> a #sum :: Num a => NonEmptyF f a -> a #product :: Num a => NonEmptyF f a -> a # Source # Instance detailsDefined in Control.Applicative.ListF Methodstraverse :: Applicative f0 => (a -> f0 b) -> NonEmptyF f a -> f0 (NonEmptyF f b) #sequenceA :: Applicative f0 => NonEmptyF f (f0 a) -> f0 (NonEmptyF f a) #mapM :: Monad m => (a -> m b) -> NonEmptyF f a -> m (NonEmptyF f b) #sequence :: Monad m => NonEmptyF f (m a) -> m (NonEmptyF f a) # Eq1 f => Eq1 (NonEmptyF f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftEq :: (a -> b -> Bool) -> NonEmptyF f a -> NonEmptyF f b -> Bool # Ord1 f => Ord1 (NonEmptyF f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftCompare :: (a -> b -> Ordering) -> NonEmptyF f a -> NonEmptyF f b -> Ordering # Read1 f => Read1 (NonEmptyF f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (NonEmptyF f a) #liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [NonEmptyF f a] #liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (NonEmptyF f a) #liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [NonEmptyF f a] # Show1 f => Show1 (NonEmptyF f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> NonEmptyF f a -> ShowS #liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [NonEmptyF f a] -> ShowS # Pointed f => Pointed (NonEmptyF f) Source # Instance detailsDefined in Control.Applicative.ListF Methodspoint :: a -> NonEmptyF f a # Functor f => Alt (NonEmptyF f) Source # Instance detailsDefined in Control.Applicative.ListF Methods() :: NonEmptyF f a -> NonEmptyF f a -> NonEmptyF f a #some :: Applicative (NonEmptyF f) => NonEmptyF f a -> NonEmptyF f [a] #many :: Applicative (NonEmptyF f) => NonEmptyF f a -> NonEmptyF f [a] # Source # Instance detailsDefined in Data.HFunctor Methodshbind :: (f ~> NonEmptyF g) -> NonEmptyF f ~> NonEmptyF g Source # Source # Instance detailsDefined in Data.HFunctor Methods Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> NonEmptyF f ~> NonEmptyF g Source # Eq (f a) => Eq (NonEmptyF f a) Source # Instance detailsDefined in Control.Applicative.ListF Methods(==) :: NonEmptyF f a -> NonEmptyF f a -> Bool #(/=) :: NonEmptyF f a -> NonEmptyF f a -> Bool # (Typeable f, Typeable a, Data (f a)) => Data (NonEmptyF f a) Source # Instance detailsDefined in Control.Applicative.ListF Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NonEmptyF f a -> c (NonEmptyF f a) #gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (NonEmptyF f a) #toConstr :: NonEmptyF f a -> Constr #dataTypeOf :: NonEmptyF f a -> DataType #dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (NonEmptyF f a)) #dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (NonEmptyF f a)) #gmapT :: (forall b. Data b => b -> b) -> NonEmptyF f a -> NonEmptyF f a #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NonEmptyF f a -> r #gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NonEmptyF f a -> r #gmapQ :: (forall d. Data d => d -> u) -> NonEmptyF f a -> [u] #gmapQi :: Int -> (forall d. Data d => d -> u) -> NonEmptyF f a -> u #gmapM :: Monad m => (forall d. Data d => d -> m d) -> NonEmptyF f a -> m (NonEmptyF f a) #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NonEmptyF f a -> m (NonEmptyF f a) #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NonEmptyF f a -> m (NonEmptyF f a) # Ord (f a) => Ord (NonEmptyF f a) Source # Instance detailsDefined in Control.Applicative.ListF Methodscompare :: NonEmptyF f a -> NonEmptyF f a -> Ordering #(<) :: NonEmptyF f a -> NonEmptyF f a -> Bool #(<=) :: NonEmptyF f a -> NonEmptyF f a -> Bool #(>) :: NonEmptyF f a -> NonEmptyF f a -> Bool #(>=) :: NonEmptyF f a -> NonEmptyF f a -> Bool #max :: NonEmptyF f a -> NonEmptyF f a -> NonEmptyF f a #min :: NonEmptyF f a -> NonEmptyF f a -> NonEmptyF f a # Read (f a) => Read (NonEmptyF f a) Source # Instance detailsDefined in Control.Applicative.ListF MethodsreadsPrec :: Int -> ReadS (NonEmptyF f a) #readList :: ReadS [NonEmptyF f a] #readPrec :: ReadPrec (NonEmptyF f a) # Show (f a) => Show (NonEmptyF f a) Source # Instance detailsDefined in Control.Applicative.ListF MethodsshowsPrec :: Int -> NonEmptyF f a -> ShowS #show :: NonEmptyF f a -> String #showList :: [NonEmptyF f a] -> ShowS # Generic (NonEmptyF f a) Source # Instance detailsDefined in Control.Applicative.ListF Associated Typestype Rep (NonEmptyF f a) :: Type -> Type # Methodsfrom :: NonEmptyF f a -> Rep (NonEmptyF f a) x #to :: Rep (NonEmptyF f a) x -> NonEmptyF f a # Semigroup (NonEmptyF f a) Source # Instance detailsDefined in Control.Applicative.ListF Methods(<>) :: NonEmptyF f a -> NonEmptyF f a -> NonEmptyF f a #sconcat :: NonEmpty (NonEmptyF f a) -> NonEmptyF f a #stimes :: Integral b => b -> NonEmptyF f a -> NonEmptyF f a # type C NonEmptyF Source # Instance detailsDefined in Data.HFunctor.Interpret type C NonEmptyF = Alt type Rep (NonEmptyF f a) Source # Instance detailsDefined in Control.Applicative.ListF type Rep (NonEmptyF f a) = D1 (MetaData "NonEmptyF" "Control.Applicative.ListF" "functor-combinators-0.1.1.1-B2oyFu2GVTM8ySAuzVPoNk" True) (C1 (MetaCons "NonEmptyF" PrefixI True) (S1 (MetaSel (Just "runNonEmptyF") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (NonEmpty (f a)))))

newtype MaybeF f a Source #

A maybe f a.

Can be useful for describing a "an f a that may or may not be there".

This is the free structure for a "fail"-like typeclass that would only have zero :: f a.

Constructors

 MaybeF FieldsrunMaybeF :: Maybe (f a)
Instances
 Source # Technically, C is over-constrained: we only need zero :: f a, but we don't really have that typeclass in any standard hierarchies. We use Plus here instead, but we never use . This would only go wrong in situations where your type supports zero but not , like instances of MonadFail without MonadPlus. Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C MaybeF :: (Type -> Type) -> Constraint Source # Methodsretract :: C MaybeF f => MaybeF f ~> f Source #interpret :: C MaybeF g => (f ~> g) -> MaybeF f ~> g Source # Functor f => Functor (MaybeF f) Source # Instance detailsDefined in Control.Applicative.ListF Methodsfmap :: (a -> b) -> MaybeF f a -> MaybeF f b #(<$) :: a -> MaybeF f b -> MaybeF f a # Applicative f => Applicative (MaybeF f) Source # Instance detailsDefined in Control.Applicative.ListF Methodspure :: a -> MaybeF f a #(<*>) :: MaybeF f (a -> b) -> MaybeF f a -> MaybeF f b #liftA2 :: (a -> b -> c) -> MaybeF f a -> MaybeF f b -> MaybeF f c #(*>) :: MaybeF f a -> MaybeF f b -> MaybeF f b #(<*) :: MaybeF f a -> MaybeF f b -> MaybeF f a # Foldable f => Foldable (MaybeF f) Source # Instance detailsDefined in Control.Applicative.ListF Methodsfold :: Monoid m => MaybeF f m -> m #foldMap :: Monoid m => (a -> m) -> MaybeF f a -> m #foldr :: (a -> b -> b) -> b -> MaybeF f a -> b #foldr' :: (a -> b -> b) -> b -> MaybeF f a -> b #foldl :: (b -> a -> b) -> b -> MaybeF f a -> b #foldl' :: (b -> a -> b) -> b -> MaybeF f a -> b #foldr1 :: (a -> a -> a) -> MaybeF f a -> a #foldl1 :: (a -> a -> a) -> MaybeF f a -> a #toList :: MaybeF f a -> [a] #null :: MaybeF f a -> Bool #length :: MaybeF f a -> Int #elem :: Eq a => a -> MaybeF f a -> Bool #maximum :: Ord a => MaybeF f a -> a #minimum :: Ord a => MaybeF f a -> a #sum :: Num a => MaybeF f a -> a #product :: Num a => MaybeF f a -> a # Traversable f => Traversable (MaybeF f) Source # Instance detailsDefined in Control.Applicative.ListF Methodstraverse :: Applicative f0 => (a -> f0 b) -> MaybeF f a -> f0 (MaybeF f b) #sequenceA :: Applicative f0 => MaybeF f (f0 a) -> f0 (MaybeF f a) #mapM :: Monad m => (a -> m b) -> MaybeF f a -> m (MaybeF f b) #sequence :: Monad m => MaybeF f (m a) -> m (MaybeF f a) # Applicative f => Alternative (MaybeF f) Source # Instance detailsDefined in Control.Applicative.ListF Methodsempty :: MaybeF f a #(<|>) :: MaybeF f a -> MaybeF f a -> MaybeF f a #some :: MaybeF f a -> MaybeF f [a] #many :: MaybeF f a -> MaybeF f [a] # Eq1 f => Eq1 (MaybeF f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftEq :: (a -> b -> Bool) -> MaybeF f a -> MaybeF f b -> Bool # Ord1 f => Ord1 (MaybeF f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftCompare :: (a -> b -> Ordering) -> MaybeF f a -> MaybeF f b -> Ordering # Read1 f => Read1 (MaybeF f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (MaybeF f a) #liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [MaybeF f a] #liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (MaybeF f a) #liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [MaybeF f a] # Show1 f => Show1 (MaybeF f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> MaybeF f a -> ShowS #liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [MaybeF f a] -> ShowS # Pointed f => Pointed (MaybeF f) Source # Instance detailsDefined in Control.Applicative.ListF Methodspoint :: a -> MaybeF f a # Functor f => Plus (MaybeF f) Source # Instance detailsDefined in Control.Applicative.ListF Methodszero :: MaybeF f a # Functor f => Alt (MaybeF f) Source # Instance detailsDefined in Control.Applicative.ListF Methods() :: MaybeF f a -> MaybeF f a -> MaybeF f a #some :: Applicative (MaybeF f) => MaybeF f a -> MaybeF f [a] #many :: Applicative (MaybeF f) => MaybeF f a -> MaybeF f [a] # Source # Instance detailsDefined in Data.HFunctor Methodshbind :: (f ~> MaybeF g) -> MaybeF f ~> MaybeF g Source # Source # Instance detailsDefined in Data.HFunctor Methods Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> MaybeF f ~> MaybeF g Source # Eq (f a) => Eq (MaybeF f a) Source # Instance detailsDefined in Control.Applicative.ListF Methods(==) :: MaybeF f a -> MaybeF f a -> Bool #(/=) :: MaybeF f a -> MaybeF f a -> Bool # (Typeable f, Typeable a, Data (f a)) => Data (MaybeF f a) Source # Instance detailsDefined in Control.Applicative.ListF Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MaybeF f a -> c (MaybeF f a) #gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (MaybeF f a) #toConstr :: MaybeF f a -> Constr #dataTypeOf :: MaybeF f a -> DataType #dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (MaybeF f a)) #dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (MaybeF f a)) #gmapT :: (forall b. Data b => b -> b) -> MaybeF f a -> MaybeF f a #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MaybeF f a -> r #gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MaybeF f a -> r #gmapQ :: (forall d. Data d => d -> u) -> MaybeF f a -> [u] #gmapQi :: Int -> (forall d. Data d => d -> u) -> MaybeF f a -> u #gmapM :: Monad m => (forall d. Data d => d -> m d) -> MaybeF f a -> m (MaybeF f a) #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MaybeF f a -> m (MaybeF f a) #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MaybeF f a -> m (MaybeF f a) # Ord (f a) => Ord (MaybeF f a) Source # Instance detailsDefined in Control.Applicative.ListF Methodscompare :: MaybeF f a -> MaybeF f a -> Ordering #(<) :: MaybeF f a -> MaybeF f a -> Bool #(<=) :: MaybeF f a -> MaybeF f a -> Bool #(>) :: MaybeF f a -> MaybeF f a -> Bool #(>=) :: MaybeF f a -> MaybeF f a -> Bool #max :: MaybeF f a -> MaybeF f a -> MaybeF f a #min :: MaybeF f a -> MaybeF f a -> MaybeF f a # Read (f a) => Read (MaybeF f a) Source # Instance detailsDefined in Control.Applicative.ListF MethodsreadsPrec :: Int -> ReadS (MaybeF f a) #readList :: ReadS [MaybeF f a] #readPrec :: ReadPrec (MaybeF f a) #readListPrec :: ReadPrec [MaybeF f a] # Show (f a) => Show (MaybeF f a) Source # Instance detailsDefined in Control.Applicative.ListF MethodsshowsPrec :: Int -> MaybeF f a -> ShowS #show :: MaybeF f a -> String #showList :: [MaybeF f a] -> ShowS # Generic (MaybeF f a) Source # Instance detailsDefined in Control.Applicative.ListF Associated Typestype Rep (MaybeF f a) :: Type -> Type # Methodsfrom :: MaybeF f a -> Rep (MaybeF f a) x #to :: Rep (MaybeF f a) x -> MaybeF f a # Semigroup (MaybeF f a) Source # Picks the first Just. Instance detailsDefined in Control.Applicative.ListF Methods(<>) :: MaybeF f a -> MaybeF f a -> MaybeF f a #sconcat :: NonEmpty (MaybeF f a) -> MaybeF f a #stimes :: Integral b => b -> MaybeF f a -> MaybeF f a # Monoid (MaybeF f a) Source # Instance detailsDefined in Control.Applicative.ListF Methodsmempty :: MaybeF f a #mappend :: MaybeF f a -> MaybeF f a -> MaybeF f a #mconcat :: [MaybeF f a] -> MaybeF f a # type C MaybeF Source # Instance detailsDefined in Data.HFunctor.Interpret type C MaybeF = Plus type Rep (MaybeF f a) Source # Instance detailsDefined in Control.Applicative.ListF type Rep (MaybeF f a) = D1 (MetaData "MaybeF" "Control.Applicative.ListF" "functor-combinators-0.1.1.1-B2oyFu2GVTM8ySAuzVPoNk" True) (C1 (MetaCons "MaybeF" PrefixI True) (S1 (MetaSel (Just "runMaybeF") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe (f a))))) newtype MapF k f a Source # A map of f as, indexed by keys of type k. It can be useful for represeting a product of many different values of type f a, each "at" a different k location. Can be considered a combination of EnvT and ListF, in a way --- a MapF k f a is like a ListF (EnvT k f) a with unique (and ordered) keys. One use case might be to extend a schema with many "options", indexed by some string. For example, if you had a command line argument parser for a single command data Command a  Then you can represent a command line argument parser for multiple named commands with type Commands = MapF String Command  See NEMapF for a non-empty variant, if you want to enforce that your bag has at least one f a. Constructors  MapF FieldsrunMapF :: Map k (f a) Instances  Monoid k => Interpret (MapF k) Source # Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C (MapF k) :: (Type -> Type) -> Constraint Source # Methodsretract :: C (MapF k) f => MapF k f ~> f Source #interpret :: C (MapF k) g => (f ~> g) -> MapF k f ~> g Source # Monoid k => Inject (MapF k :: (Type -> Type) -> Type -> Type) Source # Injects into a singleton map at mempty. Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> MapF k f Source # HFunctor (MapF k :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> MapF k f ~> MapF k g Source # Functor f => Functor (MapF k f) Source # Instance detailsDefined in Control.Applicative.ListF Methodsfmap :: (a -> b) -> MapF k f a -> MapF k f b #(<$) :: a -> MapF k f b -> MapF k f a # Foldable f => Foldable (MapF k f) Source # Instance detailsDefined in Control.Applicative.ListF Methodsfold :: Monoid m => MapF k f m -> m #foldMap :: Monoid m => (a -> m) -> MapF k f a -> m #foldr :: (a -> b -> b) -> b -> MapF k f a -> b #foldr' :: (a -> b -> b) -> b -> MapF k f a -> b #foldl :: (b -> a -> b) -> b -> MapF k f a -> b #foldl' :: (b -> a -> b) -> b -> MapF k f a -> b #foldr1 :: (a -> a -> a) -> MapF k f a -> a #foldl1 :: (a -> a -> a) -> MapF k f a -> a #toList :: MapF k f a -> [a] #null :: MapF k f a -> Bool #length :: MapF k f a -> Int #elem :: Eq a => a -> MapF k f a -> Bool #maximum :: Ord a => MapF k f a -> a #minimum :: Ord a => MapF k f a -> a #sum :: Num a => MapF k f a -> a #product :: Num a => MapF k f a -> a # Traversable f => Traversable (MapF k f) Source # Instance detailsDefined in Control.Applicative.ListF Methodstraverse :: Applicative f0 => (a -> f0 b) -> MapF k f a -> f0 (MapF k f b) #sequenceA :: Applicative f0 => MapF k f (f0 a) -> f0 (MapF k f a) #mapM :: Monad m => (a -> m b) -> MapF k f a -> m (MapF k f b) #sequence :: Monad m => MapF k f (m a) -> m (MapF k f a) # (Eq k, Eq1 f) => Eq1 (MapF k f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftEq :: (a -> b -> Bool) -> MapF k f a -> MapF k f b -> Bool # (Ord k, Ord1 f) => Ord1 (MapF k f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftCompare :: (a -> b -> Ordering) -> MapF k f a -> MapF k f b -> Ordering # (Ord k, Read k, Read1 f) => Read1 (MapF k f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (MapF k f a) #liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [MapF k f a] #liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (MapF k f a) #liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [MapF k f a] # (Show k, Show1 f) => Show1 (MapF k f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> MapF k f a -> ShowS #liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [MapF k f a] -> ShowS # (Monoid k, Pointed f) => Pointed (MapF k f) Source # Instance detailsDefined in Control.Applicative.ListF Methodspoint :: a -> MapF k f a # (Functor f, Ord k) => Plus (MapF k f) Source # Instance detailsDefined in Control.Applicative.ListF Methodszero :: MapF k f a # (Functor f, Ord k) => Alt (MapF k f) Source # Left-biased union Instance detailsDefined in Control.Applicative.ListF Methods() :: MapF k f a -> MapF k f a -> MapF k f a #some :: Applicative (MapF k f) => MapF k f a -> MapF k f [a] #many :: Applicative (MapF k f) => MapF k f a -> MapF k f [a] # (Eq k, Eq (f a)) => Eq (MapF k f a) Source # Instance detailsDefined in Control.Applicative.ListF Methods(==) :: MapF k f a -> MapF k f a -> Bool #(/=) :: MapF k f a -> MapF k f a -> Bool # (Typeable f, Typeable a, Data k, Data (f a), Ord k) => Data (MapF k f a) Source # Instance detailsDefined in Control.Applicative.ListF Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MapF k f a -> c (MapF k f a) #gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (MapF k f a) #toConstr :: MapF k f a -> Constr #dataTypeOf :: MapF k f a -> DataType #dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (MapF k f a)) #dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (MapF k f a)) #gmapT :: (forall b. Data b => b -> b) -> MapF k f a -> MapF k f a #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MapF k f a -> r #gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MapF k f a -> r #gmapQ :: (forall d. Data d => d -> u) -> MapF k f a -> [u] #gmapQi :: Int -> (forall d. Data d => d -> u) -> MapF k f a -> u #gmapM :: Monad m => (forall d. Data d => d -> m d) -> MapF k f a -> m (MapF k f a) #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MapF k f a -> m (MapF k f a) #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MapF k f a -> m (MapF k f a) # (Ord k, Ord (f a)) => Ord (MapF k f a) Source # Instance detailsDefined in Control.Applicative.ListF Methodscompare :: MapF k f a -> MapF k f a -> Ordering #(<) :: MapF k f a -> MapF k f a -> Bool #(<=) :: MapF k f a -> MapF k f a -> Bool #(>) :: MapF k f a -> MapF k f a -> Bool #(>=) :: MapF k f a -> MapF k f a -> Bool #max :: MapF k f a -> MapF k f a -> MapF k f a #min :: MapF k f a -> MapF k f a -> MapF k f a # (Ord k, Read k, Read (f a)) => Read (MapF k f a) Source # Instance detailsDefined in Control.Applicative.ListF MethodsreadsPrec :: Int -> ReadS (MapF k f a) #readList :: ReadS [MapF k f a] #readPrec :: ReadPrec (MapF k f a) #readListPrec :: ReadPrec [MapF k f a] # (Show k, Show (f a)) => Show (MapF k f a) Source # Instance detailsDefined in Control.Applicative.ListF MethodsshowsPrec :: Int -> MapF k f a -> ShowS #show :: MapF k f a -> String #showList :: [MapF k f a] -> ShowS # Generic (MapF k f a) Source # Instance detailsDefined in Control.Applicative.ListF Associated Typestype Rep (MapF k f a) :: Type -> Type # Methodsfrom :: MapF k f a -> Rep (MapF k f a) x #to :: Rep (MapF k f a) x -> MapF k f a # (Ord k, Alt f) => Semigroup (MapF k f a) Source # A union, combining matching keys with . Instance detailsDefined in Control.Applicative.ListF Methods(<>) :: MapF k f a -> MapF k f a -> MapF k f a #sconcat :: NonEmpty (MapF k f a) -> MapF k f a #stimes :: Integral b => b -> MapF k f a -> MapF k f a # (Ord k, Alt f) => Monoid (MapF k f a) Source # Instance detailsDefined in Control.Applicative.ListF Methodsmempty :: MapF k f a #mappend :: MapF k f a -> MapF k f a -> MapF k f a #mconcat :: [MapF k f a] -> MapF k f a # type C (MapF k) Source # Instance detailsDefined in Data.HFunctor.Interpret type C (MapF k) = Plus type Rep (MapF k f a) Source # Instance detailsDefined in Control.Applicative.ListF type Rep (MapF k f a) = D1 (MetaData "MapF" "Control.Applicative.ListF" "functor-combinators-0.1.1.1-B2oyFu2GVTM8ySAuzVPoNk" True) (C1 (MetaCons "MapF" PrefixI True) (S1 (MetaSel (Just "runMapF") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Map k (f a)))))

newtype NEMapF k f a Source #

A non-empty map of f as, indexed by keys of type k. It can be useful for represeting a product of many different values of type f a, each "at" a different k location, where you need to have at least one f a at all times.

Can be considered a combination of EnvT and NonEmptyF, in a way --- an NEMapF k f a is like a NonEmptyF (EnvT k f) a with unique (and ordered) keys.

See MapF for some use cases.

Constructors

 NEMapF FieldsrunNEMapF :: NEMap k (f a)
Instances
 Monoid k => Interpret (NEMapF k) Source # Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C (NEMapF k) :: (Type -> Type) -> Constraint Source # Methodsretract :: C (NEMapF k) f => NEMapF k f ~> f Source #interpret :: C (NEMapF k) g => (f ~> g) -> NEMapF k f ~> g Source # Monoid k => Inject (NEMapF k :: (Type -> Type) -> Type -> Type) Source # Injects into a singleton map at mempty. Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> NEMapF k f Source # HFunctor (NEMapF k :: (Type -> Type) -> Type -> Type) Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> NEMapF k f ~> NEMapF k g Source # Functor f => Functor (NEMapF k f) Source # Instance detailsDefined in Control.Applicative.ListF Methodsfmap :: (a -> b) -> NEMapF k f a -> NEMapF k f b #(<$) :: a -> NEMapF k f b -> NEMapF k f a # Foldable f => Foldable (NEMapF k f) Source # Instance detailsDefined in Control.Applicative.ListF Methodsfold :: Monoid m => NEMapF k f m -> m #foldMap :: Monoid m => (a -> m) -> NEMapF k f a -> m #foldr :: (a -> b -> b) -> b -> NEMapF k f a -> b #foldr' :: (a -> b -> b) -> b -> NEMapF k f a -> b #foldl :: (b -> a -> b) -> b -> NEMapF k f a -> b #foldl' :: (b -> a -> b) -> b -> NEMapF k f a -> b #foldr1 :: (a -> a -> a) -> NEMapF k f a -> a #foldl1 :: (a -> a -> a) -> NEMapF k f a -> a #toList :: NEMapF k f a -> [a] #null :: NEMapF k f a -> Bool #length :: NEMapF k f a -> Int #elem :: Eq a => a -> NEMapF k f a -> Bool #maximum :: Ord a => NEMapF k f a -> a #minimum :: Ord a => NEMapF k f a -> a #sum :: Num a => NEMapF k f a -> a #product :: Num a => NEMapF k f a -> a # Traversable f => Traversable (NEMapF k f) Source # Instance detailsDefined in Control.Applicative.ListF Methodstraverse :: Applicative f0 => (a -> f0 b) -> NEMapF k f a -> f0 (NEMapF k f b) #sequenceA :: Applicative f0 => NEMapF k f (f0 a) -> f0 (NEMapF k f a) #mapM :: Monad m => (a -> m b) -> NEMapF k f a -> m (NEMapF k f b) #sequence :: Monad m => NEMapF k f (m a) -> m (NEMapF k f a) # (Eq k, Eq1 f) => Eq1 (NEMapF k f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftEq :: (a -> b -> Bool) -> NEMapF k f a -> NEMapF k f b -> Bool # (Ord k, Ord1 f) => Ord1 (NEMapF k f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftCompare :: (a -> b -> Ordering) -> NEMapF k f a -> NEMapF k f b -> Ordering # (Ord k, Read k, Read1 f) => Read1 (NEMapF k f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (NEMapF k f a) #liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [NEMapF k f a] #liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (NEMapF k f a) #liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [NEMapF k f a] # (Show k, Show1 f) => Show1 (NEMapF k f) Source # Instance detailsDefined in Control.Applicative.ListF MethodsliftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> NEMapF k f a -> ShowS #liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [NEMapF k f a] -> ShowS # Foldable1 f => Foldable1 (NEMapF k f) Source # Instance detailsDefined in Control.Applicative.ListF Methodsfold1 :: Semigroup m => NEMapF k f m -> m #foldMap1 :: Semigroup m => (a -> m) -> NEMapF k f a -> m #toNonEmpty :: NEMapF k f a -> NonEmpty a # (Monoid k, Pointed f) => Pointed (NEMapF k f) Source # Instance detailsDefined in Control.Applicative.ListF Methodspoint :: a -> NEMapF k f a # Traversable1 f => Traversable1 (NEMapF k f) Source # Instance detailsDefined in Control.Applicative.ListF Methodstraverse1 :: Apply f0 => (a -> f0 b) -> NEMapF k f a -> f0 (NEMapF k f b) #sequence1 :: Apply f0 => NEMapF k f (f0 b) -> f0 (NEMapF k f b) # (Functor f, Ord k) => Alt (NEMapF k f) Source # Left-biased union Instance detailsDefined in Control.Applicative.ListF Methods() :: NEMapF k f a -> NEMapF k f a -> NEMapF k f a #some :: Applicative (NEMapF k f) => NEMapF k f a -> NEMapF k f [a] #many :: Applicative (NEMapF k f) => NEMapF k f a -> NEMapF k f [a] # (Eq k, Eq (f a)) => Eq (NEMapF k f a) Source # Instance detailsDefined in Control.Applicative.ListF Methods(==) :: NEMapF k f a -> NEMapF k f a -> Bool #(/=) :: NEMapF k f a -> NEMapF k f a -> Bool # (Typeable f, Typeable a, Data k, Data (f a), Ord k) => Data (NEMapF k f a) Source # Instance detailsDefined in Control.Applicative.ListF Methodsgfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NEMapF k f a -> c (NEMapF k f a) #gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (NEMapF k f a) #toConstr :: NEMapF k f a -> Constr #dataTypeOf :: NEMapF k f a -> DataType #dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (NEMapF k f a)) #dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (NEMapF k f a)) #gmapT :: (forall b. Data b => b -> b) -> NEMapF k f a -> NEMapF k f a #gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NEMapF k f a -> r #gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NEMapF k f a -> r #gmapQ :: (forall d. Data d => d -> u) -> NEMapF k f a -> [u] #gmapQi :: Int -> (forall d. Data d => d -> u) -> NEMapF k f a -> u #gmapM :: Monad m => (forall d. Data d => d -> m d) -> NEMapF k f a -> m (NEMapF k f a) #gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NEMapF k f a -> m (NEMapF k f a) #gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NEMapF k f a -> m (NEMapF k f a) # (Ord k, Ord (f a)) => Ord (NEMapF k f a) Source # Instance detailsDefined in Control.Applicative.ListF Methodscompare :: NEMapF k f a -> NEMapF k f a -> Ordering #(<) :: NEMapF k f a -> NEMapF k f a -> Bool #(<=) :: NEMapF k f a -> NEMapF k f a -> Bool #(>) :: NEMapF k f a -> NEMapF k f a -> Bool #(>=) :: NEMapF k f a -> NEMapF k f a -> Bool #max :: NEMapF k f a -> NEMapF k f a -> NEMapF k f a #min :: NEMapF k f a -> NEMapF k f a -> NEMapF k f a # (Ord k, Read k, Read (f a)) => Read (NEMapF k f a) Source # Instance detailsDefined in Control.Applicative.ListF MethodsreadsPrec :: Int -> ReadS (NEMapF k f a) #readList :: ReadS [NEMapF k f a] #readPrec :: ReadPrec (NEMapF k f a) #readListPrec :: ReadPrec [NEMapF k f a] # (Show k, Show (f a)) => Show (NEMapF k f a) Source # Instance detailsDefined in Control.Applicative.ListF MethodsshowsPrec :: Int -> NEMapF k f a -> ShowS #show :: NEMapF k f a -> String #showList :: [NEMapF k f a] -> ShowS # Generic (NEMapF k f a) Source # Instance detailsDefined in Control.Applicative.ListF Associated Typestype Rep (NEMapF k f a) :: Type -> Type # Methodsfrom :: NEMapF k f a -> Rep (NEMapF k f a) x #to :: Rep (NEMapF k f a) x -> NEMapF k f a # (Ord k, Alt f) => Semigroup (NEMapF k f a) Source # A union, combining matching keys with . Instance detailsDefined in Control.Applicative.ListF Methods(<>) :: NEMapF k f a -> NEMapF k f a -> NEMapF k f a #sconcat :: NonEmpty (NEMapF k f a) -> NEMapF k f a #stimes :: Integral b => b -> NEMapF k f a -> NEMapF k f a # type C (NEMapF k) Source # Instance detailsDefined in Data.HFunctor.Interpret type C (NEMapF k) = Alt type Rep (NEMapF k f a) Source # Instance detailsDefined in Control.Applicative.ListF type Rep (NEMapF k f a) = D1 (MetaData "NEMapF" "Control.Applicative.ListF" "functor-combinators-0.1.1.1-B2oyFu2GVTM8ySAuzVPoNk" True) (C1 (MetaCons "NEMapF" PrefixI True) (S1 (MetaSel (Just "runNEMapF") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (NEMap k (f a))))) data Ap (f :: Type -> Type) a # The free Applicative for a Functor f. Instances  Source # A free Applicative Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C Ap :: (Type -> Type) -> Constraint Source # Methodsretract :: C Ap f => Ap f ~> f Source #interpret :: C Ap g => (f ~> g) -> Ap f ~> g Source # Source # Instance detailsDefined in Data.HFunctor.Final Methods Functor (Ap f) Instance detailsDefined in Control.Applicative.Free Methodsfmap :: (a -> b) -> Ap f a -> Ap f b #(<$) :: a -> Ap f b -> Ap f a # Instance detailsDefined in Control.Applicative.Free Methodspure :: a -> Ap f a #(<*>) :: Ap f (a -> b) -> Ap f a -> Ap f b #liftA2 :: (a -> b -> c) -> Ap f a -> Ap f b -> Ap f c #(*>) :: Ap f a -> Ap f b -> Ap f b #(<*) :: Ap f a -> Ap f b -> Ap f a # Comonad f => Comonad (Ap f) Instance detailsDefined in Control.Applicative.Free Methodsextract :: Ap f a -> a #duplicate :: Ap f a -> Ap f (Ap f a) #extend :: (Ap f a -> b) -> Ap f a -> Ap f b # Apply (Ap f) Instance detailsDefined in Control.Applicative.Free Methods(<.>) :: Ap f (a -> b) -> Ap f a -> Ap f b #(.>) :: Ap f a -> Ap f b -> Ap f b #(<.) :: Ap f a -> Ap f b -> Ap f a #liftF2 :: (a -> b -> c) -> Ap f a -> Ap f b -> Ap f c # Source # Instance detailsDefined in Data.HFunctor Methodshbind :: (f ~> Ap g) -> Ap f ~> Ap g Source #hjoin :: Ap (Ap f) ~> Ap f Source # Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> Ap f Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Ap f ~> Ap g Source # type C Ap Source # Instance detailsDefined in Data.HFunctor.Interpret type C Ap = Applicative

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

One or more fs convolved with itself.

Essentially:

Ap1 f
~ f                            -- one f
:+: (f Day' f)          -- two f's
:+: (f Day f Day f)           -- three f's
:+: (f Day f Day f Day f)  -- four f's
:+: ...                          -- etc.


Useful if you want to promote an f to a situation with "at least one f sequenced with itself".

Mostly useful for its HFunctor and Interpret instance, along with its relationship with Ap and Day.

This is the free Apply --- Basically a "non-empty" Ap.

The construction here is based on Ap, similar to now NonEmpty is built on list.

Constructors

 Ap1 :: f a -> Ap f (a -> b) -> Ap1 f b

Bundled Patterns

 pattern DayAp1 :: Day f (Ap f) a -> Ap1 f a An Ap1 f is just a Day f (Ap f). This bidirectional pattern synonym lets you treat it as such.
Instances
 Source # Instance detailsDefined in Data.Functor.Apply.Free Associated Typestype C Ap1 :: (Type -> Type) -> Constraint Source # Methodsretract :: C Ap1 f => Ap1 f ~> f Source #interpret :: C Ap1 g => (f ~> g) -> Ap1 f ~> g Source # Source # Instance detailsDefined in Data.Functor.Apply.Free Methodshbind :: (f ~> Ap1 g) -> Ap1 f ~> Ap1 g Source #hjoin :: Ap1 (Ap1 f) ~> Ap1 f Source # Source # Instance detailsDefined in Data.Functor.Apply.Free Methodsinject :: f ~> Ap1 f Source # Source # Instance detailsDefined in Data.HFunctor.Final Methods Source # Instance detailsDefined in Data.Functor.Apply.Free Methodshmap :: (f ~> g) -> Ap1 f ~> Ap1 g Source # Functor (Ap1 f) Source # Instance detailsDefined in Data.Functor.Apply.Free Methodsfmap :: (a -> b) -> Ap1 f a -> Ap1 f b #(<$) :: a -> Ap1 f b -> Ap1 f a # Apply (Ap1 f) Source # Instance detailsDefined in Data.Functor.Apply.Free Methods(<.>) :: Ap1 f (a -> b) -> Ap1 f a -> Ap1 f b #(.>) :: Ap1 f a -> Ap1 f b -> Ap1 f b #(<.) :: Ap1 f a -> Ap1 f b -> Ap1 f a #liftF2 :: (a -> b -> c) -> Ap1 f a -> Ap1 f b -> Ap1 f c # type C Ap1 Source # Instance detailsDefined in Data.Functor.Apply.Free type C Ap1 = Apply data Alt (f :: Type -> Type) a # Instances  Source # A free Alternative Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C Alt :: (Type -> Type) -> Constraint Source # Methodsretract :: C Alt f => Alt f ~> f Source #interpret :: C Alt g => (f ~> g) -> Alt f ~> g Source # Source # Instance detailsDefined in Data.HFunctor.Final Methods Functor (Alt f) Instance detailsDefined in Control.Alternative.Free Methodsfmap :: (a -> b) -> Alt f a -> Alt f b #(<$) :: a -> Alt f b -> Alt f a # Instance detailsDefined in Control.Alternative.Free Methodspure :: a -> Alt f a #(<*>) :: Alt f (a -> b) -> Alt f a -> Alt f b #liftA2 :: (a -> b -> c) -> Alt f a -> Alt f b -> Alt f c #(*>) :: Alt f a -> Alt f b -> Alt f b #(<*) :: Alt f a -> Alt f b -> Alt f a # Instance detailsDefined in Control.Alternative.Free Methodsempty :: Alt f a #(<|>) :: Alt f a -> Alt f a -> Alt f a #some :: Alt f a -> Alt f [a] #many :: Alt f a -> Alt f [a] # Apply (Alt f) Instance detailsDefined in Control.Alternative.Free Methods(<.>) :: Alt f (a -> b) -> Alt f a -> Alt f b #(.>) :: Alt f a -> Alt f b -> Alt f b #(<.) :: Alt f a -> Alt f b -> Alt f a #liftF2 :: (a -> b -> c) -> Alt f a -> Alt f b -> Alt f c # Alt (Alt f) Instance detailsDefined in Control.Alternative.Free Methods() :: Alt f a -> Alt f a -> Alt f a #some :: Applicative (Alt f) => Alt f a -> Alt f [a] #many :: Applicative (Alt f) => Alt f a -> Alt f [a] # Source # Instance detailsDefined in Data.HFunctor Methodshbind :: (f ~> Alt g) -> Alt f ~> Alt g Source #hjoin :: Alt (Alt f) ~> Alt f Source # Source # Instance detailsDefined in Data.HFunctor Methodsinject :: f ~> Alt f Source # Source # Instance detailsDefined in Data.HFunctor.Internal Methodshmap :: (f ~> g) -> Alt f ~> Alt g Source # Semigroup (Alt f a) Instance detailsDefined in Control.Alternative.Free Methods(<>) :: Alt f a -> Alt f a -> Alt f a #sconcat :: NonEmpty (Alt f a) -> Alt f a #stimes :: Integral b => b -> Alt f a -> Alt f a # Monoid (Alt f a) Instance detailsDefined in Control.Alternative.Free Methodsmempty :: Alt f a #mappend :: Alt f a -> Alt f a -> Alt f a #mconcat :: [Alt f a] -> Alt f a # type C Alt Source # Instance detailsDefined in Data.HFunctor.Interpret type C Alt = Alternative

data Free f a Source #

A Free f is f enhanced with "sequential binding" capabilities. It allows you to sequence multiple fs one after the other, and also to determine "what f to sequence" based on the result of the computation so far.

Essentially, you can think of this as "giving f a Monad instance", with all that that entails (return, >>=, etc.).

Lift f into it with inject :: f a -> Free f a. When you finally want to "use" it, you can interpret it into any monadic context:

interpret
:: Monad g
=> (forall x. f x -> g x)
-> Free f a
-> g a


Structurally, this is equivalent to many "nested" f's. A value of type Free f a is either:

• a
• f a
• f (f a)
• f (f (f a))
• .. etc.

Under the hood, this is the Church-encoded Freer monad. It's Free, or F, but in a way that is compatible with HFunctor and Interpret.

Instances
 Source # A free Monad` Instance detailsDefined in Data.HFunctor.Interpret Associated Typestype C Free :: (Type -> Type) -> Constraint Source # Methodsretract :: C Free f => Free f ~> f Source #interpret :: C Free g => (f ~> g) -> Free f ~> g Source # Source # Instance detailsDefined in Data.HFunctor.Final MethodstoFree :: Functor f =>