Copyright | (c) 2014 Justus Sagemüller |
---|---|
License | GPL v3 (see COPYING) |
Maintainer | (@) jsag $ hvl.no |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Data.Foldable.Constrained
Description
Synopsis
- class Functor t k l => Foldable (t :: Type -> Type) (k :: Type -> Type -> Type) (l :: Type -> Type -> Type) where
- ffoldl :: (ObjectPair k a b, ObjectPair l a (t b)) => k (a, b) a -> l (a, t b) a
- foldMap :: (Object k a, Object l (t a), Semigroup m, Monoid m, Object k m, Object l m) => k a m -> l (t a) m
- fold :: (Foldable t k k, Monoid m, Semigroup m, Object k m, Object k (t m)) => k (t m) m
- traverse_ :: forall t k l o f a b uk ul. (Foldable t k l, PreArrow k, PreArrow l, Monoidal f l l, Monoidal f k k, ObjectPair l (f ul) (t a), ObjectPair k (f ul) a, ObjectPair l ul (t a), ObjectPair l (t a) ul, ObjectPair k b ul, Object k (f b), ObjectPair k (f ul) (f ul), ObjectPair k ul ul, uk ~ UnitObject k, ul ~ UnitObject l, uk ~ ul) => k a (f b) -> l (t a) (f ul)
- mapM_ :: forall t k o f a b u. (Foldable t k k, WellPointed k, Monoidal f k k, u ~ UnitObject k, ObjectPair k (f u) (t a), ObjectPair k (f u) a, ObjectPair k u (t a), ObjectPair k (t a) u, ObjectPair k (f u) (f u), ObjectPair k u u, ObjectPair k b u, Object k (f b)) => k a (f b) -> k (t a) (f u)
- forM_ :: forall t k (l :: Type -> Type -> Type) f a b uk ul. (Foldable t k l, Monoidal f l l, Monoidal f k k, Function l, Arrow k (->), Arrow l (->), ul ~ UnitObject l, uk ~ UnitObject k, uk ~ ul, ObjectPair l ul ul, ObjectPair l (f ul) (f ul), ObjectPair l (f ul) (t a), ObjectPair l ul (t a), ObjectPair l (t a) ul, ObjectPair l (f ul) a, ObjectPair k b (f b), ObjectPair k b ul, ObjectPair k uk uk, ObjectPair k (f uk) a, ObjectPair k (f uk) (f uk)) => t a -> k a (f b) -> f uk
- sequence_ :: forall t (k :: Type -> Type -> Type) l m a b uk ul. (Foldable t k l, Arrow k (->), Arrow l (->), uk ~ UnitObject k, ul ~ UnitObject l, uk ~ ul, Monoidal m k k, Monoidal m l l, ObjectPair k a uk, ObjectPair k (t (m a)) uk, ObjectPair k uk uk, ObjectPair k (m uk) (m uk), ObjectPair k (t (m a)) ul, ObjectPair l (m ul) (t (m a)), ObjectPair l ul (t (m a)), ObjectPair l (m uk) (t (m a)), ObjectPair l (t (m a)) ul, ObjectPair k (m uk) (m a)) => l (t (m a)) (m uk)
- concatMap :: (Foldable f k l, Object k a, Object k [b], Object l (f a), Object l [b]) => k a [b] -> l (f a) [b]
Documentation
class Functor t k l => Foldable (t :: Type -> Type) (k :: Type -> Type -> Type) (l :: Type -> Type -> Type) where Source #
Foldable class, generalised to use arrows in categories other than ->
. This changes the interface
somewhat – in particular, foldr
relies on currying and hence can't really be expressed in
a category without exponential objects; however the monoidal folds come out quite nicely. (Of course,
it's debatable how much sense the Hask-Monoid
class even makes in other categories.)
Unlike with the Functor
classes, there is no derived instance
:
in this case, it would prevent some genarality.
See below for how to define such an instance manually.Foldable
f => Foldable
f (->) (->)
Methods
ffoldl :: (ObjectPair k a b, ObjectPair l a (t b)) => k (a, b) a -> l (a, t b) a Source #
foldMap :: (Object k a, Object l (t a), Semigroup m, Monoid m, Object k m, Object l m) => k a m -> l (t a) m Source #
traverse_ :: forall t k l o f a b uk ul. (Foldable t k l, PreArrow k, PreArrow l, Monoidal f l l, Monoidal f k k, ObjectPair l (f ul) (t a), ObjectPair k (f ul) a, ObjectPair l ul (t a), ObjectPair l (t a) ul, ObjectPair k b ul, Object k (f b), ObjectPair k (f ul) (f ul), ObjectPair k ul ul, uk ~ UnitObject k, ul ~ UnitObject l, uk ~ ul) => k a (f b) -> l (t a) (f ul) Source #
Despite the ridiculous-looking signature, this is in fact equivalent
to traverse_
within Hask.
mapM_ :: forall t k o f a b u. (Foldable t k k, WellPointed k, Monoidal f k k, u ~ UnitObject k, ObjectPair k (f u) (t a), ObjectPair k (f u) a, ObjectPair k u (t a), ObjectPair k (t a) u, ObjectPair k (f u) (f u), ObjectPair k u u, ObjectPair k b u, Object k (f b)) => k a (f b) -> k (t a) (f u) Source #
The distinction between mapM_
and traverse_
doesn't really make sense
on grounds of Monoidal
/ Applicative
vs Monad
, but it has in fact some
benefits to restrict this to endofunctors, to make the constraint list
at least somewhat shorter.
forM_ :: forall t k (l :: Type -> Type -> Type) f a b uk ul. (Foldable t k l, Monoidal f l l, Monoidal f k k, Function l, Arrow k (->), Arrow l (->), ul ~ UnitObject l, uk ~ UnitObject k, uk ~ ul, ObjectPair l ul ul, ObjectPair l (f ul) (f ul), ObjectPair l (f ul) (t a), ObjectPair l ul (t a), ObjectPair l (t a) ul, ObjectPair l (f ul) a, ObjectPair k b (f b), ObjectPair k b ul, ObjectPair k uk uk, ObjectPair k (f uk) a, ObjectPair k (f uk) (f uk)) => t a -> k a (f b) -> f uk Source #
sequence_ :: forall t (k :: Type -> Type -> Type) l m a b uk ul. (Foldable t k l, Arrow k (->), Arrow l (->), uk ~ UnitObject k, ul ~ UnitObject l, uk ~ ul, Monoidal m k k, Monoidal m l l, ObjectPair k a uk, ObjectPair k (t (m a)) uk, ObjectPair k uk uk, ObjectPair k (m uk) (m uk), ObjectPair k (t (m a)) ul, ObjectPair l (m ul) (t (m a)), ObjectPair l ul (t (m a)), ObjectPair l (m uk) (t (m a)), ObjectPair l (t (m a)) ul, ObjectPair k (m uk) (m a)) => l (t (m a)) (m uk) Source #