Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Implements higher-ranked equivalents of Functor
, Monad
, Foldable
and
Traversable
.
- class HFunctor (h :: (u -> *) -> u -> *) where
- class HPointed h where
- class HBind h where
- class (HFunctor h, HPointed h, HBind h) => HMonad h
- hliftM :: (HPointed h, HBind h) => (forall b. t b -> t' b) -> h t a -> h t' a
- hjoin :: HBind h => h (h t) a -> h t a
- class HFunctor h => HTraversable h where
- hfoldMapMonoid :: (HTraversable h, Monoid m) => (forall b. t b -> m) -> h t a -> m
- hbindTraverse :: (HTraversable h, HMonad h, Applicative f) => (forall b. t b -> f (h t' b)) -> h t a -> f (h t' a)
- class HBifunctor (h :: (k -> *) -> (k -> *) -> k -> *) where
- class HBifunctor h => HBitraversable h where
- hbifoldMapMonoid :: (Monoid m, HBitraversable h) => (forall b. s b -> m) -> (forall b. t b -> m) -> h s t a -> m
- class HDuofunctor (h :: ((u -> *) -> u -> *) -> (u -> *) -> u -> *) where
- hduomapFirst :: HDuofunctor h => (forall g g' b. (forall c. g c -> g' c) -> s g b -> s' g' b) -> h s t a -> h s' t a
- hduomapFirst' :: (HDuofunctor h, HFunctor s) => (forall g b. s g b -> s' g b) -> h s t a -> h s' t a
- hduomapSecond :: (HDuofunctor h, HFunctor s) => (forall b. t b -> t' b) -> h s t a -> h s t' a
- class HDuofunctor h => HDuotraversable h where
- hduotraverseFirst :: (HDuotraversable h, Applicative f) => (forall g g' b. (forall c. g c -> f (g' c)) -> s g b -> f (s' g' b)) -> h s t a -> f (h s' t a)
- hduotraverseFirst' :: (HDuotraversable h, HTraversable s, Monad f) => (forall g b. s g b -> f (s' g b)) -> h s t a -> f (h s' t a)
- hduotraverseSecond :: (HDuotraversable h, HTraversable s, Applicative f) => (forall b. t b -> f (t' b)) -> h s t a -> f (h s t' a)
- class HFoldableAt k h where
- implHfoldMap :: HFunctor h => (h k a -> k a) -> (forall b. t b -> k b) -> h t a -> k a
- implHfoldMapCompose :: (HTraversable h, Monad m) => (h k a -> m (k a)) -> (forall b. t b -> Compose m k b) -> h t a -> Compose m k a
- hfold :: HFoldableAt t h => h t a -> t a
- hfoldA :: (HFoldableAt (Compose f t) h, Applicative f) => h t a -> f (t a)
- hfoldMapA :: (HFoldableAt (Compose f k) h, Applicative f) => (forall b. t b -> f (k b)) -> h t a -> f (k a)
- hfoldTraverse :: (HFoldableAt k h, HTraversable h, Applicative f) => (forall b. t b -> f (k b)) -> h t a -> f (k a)
- class HBifoldableAt k h where
- hbifold :: HBifoldableAt k h => h k k a -> k a
- class HDuofoldableAt k h where
- implHduofoldMap :: (HDuofunctor h, HFunctor s) => ((forall g b. (forall c. g c -> k c) -> s g b -> k b) -> h s k a -> k a) -> (forall g b. (forall c. g c -> k c) -> s g b -> k b) -> (forall b. t b -> k b) -> h s t a -> k a
- implHduofoldMapCompose :: (HDuotraversable h, HTraversable s, Monad m) => ((forall g b. (forall c. g c -> m (k c)) -> s g b -> m (k b)) -> h s k a -> m (k a)) -> (forall g b. (forall c. g c -> Compose m k c) -> s g b -> Compose m k b) -> (forall b. t b -> Compose m k b) -> h s t a -> Compose m k a
- data HFree h t a
Documentation
class HFunctor (h :: (u -> *) -> u -> *) where Source #
Higher-ranked analogue of Functor
.
hmap :: (forall b. t b -> t' b) -> h t a -> h t' a Source #
Higher-ranked analogue of fmap
. Has a default implementation in terms of
htraverse
for
.HTraversable
h
hmap :: HTraversable h => (forall b. t b -> t' b) -> h t a -> h t' a Source #
Higher-ranked analogue of fmap
. Has a default implementation in terms of
htraverse
for
.HTraversable
h
(HFunctor * op, HFunctor * (OpChoice ops)) => HFunctor * (OpChoice ((:) ((* -> *) -> * -> *) op ops)) Source # | |
HFunctor * (OpChoice ([] ((* -> *) -> * -> *))) Source # | |
HFunctor * (OpChoice ops) => HFunctor * (HFree' ops) Source # | |
HFunctor u (Reverse u) Source # | |
HFunctor u (ReaderT u r) Source # | |
HFunctor u (Sum u f) Source # | |
HFunctor u (Product u f) Source # | |
HFunctor u h => HFunctor u (HFree u h) Source # | |
HFunctor u (BV u g) Source # | |
HDuofunctor u h => HFunctor u (SFree u h) Source # | |
Functor f => HFunctor u (Compose * u f) Source # | |
HFunctor u h => HFunctor u (Scope u g h) Source # | |
HFunctor u h => HFunctor u (Scoped u h f) Source # | |
HFunctor u (GeneralOp u u op) Source # | |
HFunctor * SimpleOp Source # | |
HFunctor * LogicOp Source # | |
HFunctor * (ExceptT e) Source # | |
HFunctor * (StateT s) Source # | |
HFunctor * (StateT s) Source # | |
HFunctor * (WriterT w) Source # | |
HFunctor * (WriterT w) Source # | |
class HPointed h where Source #
Half of the higher-ranked analogue of Monad
.
HPointed * (HFree' ops) Source # | |
HPointed k (Reverse k) Source # | |
HPointed k (ReaderT k r) Source # | |
HPointed k (Sum k f) Source # | |
HPointed k (HFree k h) Source # | |
HPointed k (BV k g) Source # | |
HPointed k (SFree k h) Source # | |
Applicative f => HPointed k (Compose * k f) Source # | |
HPointed k h => HPointed k (Scope k g h) Source # | |
Half of the higher-ranked analogue of Monad
.
(^>>=) :: h t a -> (forall b. t b -> h t' b) -> h t' a infixr 1 Source #
Higher-ranked analogue of >>=
.
HFunctor * (OpChoice ops) => HBind * (HFree' ops) Source # | |
HBind k (Reverse k) Source # | |
HBind k (ReaderT k r) Source # | |
HBind k (Sum k f) Source # | |
HFunctor k h => HBind k (HFree k h) Source # | |
HBind k (BV k g) Source # | |
HDuofunctor k h => HBind k (SFree k h) Source # | |
Monad f => HBind k (Compose * k f) Source # | |
class (HFunctor h, HPointed h, HBind h) => HMonad h Source #
Higher-ranked analogue of Monad
.
NB there's no such thing as HApplicative
for a reason. Consider f :: h t a ->
h t' a -> h (
, i.e. the higher-ranked analogue of Product
t t') aliftA2 (,)
:: f a -> f b -> f (a, b)
. Unfortunately f
can't exist, because
pairs up values of the same type, and in our constructions, Product
h
potentially
contains values of many types; a
just happens to be the one at the top level.
There's no guarantee that the two structures will have the same types inside to
pair together.
class HFunctor h => HTraversable h where Source #
Higher-ranked analogue of Traversable
.
htraverse :: Applicative f => (forall b. t b -> f (t' b)) -> h t a -> f (h t' a) Source #
Higher-ranked analogue of traverse
.
hsequence :: Applicative f => h (Compose f t) a -> f (h t a) Source #
Higher-ranked analogue of sequenceA
.
(HTraversable * op, HTraversable * (OpChoice ops)) => HTraversable * (OpChoice ((:) ((* -> *) -> * -> *) op ops)) Source # | |
HTraversable * (OpChoice ([] ((* -> *) -> * -> *))) Source # | |
HTraversable * (OpChoice ops) => HTraversable * (HFree' ops) Source # | |
HTraversable u (Reverse u) Source # | |
HTraversable u (Sum u f) Source # | |
HTraversable u (Product u f) Source # | |
HTraversable u h => HTraversable u (HFree u h) Source # | |
HTraversable u (BV u g) Source # | |
HDuotraversable u h => HTraversable u (SFree u h) Source # | |
Traversable f => HTraversable u (Compose * u f) Source # | |
HTraversable u h => HTraversable u (Scope u g h) Source # | |
HTraversable u h => HTraversable u (Scoped u h f) Source # | |
HTraversable u (GeneralOp u u op) Source # | |
HTraversable * SimpleOp Source # | |
HTraversable * LogicOp Source # | |
hfoldMapMonoid :: (HTraversable h, Monoid m) => (forall b. t b -> m) -> h t a -> m Source #
An HTraversable
instance lets you do something similar to foldMap
. For
a more flexible operation, see hfoldMap
.
hbindTraverse :: (HTraversable h, HMonad h, Applicative f) => (forall b. t b -> f (h t' b)) -> h t a -> f (h t' a) Source #
class HBifunctor (h :: (k -> *) -> (k -> *) -> k -> *) where Source #
Higher-ranked analogue of Bifunctor
.
hbimap :: (forall b. s b -> s' b) -> (forall b. t b -> t' b) -> h s t a -> h s' t' a Source #
Higher-ranked analogue of bimap
.
hfirst :: (forall b. s b -> s' b) -> h s t a -> h s' t a Source #
hsecond :: (forall b. t b -> t' b) -> h s t a -> h s t' a Source #
hbimap :: HBitraversable h => (forall b. s b -> s' b) -> (forall b. t b -> t' b) -> h s t a -> h s' t' a Source #
Higher-ranked analogue of bimap
.
HBifunctor k (Sum k) Source # | |
HBifunctor k (Product k) Source # | |
HBifunctor k (BV k) Source # | |
HFunctor k h => HBifunctor k (Scoped k h) Source # | |
class HBifunctor h => HBitraversable h where Source #
hbitraverse :: Applicative f => (forall b. s b -> f (s' b)) -> (forall b. t b -> f (t' b)) -> h s t a -> f (h s' t' a) Source #
HBitraversable k (Sum k) Source # | |
HBitraversable k (Product k) Source # | |
HBitraversable k (BV k) Source # | |
HTraversable k h => HBitraversable k (Scoped k h) Source # | |
hbifoldMapMonoid :: (Monoid m, HBitraversable h) => (forall b. s b -> m) -> (forall b. t b -> m) -> h s t a -> m Source #
class HDuofunctor (h :: ((u -> *) -> u -> *) -> (u -> *) -> u -> *) where Source #
hduomap :: (forall g g' b. (forall c. g c -> g' c) -> s g b -> s' g' b) -> (forall b. t b -> t' b) -> h s t a -> h s' t' a Source #
hduomap :: HDuotraversable h => (forall g g' b. (forall c. g c -> g' c) -> s g b -> s' g' b) -> (forall b. t b -> t' b) -> h s t a -> h s' t' a Source #
HDuofunctor u (HFree u) Source # | |
HDuofunctor u (Scope u g) Source # | |
hduomapFirst :: HDuofunctor h => (forall g g' b. (forall c. g c -> g' c) -> s g b -> s' g' b) -> h s t a -> h s' t a Source #
hduomapFirst' :: (HDuofunctor h, HFunctor s) => (forall g b. s g b -> s' g b) -> h s t a -> h s' t a Source #
hduomapSecond :: (HDuofunctor h, HFunctor s) => (forall b. t b -> t' b) -> h s t a -> h s t' a Source #
class HDuofunctor h => HDuotraversable h where Source #
hduotraverse :: Applicative f => (forall g g' b. (forall c. g c -> f (g' c)) -> s g b -> f (s' g' b)) -> (forall b. t b -> f (t' b)) -> h s t a -> f (h s' t' a) Source #
HDuotraversable u (HFree u) Source # | |
HDuotraversable u (Scope u g) Source # | |
hduotraverseFirst :: (HDuotraversable h, Applicative f) => (forall g g' b. (forall c. g c -> f (g' c)) -> s g b -> f (s' g' b)) -> h s t a -> f (h s' t a) Source #
hduotraverseFirst' :: (HDuotraversable h, HTraversable s, Monad f) => (forall g b. s g b -> f (s' g b)) -> h s t a -> f (h s' t a) Source #
hduotraverseSecond :: (HDuotraversable h, HTraversable s, Applicative f) => (forall b. t b -> f (t' b)) -> h s t a -> f (h s t' a) Source #
class HFoldableAt k h where Source #
This is a more flexible, higher-ranked version of Foldable
. While Foldable
only allows you to fold into a Monoid
, HFoldable
allows you to fold into
some arbitrary type constructor k
. This means that the instance can take
advantage of additional structure inside k
and h
, to combine internal
results in different ways, rather than just the mappend
available to
foldMap
.
Notice that if you have
instance (Monoid
m) =>HFoldableAt
(Const
m) h
(HFoldableAt * k op, HFoldableAt * k (OpChoice ops)) => HFoldableAt * k (OpChoice ((:) ((* -> *) -> * -> *) op ops)) Source # | |
HFoldableAt * k (OpChoice ([] ((* -> *) -> * -> *))) Source # | |
(HFoldableAt * k (OpChoice ops), HFunctor * (OpChoice ops)) => HFoldableAt * k (HFree' ops) Source # | |
HFoldableAt k1 k2 (Reverse k1) Source # | |
HFoldableAt k1 k2 (Sum k1 k2) Source # | |
HFoldableAt k1 k2 h => HFoldableAt k1 k2 (HFree k1 h) Source # | |
(HDuotraversable k1 h, HDuofoldableAt k1 k2 h) => HFoldableAt k1 k2 (SFree k1 h) Source # | |
EvalOpAt k1 k2 op => HFoldableAt k1 k2 (GeneralOp k1 k1 op) Source # | |
HFoldableAt * Identity SimpleOp Source # | |
HFoldableAt * Identity LogicOp Source # | |
HFoldableAt * SBV SimpleOp Source # | |
HFoldableAt * SBV LogicOp Source # | |
Alternative k => HFoldableAt * k (Product * k) Source # | |
(Alternative g, Foldable f) => HFoldableAt * g (Compose * * f) Source # | e.g. |
implHfoldMap :: HFunctor h => (h k a -> k a) -> (forall b. t b -> k b) -> h t a -> k a Source #
implHfoldMapCompose :: (HTraversable h, Monad m) => (h k a -> m (k a)) -> (forall b. t b -> Compose m k b) -> h t a -> Compose m k a Source #
A helper function for implementing instances with the general form
. I.e. folding that requires a monadic
context of some kind.Monad
m => HFoldableAt
(Compose
m t) h
hfold :: HFoldableAt t h => h t a -> t a Source #
Higher-ranked equivalent of fold
.
hfoldA :: (HFoldableAt (Compose f t) h, Applicative f) => h t a -> f (t a) Source #
Fold in an applicative context.
hfoldMapA :: (HFoldableAt (Compose f k) h, Applicative f) => (forall b. t b -> f (k b)) -> h t a -> f (k a) Source #
Fold in an applicative context.
hfoldTraverse :: (HFoldableAt k h, HTraversable h, Applicative f) => (forall b. t b -> f (k b)) -> h t a -> f (k a) Source #
hfoldTraverse
is to hfoldMap
as htraverse
is to hmap
.
class HBifoldableAt k h where Source #
hbifoldMap :: (forall b. f b -> k b) -> (forall b. g b -> k b) -> h f g a -> k a Source #
HBifoldableAt k1 k2 (Sum k1) Source # | |
HBifoldableAt k1 k2 (BV k1) Source # | |
(HFunctor k1 h, HFoldableAt k1 k2 h) => HBifoldableAt k1 k2 (Scoped k1 h) Source # | |
Alternative k => HBifoldableAt * k (Product *) Source # | |
hbifold :: HBifoldableAt k h => h k k a -> k a Source #
class HDuofoldableAt k h where Source #
hduofoldMap :: HTraversable s => (forall g b. (forall c. g c -> k c) -> s g b -> k b) -> (forall b. t b -> k b) -> h s t a -> k a Source #
HDuofoldableAt u k (HFree u) Source # | |
HDuofoldableAt k1 k2 (Scope k1 k2) Source # | |
implHduofoldMap :: (HDuofunctor h, HFunctor s) => ((forall g b. (forall c. g c -> k c) -> s g b -> k b) -> h s k a -> k a) -> (forall g b. (forall c. g c -> k c) -> s g b -> k b) -> (forall b. t b -> k b) -> h s t a -> k a Source #
implHduofoldMapCompose :: (HDuotraversable h, HTraversable s, Monad m) => ((forall g b. (forall c. g c -> m (k c)) -> s g b -> m (k b)) -> h s k a -> m (k a)) -> (forall g b. (forall c. g c -> Compose m k c) -> s g b -> Compose m k b) -> (forall b. t b -> Compose m k b) -> h s t a -> Compose m k a Source #
is a higher-ranked free monad over the higher-ranked functor HFree
hh
.
That means that given
, we get HFunctor
h
for free.HMonad
(HFree
h)
HDuofoldableAt u k (HFree u) Source # | |
HFoldableAt k1 k2 h => HFoldableAt k1 k2 (HFree k1 h) Source # | |
Pretty2 k k op => Pretty2 k k (HFree k op) Source # | |
HDuotraversable u (HFree u) Source # | |
HDuofunctor u (HFree u) Source # | |
HTraversable u h => HTraversable u (HFree u h) Source # | |
HFunctor k h => HMonad k (HFree k h) Source # | |
HFunctor k h => HBind k (HFree k h) Source # | |
HPointed k (HFree k h) Source # | |
HFunctor u h => HFunctor u (HFree u h) Source # | |
Num (WhileExpr l AlgReal) # | |
IsString s => IsString (WhileExpr s AlgReal) # | |