Module

Data.Functor.Hoist

Package
purescript-hoist
Repository
paf31/purescript-hoist

#Hoist Source

type Hoist s t a b = a ~> b -> s ~> t

Hoist asserts that natural transformations between a and b can be hoisted to natural transformations between s and t.

Usefully, the types line up with several standard functions from the core libraries:

Control.Monad.Free.hoistFree :: forall f g. Hoist (Free f)     (Free g)     f g
Data.Coyoneda.hoistCoyoneda  :: forall f g. Hoist (Coyoneda f) (Coyoneda g) f g
Data.Yoneda.hoistYoneda      :: forall f g. Hoist (Yoneda f)   (Yoneda g)   f g

And from purescript-mmorph:

hoist :: forall f g t. MFunctor t => Hoist (t f) (t g) f g

These functions compose like lenses, allowing us to hoist natural transformations over small parts of a structure:

hoistFree ⇜ right ⇜ first
  :: forall f g x y
   . Hoist (Free (Coproduct x (Product f y))) (Free (Coproduct x (Product g y))) f g

#composeHoist Source

composeHoist :: forall f e d c b a. Hoist e f c d -> Hoist c d a b -> Hoist e f a b

Compose Hoisting functions.

This is provided to help with type inference.

#(⇜) Source

Operator alias for Data.Functor.Hoist.composeHoist (right-associative / precedence 8)

#first Source

first :: forall h g f. Hoist (Product f h) (Product g h) f g

Hoist over the first component of a functor product.

#second Source

second :: forall h g f. Hoist (Product h f) (Product h g) f g

Hoist over the second component of a functor product.

#left Source

left :: forall h g f. Hoist (Coproduct f h) (Coproduct g h) f g

Hoist over the first component of a functor coproduct.

#right Source

right :: forall h g f. Hoist (Coproduct h f) (Coproduct h g) f g

Hoist over the second component of a functor coproduct.

#precomposed Source

precomposed :: forall h g f. Functor h => Hoist (Compose h f) (Compose h g) f g

Hoist over the inner function in a composition.

#composed Source

composed :: forall h g f. Hoist (Compose f h) (Compose g h) f g

Hoist over the outer function in a composition.