HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Modulesemigroupoids-6.0.2Haskell2010

Data.Semigroup.Traversable

  • 1 class
  • 4 values
classclass (Foldable1 t, Traversable t) => Traversable1 (t :: Type -> Type) where
#

Methods

Instances30Traversable1, …

Defining Traversable1 instances

3 declarations

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
valuegtraverse1
  1. :: (Traversable1 (Rep1 t), Apply f, Generic1 t)
  2. => a -> f b
  3. -> t a
  4. -> 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

Default superclass instance helpers

1 declaration