Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Free c a = Free {
- runFree :: forall b. c b => (a -> b) -> b
- unit :: a -> Free c a
- rightAdjunct :: c b => (a -> b) -> Free c a -> b
- counit :: c a => Free c a -> a
- leftAdjunct :: (Free c a -> b) -> a -> b
- transform :: (forall r. c r => (b -> r) -> a -> r) -> Free c a -> Free c b
- newtype Extract a = Extract {
- getExtract :: a
- newtype Duplicate f a = Duplicate {
- getDuplicate :: f (f a)
- class Class f x => Class' f x where
- evaluate' :: AlgebraSignature f => f x -> x
- newtype LiftAFree c f a = LiftAFree {
- getLiftAFree :: f (Free c a)
- data ShowHelper f a
- = ShowUnit a
- | ShowRec (f (ShowHelper f a))
- class a => b => a :=> b
- deriveInstances :: Name -> Q [Dec]
Documentation
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.
Instances
(forall x. c x => Class' f x) => Algebra f (Free c a) Source # | |
Defined in Data.Functor.Free.Internal | |
Monad (Free c) Source # | |
Functor (Free c) Source # | |
Applicative (Free c) Source # | |
(forall (f :: Type -> Type) x. Applicative f => c (LiftAFree c f x)) => Foldable (Free c) Source # | |
Defined in Data.Functor.Free.Internal 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 # elem :: Eq a => a -> Free c a -> Bool # maximum :: Ord a => Free c a -> a # minimum :: Ord a => Free c a -> a # | |
(forall (f :: Type -> Type) x. Applicative f => c (LiftAFree c f x)) => Traversable (Free c) Source # | |
(forall x. c (Extract x), forall x. c (Duplicate (Free c) x)) => Comonad (Free c) Source # | |
(forall x. c x :=> Floating x) => Floating (Free c a) Source # | |
Defined in Data.Functor.Free 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 # 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 # | |
(forall x. c x :=> Fractional x) => Fractional (Free c a) Source # | |
(forall x. c x :=> Num x) => Num (Free c a) Source # | |
(Show a, Show (Signature c (ShowHelper (Signature c) a)), c (ShowHelper (Signature c) a)) => Show (Free c a) Source # | |
(forall x. c x :=> Semigroup x) => Semigroup (Free c a) Source # | |
(forall x. c x :=> Monoid x) => Monoid (Free c a) Source # | |
rightAdjunct :: c b => (a -> b) -> Free c a -> b Source #
rightAdjunct
is the destructor of
values.Free
c
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)
Extract | |
|
newtype Duplicate f a Source #
Duplicate | |
|
newtype LiftAFree c f a Source #
LiftAFree | |
|
Instances
data ShowHelper f a Source #
ShowUnit a | |
ShowRec (f (ShowHelper f a)) |
Instances
Algebra f (ShowHelper f a) Source # | |
Defined in Data.Functor.Free.Internal algebra :: f (ShowHelper f a) -> ShowHelper f a # | |
(Show a, Show (f (ShowHelper f a))) => Show (ShowHelper f a) Source # | |
Defined in Data.Functor.Free.Internal 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 # | |
Defined in Data.Functor.Free.Internal |
deriveInstances :: Name -> Q [Dec] Source #
Derive the instances of
for the class Free
c ac
, Show
, Foldable
and Traversable
.
For example:
deriveInstances ''Num