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 Fieldsalternatives :: [AltF f a]

Instances

 Functor f => Functor (Alt f) # Methodsfmap :: (a -> b) -> Alt f a -> Alt f b #(<$) :: a -> Alt f b -> Alt f a # Functor f => Applicative (Alt f) # Methodspure :: a -> Alt f a #(<*>) :: Alt f (a -> b) -> Alt f a -> Alt f b #(*>) :: Alt f a -> Alt f b -> Alt f b #(<*) :: Alt f a -> Alt f b -> Alt f a # Functor f => Alternative (Alt f) # Methodsempty :: Alt f a #(<|>) :: Alt f a -> Alt f a -> Alt f a #some :: Alt f a -> Alt f [a] #many :: Alt f a -> Alt f [a] # Functor f => Alt (Alt f) # Methods() :: Alt f a -> Alt f a -> Alt f a #some :: Applicative (Alt f) => Alt f a -> Alt f [a] #many :: Applicative (Alt f) => Alt f a -> Alt f [a] # Functor f => Apply (Alt f) # Methods(<.>) :: Alt f (a -> b) -> Alt f a -> Alt f b #(.>) :: Alt f a -> Alt f b -> Alt f b #(<.) :: Alt f a -> Alt f b -> Alt f a # Functor f => Semigroup (Alt f a) # Methods(<>) :: Alt f a -> Alt f a -> Alt f a #sconcat :: NonEmpty (Alt f a) -> Alt f a #stimes :: Integral b => b -> Alt f a -> Alt f a # Functor f => Monoid (Alt f a) # Methodsmempty :: Alt f a #mappend :: Alt f a -> Alt f a -> Alt f a #mconcat :: [Alt f a] -> Alt f a # 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) # Methodsfmap :: (a -> b) -> AltF f a -> AltF f b #(<$) :: a -> AltF f b -> AltF f a # Functor f => Applicative (AltF f) # Methodspure :: a -> AltF f a #(<*>) :: AltF f (a -> b) -> AltF f a -> AltF f b #(*>) :: AltF f a -> AltF f b -> AltF f b #(<*) :: AltF f a -> AltF f b -> AltF f a #

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.