ap-normalize-0.1.0.1: Self-normalizing applicative expressions
Safe HaskellSafe-Inferred
LanguageHaskell2010

ApNormalize.DList

Description

This structure is part of the definition of Aps.

Synopsis

Applicative difference lists

newtype ApDList f 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
Functor (ApDList f) Source # 
Instance details

Defined in ApNormalize.DList

Methods

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

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

Applicative (ApDList f) Source # 
Instance details

Defined in ApNormalize.DList

Methods

pure :: a -> ApDList f a #

(<*>) :: ApDList f (a -> b) -> ApDList f a -> ApDList f b #

liftA2 :: (a -> b -> c) -> ApDList f a -> ApDList f b -> ApDList f c #

(*>) :: ApDList f a -> ApDList f b -> ApDList f b #

(<*) :: ApDList f a -> ApDList f b -> ApDList f a #

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 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 #

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