ap-normalize-0.1.0.1: Self-normalizing applicative expressions

Safe Haskell | Safe-Inferred
Language | Haskell2010

ApNormalize.DList

Contents

- Applicative difference lists

Description

This structure is part of the definition of `Aps`.

Synopsis

- newtype ApDList (f :: Type -> Type) a = ApDList (forall r. Yoneda f (a -> r) -> f r)
- liftApDList :: Applicative f => f a -> ApDList f a
- lowerApDList :: Yoneda f (b -> c) -> ApDList f b -> f c
- newtype Yoneda (f :: Type -> Type) a = Yoneda (forall x. (a -> x) -> f x)

# Applicative difference lists

newtype ApDList (f :: Type -> Type) a Source #

Type of applicative difference lists.

An applicative transformer which accumulates `f`-actions in a left-nested composition using `(`<*>`)`.

`ApDList` represents a sequence of `f`-actions `u1 :: f x1`, ... `un :: f xn` as "term with a hole" `(_ <*> u1 <*> ... <*> un) :: f r`.

That hole must have type `_ :: f (x1 -> ... -> un -> r)`; the variable number of arrows is hidden by existential quantification and continuation passing.

To help ensure that syntactic invariant, the `Functor` and `Applicative` instances for `ApDList` have no constraints. `liftApDList` is the only function whose signature requires an ``Applicative` f` constraint, wrapping each action `u` inside one `(`<*>`)`.

Constructors

ApDList (forall r. Yoneda f (a -> r) -> f r) |

#### Instances

Instances details

Applicative (ApDList f) Source # |
Instance details Defined in ApNormalize.DList Methods pure :: a -> ApDList f a Source # (<*>) :: ApDList f (a -> b) -> ApDList f a -> ApDList f b Source # liftA2 :: (a -> b -> c) -> ApDList f a -> ApDList f b -> ApDList f c Source # (*>) :: ApDList f a -> ApDList f b -> ApDList f b Source # (<*) :: ApDList f a -> ApDList f b -> ApDList f a Source #
Functor (ApDList f) Source # |
Instance details Defined in ApNormalize.DList Methods fmap :: (a -> b) -> ApDList f a -> ApDList f b Source # (<$) :: a -> ApDList f b -> ApDList f a Source #

liftApDList :: Applicative f => f a -> ApDList f a Source #

A difference list with one element `u`, denoted `_ <*> u`.

lowerApDList :: Yoneda f (b -> c) -> ApDList f b -> f c Source #

Complete a difference list, filling the hole with the first argument.

newtype Yoneda (f :: Type -> Type) a Source #

A delayed application of `fmap` which can be fused with an inner `fmap` or `liftA2`.

This is the same definition as in the kan-extensions library, but we redefine it to not pay for all the dependencies.

Constructors

Yoneda (forall x. (a -> x) -> f x) |

#### Instances

Instances details

Functor (Yoneda f) Source # |
Instance details Defined in ApNormalize.DList Methods fmap :: (a -> b) -> Yoneda f a -> Yoneda f b Source # (<$) :: a -> Yoneda f b -> Yoneda f a Source #