free-4.4: Monads for free

PortabilityGADTs, Rank2Types
Stabilityprovisional
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellNone

Control.Alternative.Free

Description

Left distributive Alternative functors for free, based on a design by Stijn van Drongelen.

Synopsis

Documentation

data Alt f a whereSource

The free Alternative for a Functor f.

Constructors

Pure :: a -> Alt f a 
Ap :: f a -> Alt f (a -> b) -> Alt f b 
Alt :: [Alt f a] -> Alt f a 

Instances

Functor (Alt f) 
Typeable1 f => Typeable1 (Alt f) 
Applicative (Alt f) 
Alternative (Alt f) 
Apply (Alt f) 
Monoid (Alt f a) 
Semigroup (Alt f a) 

runAlt :: Alternative g => (forall x. f x -> g x) -> Alt f a -> g aSource

Given a natural transformation from f to g, this gives a canonical monoidal natural transformation from Alt f to g.

liftAlt :: f a -> Alt f aSource

A version of lift that can be used with just a Functor for f.

hoistAlt :: (forall a. f a -> g a) -> Alt f b -> Alt g bSource

Given a natural transformation from f to g this gives a monoidal natural transformation from Alt f to Alt g.