free-functors-1.0: Free functors, adjoint to functors that forget class constraints.

Safe HaskellNone
LanguageHaskell2010

Data.Functor.Free.Internal

Synopsis

Documentation

newtype Free c a Source #

The free functor for class c.

Free c a is basically an expression tree with operations from class c and variables/placeholders of type a, created with unit. Monadic bind allows you to replace each of these variables with another sub-expression.

Constructors

Free 

Fields

  • runFree :: forall b. c b => (a -> b) -> b
     
Instances
(forall x. c x => Class' f x) => Algebra f (Free c a) Source # 
Instance details

Defined in Data.Functor.Free.Internal

Methods

algebra :: f (Free c a) -> Free c a #

Monad (Free c) Source # 
Instance details

Defined in Data.Functor.Free.Internal

Methods

(>>=) :: Free c a -> (a -> Free c b) -> Free c b #

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

return :: a -> Free c a #

fail :: String -> Free c a #

Functor (Free c) Source # 
Instance details

Defined in Data.Functor.Free.Internal

Methods

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

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

Applicative (Free c) Source # 
Instance details

Defined in Data.Functor.Free.Internal

Methods

pure :: a -> Free c a #

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

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

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

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

(forall (f :: Type -> Type) x. Applicative f => c (LiftAFree c f x)) => Foldable (Free c) Source # 
Instance details

Defined in Data.Functor.Free.Internal

Methods

fold :: Monoid m => Free c m -> m #

foldMap :: Monoid m => (a -> m) -> Free c a -> m #

foldr :: (a -> b -> b) -> b -> Free c a -> b #

foldr' :: (a -> b -> b) -> b -> Free c a -> b #

foldl :: (b -> a -> b) -> b -> Free c a -> b #

foldl' :: (b -> a -> b) -> b -> Free c a -> b #

foldr1 :: (a -> a -> a) -> Free c a -> a #

foldl1 :: (a -> a -> a) -> Free c a -> a #

toList :: Free c a -> [a] #

null :: Free c a -> Bool #

length :: Free c a -> Int #

elem :: Eq a => a -> Free c a -> Bool #

maximum :: Ord a => Free c a -> a #

minimum :: Ord a => Free c a -> a #

sum :: Num a => Free c a -> a #

product :: Num a => Free c a -> a #

(forall (f :: Type -> Type) x. Applicative f => c (LiftAFree c f x)) => Traversable (Free c) Source # 
Instance details

Defined in Data.Functor.Free.Internal

Methods

traverse :: Applicative f => (a -> f b) -> Free c a -> f (Free c b) #

sequenceA :: Applicative f => Free c (f a) -> f (Free c a) #

mapM :: Monad m => (a -> m b) -> Free c a -> m (Free c b) #

sequence :: Monad m => Free c (m a) -> m (Free c a) #

(forall x. c (Extract x), forall x. c (Duplicate (Free c) x)) => Comonad (Free c) Source # 
Instance details

Defined in Data.Functor.Free.Internal

Methods

extract :: Free c a -> a #

duplicate :: Free c a -> Free c (Free c a) #

extend :: (Free c a -> b) -> Free c a -> Free c b #

(forall x. c x :=> Floating x) => Floating (Free c a) Source # 
Instance details

Defined in Data.Functor.Free

Methods

pi :: Free c a #

exp :: Free c a -> Free c a #

log :: Free c a -> Free c a #

sqrt :: Free c a -> Free c a #

(**) :: Free c a -> Free c a -> Free c a #

logBase :: Free c a -> Free c a -> Free c a #

sin :: Free c a -> Free c a #

cos :: Free c a -> Free c a #

tan :: Free c a -> Free c a #

asin :: Free c a -> Free c a #

acos :: Free c a -> Free c a #

atan :: Free c a -> Free c a #

sinh :: Free c a -> Free c a #

cosh :: Free c a -> Free c a #

tanh :: Free c a -> Free c a #

asinh :: Free c a -> Free c a #

acosh :: Free c a -> Free c a #

atanh :: Free c a -> Free c a #

log1p :: Free c a -> Free c a #

expm1 :: Free c a -> Free c a #

log1pexp :: Free c a -> Free c a #

log1mexp :: Free c a -> Free c a #

(forall x. c x :=> Fractional x) => Fractional (Free c a) Source # 
Instance details

Defined in Data.Functor.Free

Methods

(/) :: Free c a -> Free c a -> Free c a #

recip :: Free c a -> Free c a #

fromRational :: Rational -> Free c a #

(forall x. c x :=> Num x) => Num (Free c a) Source # 
Instance details

Defined in Data.Functor.Free

Methods

(+) :: Free c a -> Free c a -> Free c a #

(-) :: Free c a -> Free c a -> Free c a #

(*) :: Free c a -> Free c a -> Free c a #

negate :: Free c a -> Free c a #

abs :: Free c a -> Free c a #

signum :: Free c a -> Free c a #

fromInteger :: Integer -> Free c a #

(Show a, Show (Signature c (ShowHelper (Signature c) a)), c (ShowHelper (Signature c) a)) => Show (Free c a) Source # 
Instance details

Defined in Data.Functor.Free.Internal

Methods

showsPrec :: Int -> Free c a -> ShowS #

show :: Free c a -> String #

showList :: [Free c a] -> ShowS #

(forall x. c x :=> Semigroup x) => Semigroup (Free c a) Source # 
Instance details

Defined in Data.Functor.Free

Methods

(<>) :: Free c a -> Free c a -> Free c a #

sconcat :: NonEmpty (Free c a) -> Free c a #

stimes :: Integral b => b -> Free c a -> Free c a #

(forall x. c x :=> Monoid x) => Monoid (Free c a) Source # 
Instance details

Defined in Data.Functor.Free

Methods

mempty :: Free c a #

mappend :: Free c a -> Free c a -> Free c a #

mconcat :: [Free c a] -> Free c a #

unit :: a -> Free c a Source #

unit allows you to create Free c values, together with the operations from the class c.

rightAdjunct :: c b => (a -> b) -> Free c a -> b Source #

rightAdjunct is the destructor of Free c values.

counit :: c a => Free c a -> a Source #

counit = rightAdjunct id

leftAdjunct :: (Free c a -> b) -> a -> b Source #

leftAdjunct f = f . unit

transform :: (forall r. c r => (b -> r) -> a -> r) -> Free c a -> Free c b Source #

transform f as = as >>= f unit
transform f . transform g = transform (g . f)

newtype Extract a Source #

Constructors

Extract 

Fields

newtype Duplicate f a Source #

Constructors

Duplicate 

Fields

class Class f x => Class' f x where Source #

Methods

evaluate' :: AlgebraSignature f => f x -> x Source #

Instances
Class f x => Class' f x Source # 
Instance details

Defined in Data.Functor.Free.Internal

Methods

evaluate' :: f x -> x Source #

newtype LiftAFree c f a Source #

Constructors

LiftAFree 

Fields

Instances
(Applicative f, forall x. c x => Class' s x) => Algebra s (LiftAFree c f a) Source # 
Instance details

Defined in Data.Functor.Free.Internal

Methods

algebra :: s (LiftAFree c f a) -> LiftAFree c f a #

(Applicative f, forall x. c x :=> Floating x) => Floating (LiftAFree c f a) Source # 
Instance details

Defined in Data.Functor.Free

Methods

pi :: LiftAFree c f a #

exp :: LiftAFree c f a -> LiftAFree c f a #

log :: LiftAFree c f a -> LiftAFree c f a #

sqrt :: LiftAFree c f a -> LiftAFree c f a #

(**) :: LiftAFree c f a -> LiftAFree c f a -> LiftAFree c f a #

logBase :: LiftAFree c f a -> LiftAFree c f a -> LiftAFree c f a #

sin :: LiftAFree c f a -> LiftAFree c f a #

cos :: LiftAFree c f a -> LiftAFree c f a #

tan :: LiftAFree c f a -> LiftAFree c f a #

asin :: LiftAFree c f a -> LiftAFree c f a #

acos :: LiftAFree c f a -> LiftAFree c f a #

atan :: LiftAFree c f a -> LiftAFree c f a #

sinh :: LiftAFree c f a -> LiftAFree c f a #

cosh :: LiftAFree c f a -> LiftAFree c f a #

tanh :: LiftAFree c f a -> LiftAFree c f a #

asinh :: LiftAFree c f a -> LiftAFree c f a #

acosh :: LiftAFree c f a -> LiftAFree c f a #

atanh :: LiftAFree c f a -> LiftAFree c f a #

log1p :: LiftAFree c f a -> LiftAFree c f a #

expm1 :: LiftAFree c f a -> LiftAFree c f a #

log1pexp :: LiftAFree c f a -> LiftAFree c f a #

log1mexp :: LiftAFree c f a -> LiftAFree c f a #

(Applicative f, forall x. c x :=> Fractional x) => Fractional (LiftAFree c f a) Source # 
Instance details

Defined in Data.Functor.Free

Methods

(/) :: LiftAFree c f a -> LiftAFree c f a -> LiftAFree c f a #

recip :: LiftAFree c f a -> LiftAFree c f a #

fromRational :: Rational -> LiftAFree c f a #

(Applicative f, forall x. c x :=> Num x) => Num (LiftAFree c f a) Source # 
Instance details

Defined in Data.Functor.Free

Methods

(+) :: LiftAFree c f a -> LiftAFree c f a -> LiftAFree c f a #

(-) :: LiftAFree c f a -> LiftAFree c f a -> LiftAFree c f a #

(*) :: LiftAFree c f a -> LiftAFree c f a -> LiftAFree c f a #

negate :: LiftAFree c f a -> LiftAFree c f a #

abs :: LiftAFree c f a -> LiftAFree c f a #

signum :: LiftAFree c f a -> LiftAFree c f a #

fromInteger :: Integer -> LiftAFree c f a #

(Applicative f, forall x. c x :=> Semigroup x) => Semigroup (LiftAFree c f a) Source # 
Instance details

Defined in Data.Functor.Free

Methods

(<>) :: LiftAFree c f a -> LiftAFree c f a -> LiftAFree c f a #

sconcat :: NonEmpty (LiftAFree c f a) -> LiftAFree c f a #

stimes :: Integral b => b -> LiftAFree c f a -> LiftAFree c f a #

(Applicative f, forall x. c x :=> Monoid x) => Monoid (LiftAFree c f a) Source # 
Instance details

Defined in Data.Functor.Free

Methods

mempty :: LiftAFree c f a #

mappend :: LiftAFree c f a -> LiftAFree c f a -> LiftAFree c f a #

mconcat :: [LiftAFree c f a] -> LiftAFree c f a #

data ShowHelper f a Source #

Constructors

ShowUnit a 
ShowRec (f (ShowHelper f a)) 
Instances
Algebra f (ShowHelper f a) Source # 
Instance details

Defined in Data.Functor.Free.Internal

Methods

algebra :: f (ShowHelper f a) -> ShowHelper f a #

(Show a, Show (f (ShowHelper f a))) => Show (ShowHelper f a) Source # 
Instance details

Defined in Data.Functor.Free.Internal

Methods

showsPrec :: Int -> ShowHelper f a -> ShowS #

show :: ShowHelper f a -> String #

showList :: [ShowHelper f a] -> ShowS #

class a => b => a :=> b Source #

Instances
a -> b => a :=> b Source # 
Instance details

Defined in Data.Functor.Free.Internal

deriveInstances :: Name -> Q [Dec] Source #

Derive the instances of Free c a for the class c, Show, Foldable and Traversable.

For example:

deriveInstances ''Num