free-alternative-other
Safe HaskellNone
LanguageHaskell2010

Control.Alternative.Free.Lawless

Description

Free Alternative (with no laws beyond monoidal).

Free Alternative but assumes no laws relating Applicative structure and Alternative methods, just inherited Applicative laws and (empty, <|>) being monoid.

Synopsis

Type definitions

data Free (f :: Type -> Type) a Source #

Constructors

FreeLift (f a) 
FreeSumOf' (NotOne (Summand f a)) 
FreeApOf' (Ap' (Factor f) a) 

Bundled Patterns

pattern SumOf :: [Summand f a] -> Free f a

View as a list of Summands

pattern ApOf :: Functor f => Ap (Factor f) a -> Free f a

View as a Ap, formal chain of *, of Factors.

Instances

Instances details
FFunctor Free Source # 
Instance details

Defined in Control.Alternative.Free.Lawless

Methods

ffmap :: forall (g :: Type -> Type) (h :: Type -> Type) x. (Functor g, Functor h) => (g ~> h) -> Free g x -> Free h x #

FMonad Free Source # 
Instance details

Defined in Control.Alternative.Free.Lawless

Methods

fpure :: forall (g :: Type -> Type). Functor g => g ~> Free g #

fbind :: forall (g :: Type -> Type) (h :: Type -> Type) a. (Functor g, Functor h) => (g ~> Free h) -> Free g a -> Free h a #

Functor f => Alternative (Free f) Source # 
Instance details

Defined in Control.Alternative.Free.Lawless

Methods

empty :: Free f a #

(<|>) :: Free f a -> Free f a -> Free f a #

some :: Free f a -> Free f [a] #

many :: Free f a -> Free f [a] #

Functor f => Applicative (Free f) Source # 
Instance details

Defined in Control.Alternative.Free.Lawless

Methods

pure :: a -> Free f a #

(<*>) :: Free f (a -> b) -> Free f a -> Free f b #

liftA2 :: (a -> b -> c) -> Free f a -> Free f b -> Free f c #

(*>) :: Free f a -> Free f b -> Free f b #

(<*) :: Free f a -> Free f b -> Free f a #

Functor f => Functor (Free f) Source # 
Instance details

Defined in Control.Alternative.Free.Lawless

Methods

fmap :: (a -> b) -> Free f a -> Free f b #

(<$) :: a -> Free f b -> Free f a #

newtype Factor (f :: Type -> Type) a Source #

Subexpressions of Free f a which cannot be written as nontrivial apply x <*> y.

Constructors

Factor 

Fields

Instances

Instances details
FFunctor Factor Source # 
Instance details

Defined in Control.Alternative.Free.Lawless

Methods

ffmap :: forall (g :: Type -> Type) (h :: Type -> Type) x. (Functor g, Functor h) => (g ~> h) -> Factor g x -> Factor h x #

Functor f => Functor (Factor f) Source # 
Instance details

Defined in Control.Alternative.Free.Lawless

Methods

fmap :: (a -> b) -> Factor f a -> Factor f b #

(<$) :: a -> Factor f b -> Factor f a #

newtype Summand (f :: Type -> Type) a Source #

Subexpressions of Free f a which cannot be written as nontrivial sum x <|> y.

Constructors

Summand 

Fields

Instances

Instances details
FFunctor Summand Source # 
Instance details

Defined in Control.Alternative.Free.Lawless

Methods

ffmap :: forall (g :: Type -> Type) (h :: Type -> Type) x. (Functor g, Functor h) => (g ~> h) -> Summand g x -> Summand h x #

Functor f => Functor (Summand f) Source # 
Instance details

Defined in Control.Alternative.Free.Lawless

Methods

fmap :: (a -> b) -> Summand f a -> Summand f b #

(<$) :: a -> Summand f b -> Summand f a #

viewAp :: forall (f :: Type -> Type) a. Free f a -> Ap (Factor f) a Source #

reviewAp :: forall (f :: Type -> Type) a. Functor f => Ap (Factor f) a -> Free f a Source #

viewSum :: forall (f :: Type -> Type) a. Free f a -> [Summand f a] Source #

reviewSum :: forall (f :: Type -> Type) a. [Summand f a] -> Free f a Source #

Universal property

liftFree :: f a -> Free f a Source #

hoistFree :: (forall x. f x -> g x) -> Free f a -> Free g a Source #

foldFree :: forall f g a. Alternative g => (forall x. f x -> g x) -> Free f a -> g a Source #

Auxiliary types

data Ap' (f :: Type -> Type) a where Source #

Free Applicative Ap f a but liftAp fa, is excluded.

Ap f a uses zero or more values of f _, but Ap' f a uses either none (Pure') or 2+ times (ApMany').

Constructors

Pure' :: forall a (f :: Type -> Type). a -> Ap' f a 
ApMany' :: forall (f :: Type -> Type) a1 b a. f a1 -> f b -> Ap f (b -> a1 -> a) -> Ap' f a 

Instances

Instances details
FFunctor Ap' Source # 
Instance details

Defined in Control.Alternative.Free.Lawless

Methods

ffmap :: forall (g :: Type -> Type) (h :: Type -> Type) x. (Functor g, Functor h) => (g ~> h) -> Ap' g x -> Ap' h x #

Functor f => Functor (Ap' f) Source # 
Instance details

Defined in Control.Alternative.Free.Lawless

Methods

fmap :: (a -> b) -> Ap' f a -> Ap' f b #

(<$) :: a -> Ap' f b -> Ap' f a #

toAp :: forall (f :: Type -> Type) a. Ap' f a -> Ap f a Source #

notOneAp :: Functor f => Ap f a -> Either (f a) (Ap' f a) Source #