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

Copyright(c) Justin Le 2019
LicenseBSD3
Maintainerjustin@jle.im
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.HFunctor

Contents

Description

This module provides abstractions for working with unary functor combinators.

Principally, it defines the HFunctor itself, as well as some classes that expose extra functionality that some HFunctors have (Inject and HBind).

See Data.HFunctor.Interpret for tools to use HFunctors as functor combinators that can represent interpretable schemas, and Data.HBifunctor for an abstraction over binary functor combinators.

Synopsis

Documentation

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
HFunctor Ap1 Source # 
Instance details

Defined in Data.Functor.Apply.Free

Methods

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

HFunctor (Reverse :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor (Backwards :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor (IdentityT :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor (Flagged :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor (Steps :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor (Step :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor (Void2 :: (k1 -> Type) -> k2 -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor (ReaderT r :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

hmap :: (f ~> g) -> ReaderT r f ~> ReaderT r g Source #

HFunctor (Sum f :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

hmap :: (f0 ~> g) -> Sum f f0 ~> Sum f g Source #

HFunctor (Product f :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

hmap :: (f0 ~> g) -> Product f f0 ~> Product f g Source #

HFunctor ((:+:) f :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

hmap :: (f0 ~> g) -> (f :+: f0) ~> (f :+: g) Source #

HFunctor ((:*:) f :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

hmap :: (f0 ~> g) -> (f :*: f0) ~> (f :*: g) Source #

HFunctor (ProxyF :: (k1 -> Type) -> k2 -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

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

HFunctor t => HFunctor (HLift t :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

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

HFunctor t => HFunctor (HFree t :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

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

HBifunctor t => HFunctor (Chain1 t :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Chain

Methods

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

HFunctor (M1 i c :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

hmap :: (f ~> g) -> M1 i c f ~> M1 i c g Source #

Functor f => HFunctor ((:.:) f :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

hmap :: (f0 ~> g) -> (f :.: f0) ~> (f :.: g) Source #

HFunctor (Joker f :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

hmap :: (f0 ~> g) -> Joker f f0 ~> Joker f g Source #

HFunctor (ConstF e :: (k1 -> Type) -> k2 -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

hmap :: (f ~> g) -> ConstF e f ~> ConstF e g Source #

HFunctor (LeftF f :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HBifunctor

Methods

hmap :: (f0 ~> g) -> LeftF f f0 ~> LeftF f g Source #

HFunctor (RightF f :: (k1 -> Type) -> k1 -> Type) Source # 
Instance details

Defined in Data.HBifunctor

Methods

hmap :: (f0 ~> g) -> RightF f f0 ~> RightF f g Source #

HFunctor (RightF f :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HBifunctor

Methods

hmap :: (f0 ~> g) -> RightF f f0 ~> RightF f g Source #

HBifunctor t => HFunctor (WrappedHBifunctor t f :: (k1 -> Type) -> k2 -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor (Void3 f :: (k2 -> Type) -> k1 -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

hmap :: (f0 ~> g) -> Void3 f f0 ~> Void3 f g Source #

HBifunctor t => HFunctor (Chain t i :: (k1 -> Type) -> k2 -> Type) Source # 
Instance details

Defined in Data.HFunctor.Chain

Methods

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

HFunctor (CoRec :: (k -> Type) -> [k] -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor (Rec :: (k -> Type) -> [k] -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor (Tagged :: (k -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor MaybeT Source #

Note that there is no Interpret or Bind instance, because inject requires Functor f.

Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor F Source #

Note that there is no Interpret or Bind instance, because inject requires Functor f.

Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor Ap Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor Ap Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor Ap Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor Alt Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor Yoneda Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor Coyoneda Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor WrappedApplicative Source # 
Instance details

Defined in Data.HFunctor.Internal

HFunctor MaybeApply Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor Lift Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor ListF Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor NonEmptyF Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor MaybeF Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor Free1 Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor Free Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

HFunctor (EnvT e :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

hmap :: (f ~> g) -> EnvT e f ~> EnvT e g Source #

HFunctor (Day f :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

hmap :: (f0 ~> g) -> Day f f0 ~> Day f g Source #

HFunctor (These1 f :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

hmap :: (f0 ~> g) -> These1 f f0 ~> These1 f g Source #

HFunctor (MapF k :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

hmap :: (f ~> g) -> MapF k f ~> MapF k g Source #

HFunctor (NEMapF k :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

hmap :: (f ~> g) -> NEMapF k f ~> NEMapF k g Source #

HFunctor (Comp f :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

hmap :: (f0 ~> g) -> Comp f f0 ~> Comp f g Source #

HFunctor (Final c :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Final

Methods

hmap :: (f ~> g) -> Final c f ~> Final c g Source #

(HFunctor s, HFunctor t) => HFunctor (ComposeT s t :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Internal

Methods

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

overHFunctor :: HFunctor t => (f <~> g) -> t f <~> t g Source #

Lift an isomorphism over an HFunctor.

Essentailly, if f and g are isomorphic, then so are t f and t g.

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
Inject Ap1 Source # 
Instance details

Defined in Data.Functor.Apply.Free

Methods

inject :: f ~> Ap1 f Source #

Inject (Reverse :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> Reverse f Source #

Inject (Backwards :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> Backwards f Source #

Inject (IdentityT :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> IdentityT f Source #

Inject (Flagged :: (k -> Type) -> k -> Type) Source #

Injects with False.

Equivalent to instance for EnvT Any and HLift IdentityT.

Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> Flagged f Source #

Inject (Steps :: (k -> Type) -> k -> Type) Source #

Injects into a singleton map at 0; same behavior as NEMapF (Sum Natural).

Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> Steps f Source #

Inject (Step :: (k -> Type) -> k -> Type) Source #

Injects with 0.

Equivalent to instance for EnvT (Sum Natural).

Instance details

Defined in Data.HFunctor

Methods

inject :: 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 details

Defined in Data.HFunctor

Methods

inject :: f ~> HFree t f Source #

HFunctor t => Inject (HLift t :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> HLift t f Source #

Inject (ProxyF :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> ProxyF f Source #

Inject (ReaderT r :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> ReaderT r f Source #

Inject (Sum f :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f0 ~> Sum f f0 Source #

Inject ((:+:) f :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f0 ~> (f :+: f0) Source #

HBifunctor t => Inject (Chain1 t :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor.Chain

Methods

inject :: f ~> Chain1 t f Source #

Monoid e => Inject (ConstF e :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> ConstF e f Source #

Inject (M1 i c :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> M1 i c f Source #

Applicative f => Inject ((:.:) f :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f0 ~> (f :.: f0) Source #

Inject (RightF f :: (k1 -> Type) -> k1 -> Type) Source # 
Instance details

Defined in Data.HBifunctor

Methods

inject :: f0 ~> RightF f f0 Source #

Inject Ap Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> Ap f Source #

Inject Ap Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> Ap f Source #

Inject Ap Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> Ap f Source #

Inject Alt Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> Alt f Source #

Inject Coyoneda Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> Coyoneda f Source #

Inject WrappedApplicative Source # 
Instance details

Defined in Data.HFunctor

Inject MaybeApply Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> MaybeApply f Source #

Inject Lift Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> Lift f Source #

Inject ListF Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> ListF f Source #

Inject NonEmptyF Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> NonEmptyF f Source #

Inject MaybeF Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> MaybeF f Source #

Inject Free1 Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> Free1 f Source #

Inject Free Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> Free f Source #

Monoid e => Inject (EnvT e :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> EnvT e f Source #

Inject (These1 f :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f0 ~> These1 f f0 Source #

Monoid k => Inject (MapF k :: (Type -> Type) -> Type -> Type) Source #

Injects into a singleton map at mempty.

Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> MapF k f Source #

Monoid k => Inject (NEMapF k :: (Type -> Type) -> Type -> Type) Source #

Injects into a singleton map at mempty.

Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> NEMapF k f Source #

Applicative f => Inject (Comp f :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f0 ~> Comp f f0 Source #

Inject (Final c :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Final

Methods

inject :: f ~> Final c f Source #

Plus f => Inject ((:*:) f :: (Type -> Type) -> Type -> Type) Source #

Only uses zero

Instance details

Defined in Data.HFunctor

Methods

inject :: f0 ~> (f :*: f0) Source #

Plus f => Inject (Product f :: (Type -> Type) -> Type -> Type) Source #

Only uses zero

Instance details

Defined in Data.HFunctor

Methods

inject :: f0 ~> Product f f0 Source #

(Inject s, Inject t) => Inject (ComposeT s t :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> ComposeT s t f Source #

(Tensor t, i ~ I t) => Inject (Chain t i :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Chain

Methods

inject :: f ~> Chain t i f Source #

class Inject t => HBind t where Source #

HBind is effectively a "higher-order Monad", in the sense that HFunctor is a "higher-order Functor".

It can be considered a typeclass for HFunctors that you can bind continuations to, nautraluniversal over all ffunctors. They work "for all functors" you lift, without requiring any constraints.

It is very similar to Interpret, except Interpret has the ability to constrain the contexts to some typeclass.

The main law is that binding inject should leave things unchanged:

hbind inject == id

But hbind should also be associatiatve, in a way that makes

hjoin . hjoin
   = hjoin . hmap hjoin

That is, squishing a t (t (t f)) a into a t f a can be done "inside" first, then "outside", or "outside" first, then "inside".

Note that these laws are different from the Interpret laws, so we often have instances where hbind and interpret (though they both may typecheck) produce different behavior.

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

Minimal complete definition

hbind | hjoin

Methods

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

Bind a continuation to a t f into some context g.

hjoin :: t (t f) ~> t f Source #

Collapse a nested t (t f) into a single t f.

Instances
HBind Ap1 Source # 
Instance details

Defined in Data.Functor.Apply.Free

Methods

hbind :: (f ~> Ap1 g) -> Ap1 f ~> Ap1 g Source #

hjoin :: Ap1 (Ap1 f) ~> Ap1 f Source #

HBind (Reverse :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

HBind (Backwards :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

HBind (IdentityT :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

HBind (Flagged :: (k -> Type) -> k -> Type) Source #

Equivalent to instance for EnvT Any and HLift IdentityT.

Instance details

Defined in Data.HFunctor

HBind (Step :: (k -> Type) -> k -> Type) Source #

Equivalent to instance for EnvT (Sum Natural).

Instance details

Defined in Data.HFunctor

Methods

hbind :: (f ~> Step g) -> Step f ~> Step g Source #

hjoin :: Step (Step f) ~> Step f Source #

HFunctor t => HBind (HFree t :: (k -> Type) -> k -> Type) Source #

HFree is the "free HBind" for any HFunctor

Instance details

Defined in Data.HFunctor

Methods

hbind :: (f ~> HFree t g) -> HFree t f ~> HFree t g Source #

hjoin :: HFree t (HFree t f) ~> HFree t f Source #

(HBind t, Inject t) => HBind (HLift t :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f ~> HLift t g) -> HLift t f ~> HLift t g Source #

hjoin :: HLift t (HLift t f) ~> HLift t f Source #

HBind (ProxyF :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f ~> ProxyF g) -> ProxyF f ~> ProxyF g Source #

hjoin :: ProxyF (ProxyF f) ~> ProxyF f Source #

HBind (Sum f :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f0 ~> Sum f g) -> Sum f f0 ~> Sum f g Source #

hjoin :: Sum f (Sum f f0) ~> Sum f f0 Source #

HBind ((:+:) f :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f0 ~> (f :+: g)) -> (f :+: f0) ~> (f :+: g) Source #

hjoin :: (f :+: (f :+: f0)) ~> (f :+: f0) Source #

HBind (M1 i c :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f ~> M1 i c g) -> M1 i c f ~> M1 i c g Source #

hjoin :: M1 i c (M1 i c f) ~> M1 i c f Source #

HBind (RightF f :: (k1 -> Type) -> k1 -> Type) Source # 
Instance details

Defined in Data.HBifunctor

Methods

hbind :: (f0 ~> RightF f g) -> RightF f f0 ~> RightF f g Source #

hjoin :: RightF f (RightF f f0) ~> RightF f f0 Source #

HBind Ap Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f ~> Ap g) -> Ap f ~> Ap g Source #

hjoin :: Ap (Ap f) ~> Ap f Source #

HBind Ap Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f ~> Ap g) -> Ap f ~> Ap g Source #

hjoin :: Ap (Ap f) ~> Ap f Source #

HBind Ap Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f ~> Ap g) -> Ap f ~> Ap g Source #

hjoin :: Ap (Ap f) ~> Ap f Source #

HBind Alt Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f ~> Alt g) -> Alt f ~> Alt g Source #

hjoin :: Alt (Alt f) ~> Alt f Source #

HBind Coyoneda Source # 
Instance details

Defined in Data.HFunctor

HBind WrappedApplicative Source # 
Instance details

Defined in Data.HFunctor

HBind MaybeApply Source # 
Instance details

Defined in Data.HFunctor

HBind Lift Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f ~> Lift g) -> Lift f ~> Lift g Source #

hjoin :: Lift (Lift f) ~> Lift f Source #

HBind ListF Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f ~> ListF g) -> ListF f ~> ListF g Source #

hjoin :: ListF (ListF f) ~> ListF f Source #

HBind NonEmptyF Source # 
Instance details

Defined in Data.HFunctor

HBind MaybeF Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f ~> MaybeF g) -> MaybeF f ~> MaybeF g Source #

hjoin :: MaybeF (MaybeF f) ~> MaybeF f Source #

HBind Free1 Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f ~> Free1 g) -> Free1 f ~> Free1 g Source #

hjoin :: Free1 (Free1 f) ~> Free1 f Source #

HBind Free Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f ~> Free g) -> Free f ~> Free g Source #

hjoin :: Free (Free f) ~> Free f Source #

Monoid e => HBind (EnvT e :: (Type -> Type) -> Type -> Type) Source #

Combines the accumulators, Writer-style

Instance details

Defined in Data.HFunctor

Methods

hbind :: (f ~> EnvT e g) -> EnvT e f ~> EnvT e g Source #

hjoin :: EnvT e (EnvT e f) ~> EnvT e f Source #

Alt f => HBind (These1 f :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f0 ~> These1 f g) -> These1 f f0 ~> These1 f g Source #

hjoin :: These1 f (These1 f f0) ~> These1 f f0 Source #

Plus f => HBind ((:*:) f :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f0 ~> (f :*: g)) -> (f :*: f0) ~> (f :*: g) Source #

hjoin :: (f :*: (f :*: f0)) ~> (f :*: f0) Source #

Plus f => HBind (Product f :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f0 ~> Product f g) -> Product f f0 ~> Product f g Source #

hjoin :: Product f (Product f f0) ~> Product f f0 Source #

Simple instances

data ProxyF f a Source #

The functor combinator that forgets all structure in the input. Ignores the input structure and stores no information.

Acts like the "zero" with respect to functor combinator composition.

ComposeT ProxyF f      ~ ProxyF
ComposeT f      ProxyF ~ ProxyF

It can be injected into (losing all information), but it is impossible to ever retract or interpret it.

This is essentially ConstF ().

Constructors

ProxyF 
Instances
HFunctor (ProxyF :: (k1 -> Type) -> k2 -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

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

HBind (ProxyF :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f ~> ProxyF g) -> ProxyF f ~> ProxyF g Source #

hjoin :: ProxyF (ProxyF f) ~> ProxyF f Source #

Inject (ProxyF :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> ProxyF f 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 details

Defined in Data.HFunctor.Interpret

Associated Types

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

Methods

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

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

Functor (ProxyF f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

fmap :: (a -> b) -> ProxyF f a -> ProxyF f b #

(<$) :: a -> ProxyF f b -> ProxyF f a #

Foldable (ProxyF f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

fold :: Monoid m => ProxyF f m -> m #

foldMap :: Monoid m => (a -> m) -> ProxyF f a -> m #

foldr :: (a -> b -> b) -> b -> ProxyF f a -> b #

foldr' :: (a -> b -> b) -> b -> ProxyF f a -> b #

foldl :: (b -> a -> b) -> b -> ProxyF f a -> b #

foldl' :: (b -> a -> b) -> b -> ProxyF f a -> b #

foldr1 :: (a -> a -> a) -> ProxyF f a -> a #

foldl1 :: (a -> a -> a) -> ProxyF f a -> a #

toList :: ProxyF f a -> [a] #

null :: ProxyF f a -> Bool #

length :: ProxyF f a -> Int #

elem :: Eq a => a -> ProxyF f a -> Bool #

maximum :: Ord a => ProxyF f a -> a #

minimum :: Ord a => ProxyF f a -> a #

sum :: Num a => ProxyF f a -> a #

product :: Num a => ProxyF f a -> a #

Traversable (ProxyF f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

traverse :: Applicative f0 => (a -> f0 b) -> ProxyF f a -> f0 (ProxyF f b) #

sequenceA :: Applicative f0 => ProxyF f (f0 a) -> f0 (ProxyF f a) #

mapM :: Monad m => (a -> m b) -> ProxyF f a -> m (ProxyF f b) #

sequence :: Monad m => ProxyF f (m a) -> m (ProxyF f a) #

Eq1 (ProxyF f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

liftEq :: (a -> b -> Bool) -> ProxyF f a -> ProxyF f b -> Bool #

Ord1 (ProxyF f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

liftCompare :: (a -> b -> Ordering) -> ProxyF f a -> ProxyF f b -> Ordering #

Read1 (ProxyF f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (ProxyF f a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [ProxyF f a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (ProxyF f a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [ProxyF f a] #

Show1 (ProxyF f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> ProxyF f a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [ProxyF f a] -> ShowS #

Eq (ProxyF f a) Source # 
Instance details

Defined in Data.HFunctor

Methods

(==) :: ProxyF f a -> ProxyF f a -> Bool #

(/=) :: ProxyF f a -> ProxyF f a -> Bool #

(Typeable f, Typeable a, Typeable k1, Typeable k2) => Data (ProxyF f a) Source # 
Instance details

Defined in Data.HFunctor

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ProxyF f a -> c (ProxyF f a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ProxyF f a) #

toConstr :: ProxyF f a -> Constr #

dataTypeOf :: ProxyF f a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (ProxyF f a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ProxyF f a)) #

gmapT :: (forall b. Data b => b -> b) -> ProxyF f a -> ProxyF f a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ProxyF f a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ProxyF f a -> r #

gmapQ :: (forall d. Data d => d -> u) -> ProxyF f a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ProxyF f a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ProxyF f a -> m (ProxyF f a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ProxyF f a -> m (ProxyF f a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ProxyF f a -> m (ProxyF f a) #

Ord (ProxyF f a) Source # 
Instance details

Defined in Data.HFunctor

Methods

compare :: ProxyF f a -> ProxyF f a -> Ordering #

(<) :: ProxyF f a -> ProxyF f a -> Bool #

(<=) :: ProxyF f a -> ProxyF f a -> Bool #

(>) :: ProxyF f a -> ProxyF f a -> Bool #

(>=) :: ProxyF f a -> ProxyF f a -> Bool #

max :: ProxyF f a -> ProxyF f a -> ProxyF f a #

min :: ProxyF f a -> ProxyF f a -> ProxyF f a #

Read (ProxyF f a) Source # 
Instance details

Defined in Data.HFunctor

Show (ProxyF f a) Source # 
Instance details

Defined in Data.HFunctor

Methods

showsPrec :: Int -> ProxyF f a -> ShowS #

show :: ProxyF f a -> String #

showList :: [ProxyF f a] -> ShowS #

Generic (ProxyF f a) Source # 
Instance details

Defined in Data.HFunctor

Associated Types

type Rep (ProxyF f a) :: Type -> Type #

Methods

from :: ProxyF f a -> Rep (ProxyF f a) x #

to :: Rep (ProxyF f a) x -> ProxyF f a #

type C (ProxyF :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

type C (ProxyF :: (Type -> Type) -> Type -> Type) = (Impossible :: (Type -> Type) -> Constraint)
type Rep (ProxyF f a) Source # 
Instance details

Defined in Data.HFunctor

type Rep (ProxyF f a) = D1 (MetaData "ProxyF" "Data.HFunctor" "functor-combinators-0.1.1.1-B2oyFu2GVTM8ySAuzVPoNk" False) (C1 (MetaCons "ProxyF" PrefixI False) (U1 :: Type -> Type))

data ConstF e f a Source #

Functor combinator that forgets all structure on the input, and instead stores a value of type e.

Like ProxyF, acts like a "zero" with functor combinator composition.

It can be injected into (losing all information), but it is impossible to ever retract or interpret it.

Constructors

ConstF 

Fields

Instances
HFunctor (ConstF e :: (k1 -> Type) -> k2 -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

hmap :: (f ~> g) -> ConstF e f ~> ConstF e g Source #

Monoid e => Inject (ConstF e :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> ConstF e f 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 details

Defined in Data.HFunctor.Interpret

Associated Types

type C (ConstF e) :: (Type -> Type) -> Constraint Source #

Methods

retract :: C (ConstF e) f => ConstF e f ~> f Source #

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

Functor (ConstF e f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

fmap :: (a -> b) -> ConstF e f a -> ConstF e f b #

(<$) :: a -> ConstF e f b -> ConstF e f a #

Foldable (ConstF e f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

fold :: Monoid m => ConstF e f m -> m #

foldMap :: Monoid m => (a -> m) -> ConstF e f a -> m #

foldr :: (a -> b -> b) -> b -> ConstF e f a -> b #

foldr' :: (a -> b -> b) -> b -> ConstF e f a -> b #

foldl :: (b -> a -> b) -> b -> ConstF e f a -> b #

foldl' :: (b -> a -> b) -> b -> ConstF e f a -> b #

foldr1 :: (a -> a -> a) -> ConstF e f a -> a #

foldl1 :: (a -> a -> a) -> ConstF e f a -> a #

toList :: ConstF e f a -> [a] #

null :: ConstF e f a -> Bool #

length :: ConstF e f a -> Int #

elem :: Eq a => a -> ConstF e f a -> Bool #

maximum :: Ord a => ConstF e f a -> a #

minimum :: Ord a => ConstF e f a -> a #

sum :: Num a => ConstF e f a -> a #

product :: Num a => ConstF e f a -> a #

Traversable (ConstF e f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

traverse :: Applicative f0 => (a -> f0 b) -> ConstF e f a -> f0 (ConstF e f b) #

sequenceA :: Applicative f0 => ConstF e f (f0 a) -> f0 (ConstF e f a) #

mapM :: Monad m => (a -> m b) -> ConstF e f a -> m (ConstF e f b) #

sequence :: Monad m => ConstF e f (m a) -> m (ConstF e f a) #

Eq e => Eq1 (ConstF e f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

liftEq :: (a -> b -> Bool) -> ConstF e f a -> ConstF e f b -> Bool #

Ord e => Ord1 (ConstF e f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

liftCompare :: (a -> b -> Ordering) -> ConstF e f a -> ConstF e f b -> Ordering #

Read e => Read1 (ConstF e f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

liftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (ConstF e f a) #

liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [ConstF e f a] #

liftReadPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec (ConstF e f a) #

liftReadListPrec :: ReadPrec a -> ReadPrec [a] -> ReadPrec [ConstF e f a] #

Show e => Show1 (ConstF e f :: Type -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> ConstF e f a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [ConstF e f a] -> ShowS #

Eq e => Eq (ConstF e f a) Source # 
Instance details

Defined in Data.HFunctor

Methods

(==) :: ConstF e f a -> ConstF e f a -> Bool #

(/=) :: ConstF e f a -> ConstF e f a -> Bool #

(Typeable f, Typeable a, Typeable k1, Typeable k2, Data e) => Data (ConstF e f a) Source # 
Instance details

Defined in Data.HFunctor

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ConstF e f a -> c (ConstF e f a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ConstF e f a) #

toConstr :: ConstF e f a -> Constr #

dataTypeOf :: ConstF e f a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (ConstF e f a)) #

dataCast2 :: Typeable t => (forall d e0. (Data d, Data e0) => c (t d e0)) -> Maybe (c (ConstF e f a)) #

gmapT :: (forall b. Data b => b -> b) -> ConstF e f a -> ConstF e f a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ConstF e f a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ConstF e f a -> r #

gmapQ :: (forall d. Data d => d -> u) -> ConstF e f a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ConstF e f a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ConstF e f a -> m (ConstF e f a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ConstF e f a -> m (ConstF e f a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ConstF e f a -> m (ConstF e f a) #

Ord e => Ord (ConstF e f a) Source # 
Instance details

Defined in Data.HFunctor

Methods

compare :: ConstF e f a -> ConstF e f a -> Ordering #

(<) :: ConstF e f a -> ConstF e f a -> Bool #

(<=) :: ConstF e f a -> ConstF e f a -> Bool #

(>) :: ConstF e f a -> ConstF e f a -> Bool #

(>=) :: ConstF e f a -> ConstF e f a -> Bool #

max :: ConstF e f a -> ConstF e f a -> ConstF e f a #

min :: ConstF e f a -> ConstF e f a -> ConstF e f a #

Read e => Read (ConstF e f a) Source # 
Instance details

Defined in Data.HFunctor

Methods

readsPrec :: Int -> ReadS (ConstF e f a) #

readList :: ReadS [ConstF e f a] #

readPrec :: ReadPrec (ConstF e f a) #

readListPrec :: ReadPrec [ConstF e f a] #

Show e => Show (ConstF e f a) Source # 
Instance details

Defined in Data.HFunctor

Methods

showsPrec :: Int -> ConstF e f a -> ShowS #

show :: ConstF e f a -> String #

showList :: [ConstF e f a] -> ShowS #

Generic (ConstF e f a) Source # 
Instance details

Defined in Data.HFunctor

Associated Types

type Rep (ConstF e f a) :: Type -> Type #

Methods

from :: ConstF e f a -> Rep (ConstF e f a) x #

to :: Rep (ConstF e f a) x -> ConstF e f a #

type C (ConstF e :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.HFunctor.Interpret

type C (ConstF e :: (Type -> Type) -> Type -> Type) = (Impossible :: (Type -> Type) -> Constraint)
type Rep (ConstF e f a) Source # 
Instance details

Defined in Data.HFunctor

type Rep (ConstF e f a) = D1 (MetaData "ConstF" "Data.HFunctor" "functor-combinators-0.1.1.1-B2oyFu2GVTM8ySAuzVPoNk" False) (C1 (MetaCons "ConstF" PrefixI True) (S1 (MetaSel (Just "getConstF") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 e)))

HFunctor Combinators

data HLift t f a Source #

An "HFunctor combinator" that enhances an HFunctor with the ability to hold a single f a. This is the higher-order analogue of Lift.

You can think of it as a free Inject for any f.

Note that HLift IdentityT is equivalent to EnvT Any.

Constructors

HPure (f a) 
HOther (t f a) 
Instances
HFunctor t => HFunctor (HLift t :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

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

(HBind t, Inject t) => HBind (HLift t :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

hbind :: (f ~> HLift t g) -> HLift t f ~> HLift t g Source #

hjoin :: HLift t (HLift t f) ~> HLift t f Source #

HFunctor t => Inject (HLift t :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> HLift t f Source #

Interpret t => Interpret (HLift t) Source #

Never uses inject

Instance details

Defined in Data.HFunctor.Interpret

Associated Types

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

Methods

retract :: C (HLift t) f => HLift t f ~> f Source #

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

(Functor f, Functor (t f)) => Functor (HLift t f) Source # 
Instance details

Defined in Data.HFunctor

Methods

fmap :: (a -> b) -> HLift t f a -> HLift t f b #

(<$) :: a -> HLift t f b -> HLift t f a #

(Eq1 (t f), Eq1 f) => Eq1 (HLift t f) Source # 
Instance details

Defined in Data.HFunctor

Methods

liftEq :: (a -> b -> Bool) -> HLift t f a -> HLift t f b -> Bool #

(Ord1 (t f), Ord1 f) => Ord1 (HLift t f) Source # 
Instance details

Defined in Data.HFunctor

Methods

liftCompare :: (a -> b -> Ordering) -> HLift t f a -> HLift t f b -> Ordering #

(Show1 (t f), Show1 f) => Show1 (HLift t f) Source # 
Instance details

Defined in Data.HFunctor

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> HLift t f a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [HLift t f a] -> ShowS #

(Eq (f a), Eq (t f a)) => Eq (HLift t f a) Source # 
Instance details

Defined in Data.HFunctor

Methods

(==) :: HLift t f a -> HLift t f a -> Bool #

(/=) :: HLift t f a -> HLift t f a -> Bool #

(Ord (f a), Ord (t f a)) => Ord (HLift t f a) Source # 
Instance details

Defined in Data.HFunctor

Methods

compare :: HLift t f a -> HLift t f a -> Ordering #

(<) :: HLift t f a -> HLift t f a -> Bool #

(<=) :: HLift t f a -> HLift t f a -> Bool #

(>) :: HLift t f a -> HLift t f a -> Bool #

(>=) :: HLift t f a -> HLift t f a -> Bool #

max :: HLift t f a -> HLift t f a -> HLift t f a #

min :: HLift t f a -> HLift t f a -> HLift t f a #

(Read (f a), Read (t f a)) => Read (HLift t f a) Source # 
Instance details

Defined in Data.HFunctor

Methods

readsPrec :: Int -> ReadS (HLift t f a) #

readList :: ReadS [HLift t f a] #

readPrec :: ReadPrec (HLift t f a) #

readListPrec :: ReadPrec [HLift t f a] #

(Show (f a), Show (t f a)) => Show (HLift t f a) Source # 
Instance details

Defined in Data.HFunctor

Methods

showsPrec :: Int -> HLift t f a -> ShowS #

show :: HLift t f a -> String #

showList :: [HLift t f a] -> ShowS #

type C (HLift t) Source # 
Instance details

Defined in Data.HFunctor.Interpret

type C (HLift t) = C t

retractHLift :: Inject t => HLift t f a -> t f a Source #

A higher-level retract to get a t f a back out of an HLift t f a, provided t is an instance of Inject.

This witnesses the fact that HLift is the "Free Inject".

data HFree t f a Source #

An "HFunctor combinator" that turns an HFunctor into potentially infinite nestings of that HFunctor.

An HFree t f a is either f a, t f a, t (t f) a, t (t (t f)) a, etc.

This effectively turns t into a tree with t branches.

One particularly useful usage is with MapF. For example if you had a data type representing a command line command parser:

data Command a

You could represent "many possible named commands" using

type Commands = MapF String Command

And you can represent multiple nested named commands using:

type NestedCommands = HFree (MapF String)

This has an Interpret instance, but it can be more useful to use via direct pattern matching, or through

foldHFree
    :: HBifunctor t
    => f ~> g
    -> t g ~> g
    -> HFree t f ~> g

which requires no extra constriant on g, and lets you consider each branch separately.

This can be considered the higher-oder analogue of Free; it is the free HBind for any HFunctor t.

Note that HFree IdentityT is equivalent to Step.

Constructors

HReturn (f a) 
HJoin (t (HFree t f) a) 
Instances
HFunctor t => HFunctor (HFree t :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Data.HFunctor

Methods

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

HFunctor t => HBind (HFree t :: (k -> Type) -> k -> Type) Source #

HFree is the "free HBind" for any HFunctor

Instance details

Defined in Data.HFunctor

Methods

hbind :: (f ~> HFree t g) -> HFree t f ~> HFree t g Source #

hjoin :: HFree t (HFree t f) ~> HFree t f Source #

HFunctor t => Inject (HFree t :: (k -> Type) -> k -> Type) Source #

HFree is the "free HBind and Inject" for any HFunctor

Instance details

Defined in Data.HFunctor

Methods

inject :: f ~> HFree t f Source #

Interpret t => Interpret (HFree t) Source #

Never uses inject

Instance details

Defined in Data.HFunctor.Interpret

Associated Types

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

Methods

retract :: C (HFree t) f => HFree t f ~> f Source #

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

(Functor f, Functor (t (HFree t f))) => Functor (HFree t f) Source # 
Instance details

Defined in Data.HFunctor

Methods

fmap :: (a -> b) -> HFree t f a -> HFree t f b #

(<$) :: a -> HFree t f b -> HFree t f a #

(Show1 (t (HFree t f)), Show1 f) => Show1 (HFree t f) Source # 
Instance details

Defined in Data.HFunctor

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> HFree t f a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [HFree t f a] -> ShowS #

(Show1 (t (HFree t f)), Show1 f, Show a) => Show (HFree t f a) Source # 
Instance details

Defined in Data.HFunctor

Methods

showsPrec :: Int -> HFree t f a -> ShowS #

show :: HFree t f a -> String #

showList :: [HFree t f a] -> ShowS #

type C (HFree t) Source # 
Instance details

Defined in Data.HFunctor.Interpret

type C (HFree t) = C t

foldHFree :: forall t f g. HFunctor t => (f ~> g) -> (t g ~> g) -> HFree t f ~> g Source #

Recursively fold down an HFree into a single g result, by handling each branch. Can be more useful than interpret because it allows you to treat each branch separately, and also does not require any constraint on g.

This is the catamorphism on HFree.

retractHFree :: HBind t => HFree t f a -> t f a Source #

A higher-level retract to get a t f a back out of an HFree t f a, provided t is an instance of Bind.

This witnesses the fact that HFree is the "Free Bind".