free-4.11: Monads for free

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

Constructors

Alt 

Fields

alternatives :: [AltF f a]
 

Instances

Functor f => Alternative (Alt f) 
Functor f => Functor (Alt f) 
Functor f => Applicative (Alt f) 
Functor f => Apply (Alt f) 
Functor f => Monoid (Alt f a) 
Functor f => Semigroup (Alt f a) 
Typeable ((* -> *) -> * -> *) Alt 

data AltF f a where

Constructors

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

Instances

Functor f => Functor (AltF f) 
Functor f => Applicative (AltF f) 
Typeable ((* -> *) -> * -> *) AltF 

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

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

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

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