HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulesemigroupoids-6.0.1Haskell2010

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 exmaple data Bar a = MkBar a Int

Default superclass instance helpers

1 declaration