ap-normalize-0.1.0.1: Self-normalizing applicative expressions

Safe Haskell | Safe-Inferred
Language | Haskell2010

ApNormalize.Aps

Contents

- Normalizing applicative functors

Description

The definition of `Aps`. Most of this is reexported by ApNormalize.

Synopsis

- data Aps (f :: Type -> Type) a where
  - Pure :: forall a (f :: Type -> Type). a -> Aps f a
  - FmapLift :: forall x a (f :: Type -> Type). (x -> a) -> f x -> Aps f a
  - LiftA2Aps :: forall x y z a (f :: Type -> Type). (x -> y -> z -> a) -> f x -> f y -> ApDList f z -> Aps f a
- (<$>^) :: (a -> b) -> f a -> Aps f b
- (<*>^) :: Applicative f => Aps f (a -> b) -> f a -> Aps f b
- liftAps :: f a -> Aps f a
- lowerAps :: Applicative f => Aps f a -> f a
- liftA2Aps :: Applicative f => (a -> b -> c) -> f a -> Aps f b -> Aps f c
- apsToApDList :: forall (f :: Type -> Type) a. Applicative f => Aps f a -> ApDList f a

# Normalizing applicative functors

data Aps (f :: Type -> Type) a where Source #

An applicative functor transformer which accumulates `f`-actions (things of type `f x`) in a normal form.

It constructs a value of type `f a` with the following syntactic invariant. It depends on the number of `f`-actions `a1 ... an` composing it, which are delimited using `liftAps`:

- Zero action: `pure x`
- One action: `f <$> a1`
- Two or more actions: `liftA2 f a1 a2 <*> a3 <*> ... <*> an`

Constructors

Pure :: forall a (f :: Type -> Type). a -> Aps f a |
FmapLift :: forall x a (f :: Type -> Type). (x -> a) -> f x -> Aps f a |
LiftA2Aps :: forall x y z a (f :: Type -> Type). (x -> y -> z -> a) -> f x -> f y -> ApDList f z -> Aps f a |

#### Instances

Instances details

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

(<$>^) :: (a -> b) -> f a -> Aps f b infixl 4 Source #

`f <$>^ u :: Aps f b` is a delayed representation of `f <$> u :: f b`, so that it can be fused with other applicative operations.

`f <$>^ u` is a shorthand for `f <$> `liftAps` u`.

(<*>^) :: Applicative f => Aps f (a -> b) -> f a -> Aps f b infixl 4 Source #

`u <*>^ v` appends an `f`-action `v` to the right of an `(`Aps` f)`-action `u`.

`u <*>^ v` is a shorthand for `u <*> `liftAps` v`.

liftAps :: f a -> Aps f a Source #

Lift an `f`-action into ``Aps` f`.

lowerAps :: Applicative f => Aps f a -> f a Source #

Lower an `f`-action from ``Aps` f`.

liftA2Aps :: Applicative f => (a -> b -> c) -> f a -> Aps f b -> Aps f c Source #

Append an action to the left of an `Aps`.

apsToApDList :: forall (f :: Type -> Type) a. Applicative f => Aps f a -> ApDList f a Source #

Conversion from `Aps` to `ApDList`.