free-4.12: 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.Final

Description

Final encoding of free Alternative functors.

Synopsis

Documentation

newtype Alt f a Source

The free Alternative for a Functor f.

Constructors

Alt 

Fields

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

Instances

Alternative (Alt f) 
Functor (Alt f) 
Applicative (Alt f) 
Alt (Alt f) 
Apply (Alt f) 
Monoid (Alt f a) 
Semigroup (Alt f a) 

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 :: f a -> Alt f a Source

A version of lift that can be used with 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.