free-4.12.2: Monads for free

Copyright(C) 2012 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityprovisional
PortabilityGADTs, Rank2Types
Safe HaskellSafe
LanguageHaskell2010

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

data AltF f a where Source

Constructors

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

Instances

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

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 a Source

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 b Source

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