Community
Modules 26

Data.Semigroup.Traversable

provisional

class (Foldable1 t, Traversable t) => Traversable1 t

traverse1 :: Apply f => (a -> f b) -> t a -> f (t b)

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)

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)

Generic traverse1. Caveats:

  1. Will not compile if t is an empty constructor.

  2. Will not compile if t has some fields that don't mention a, for example data Bar a = MkBar a Int

gsequence1 :: (Traversable1 (Rep1 t), Apply f, Generic1 t) => t (f b) -> f (t b)

Generic sequence1. Caveats are the same for gtraverse1.

Default superclass instance helpers

foldMap1Default :: (Traversable1 f, Semigroup m) => (a -> m) -> f a -> m

Default implementation of foldMap1 given an implementation of Traversable1.

Maintainer
Edward Kmett <ekmett@gmail.com>
Portability
portable
Copyright
(C) 2011-2015 Edward Kmett
License
BSD-style (see the file LICENSE)
Build record and source files

Community contribution. The service has not verified this documentation.

Target: Linux on x86-64. Some inferred types and resolved links are not available.

Generator: aihc-haddock-858b1951-web-1

Metadata snapshot: 4ac4693dc44e2bb370a93502d1bf29784374032a00ad7b3d02803e3d433c0b16

Open the dependency plan · Download the documentation model

Import a package

Enter a package name and an exact version from Hackage. The site contains imported versions only.