free-4.8: 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

newtype Alt f a Source

Constructors

Alt 

Fields

alternatives :: [AltF f a]
 

Instances

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

data AltF f a whereSource

Constructors

Ap :: f a -> Alt f (a -> b) -> AltF f b 
Pure :: a -> AltF f a 

Instances

runAlt :: forall f g a. 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 :: Functor f => 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.