Copyright | (C) 2011-2015 Edward Kmett |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | provisional |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Synopsis
- class (Foldable1 t, Traversable t) => Traversable1 (t :: Type -> Type) where
- traverse1Maybe :: (Traversable t, Apply f) => (a -> f b) -> t a -> MaybeApply f (t b)
- gtraverse1 :: (Traversable1 (Rep1 t), Apply f, Generic1 t) => (a -> f b) -> t a -> f (t b)
- gsequence1 :: (Traversable1 (Rep1 t), Apply f, Generic1 t) => t (f b) -> f (t b)
- foldMap1Default :: (Traversable1 f, Semigroup m) => (a -> m) -> f a -> m
Documentation
class (Foldable1 t, Traversable t) => Traversable1 (t :: Type -> Type) where Source #
Instances
Defining Traversable1 instances
Defining Traversable1
instances for types with both Traversable1
and Traversable
substructures can be done with traverse1Maybe
, (<*.>)
, and (<.*>)
.
data Foo a = Foo (Maybe a) (Maybe a) a [a] deriving (Functor, Traversable, Foldable) instance Traversable1 Foo where traverse1 f (Foo ma ma' a as) = Foo <$> traverseMaybe ma <*> traverseMaybe ma' <*.> f a <.*> traverseMaybe as instance Foldable1 Foo where foldMap1 = foldMap1Default
traverse1Maybe :: (Traversable t, Apply f) => (a -> f b) -> t a -> MaybeApply f (t b) Source #
Traverse a Traversable
using Apply
, getting the results back in a MaybeApply
.
gtraverse1 :: (Traversable1 (Rep1 t), Apply f, Generic1 t) => (a -> f b) -> t a -> f (t b) Source #
Generic traverse1
. Caveats:
- Will not compile if
t
is an empty constructor. - Will not compile if
t
has some fields that don't mentiona
, for exmapledata Bar a = MkBar a Int
Since: 5.3.8
gsequence1 :: (Traversable1 (Rep1 t), Apply f, Generic1 t) => t (f b) -> f (t b) Source #
Generic sequence1
. Caveats are the same for gtraverse1
.
Since: 5.3.8
Default superclass instance helpers
foldMap1Default :: (Traversable1 f, Semigroup m) => (a -> m) -> f a -> m Source #
Default implementation of foldMap1
given an implementation of Traversable1
.