Data.Semigroup.Traversable

semigroupoids-6.0.1: Semigroupoids: Category sans id

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

Data.Semigroup.Traversable

Contents

- Defining Traversable1 instances
- Default superclass instance helpers

Description

Synopsis

- class (Foldable1 t, Traversable t) => Traversable1 (t :: Type -> Type) where
  - traverse1 :: Apply f => (a -> f b) -> t a -> f (t b)
  - sequence1 :: Apply f => t (f b) -> f (t b)
- 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 #

Minimal complete definition

traverse1 | sequence1

Methods

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

sequence1 :: Apply f => t (f b) -> f (t b) #

#### Instances

Instances details

Traversable1 Complex # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f => (a -> f b) -> Complex a -> f (Complex b) # sequence1 :: Apply f => Complex (f b) -> f (Complex b) #
Traversable1 First # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f => (a -> f b) -> First a -> f (First b) # sequence1 :: Apply f => First (f b) -> f (First b) #
Traversable1 Last # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f => (a -> f b) -> Last a -> f (Last b) # sequence1 :: Apply f => Last (f b) -> f (Last b) #
Traversable1 Max # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f => (a -> f b) -> Max a -> f (Max b) # sequence1 :: Apply f => Max (f b) -> f (Max b) #
Traversable1 Min # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f => (a -> f b) -> Min a -> f (Min b) # sequence1 :: Apply f => Min (f b) -> f (Min b) #
Traversable1 Tree # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f => (a -> f b) -> Tree a -> f (Tree b) # sequence1 :: Apply f => Tree (f b) -> f (Tree b) #
Traversable1 NonEmpty # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f => (a -> f b) -> NonEmpty a -> f (NonEmpty b) # sequence1 :: Apply f => NonEmpty (f b) -> f (NonEmpty b) #
Traversable1 Identity # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f => (a -> f b) -> Identity a -> f (Identity b) # sequence1 :: Apply f => Identity (f b) -> f (Identity b) #
Traversable1 Dual # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f => (a -> f b) -> Dual a -> f (Dual b) # sequence1 :: Apply f => Dual (f b) -> f (Dual b) #
Traversable1 Product # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f => (a -> f b) -> Product a -> f (Product b) # sequence1 :: Apply f => Product (f b) -> f (Product b) #
Traversable1 Sum # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f => (a -> f b) -> Sum a -> f (Sum b) # sequence1 :: Apply f => Sum (f b) -> f (Sum b) #
Traversable1 Par1 # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f => (a -> f b) -> Par1 a -> f (Par1 b) # sequence1 :: Apply f => Par1 (f b) -> f (Par1 b) #
Traversable1 (V1 :: Type -> Type) # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f => (a -> f b) -> V1 a -> f (V1 b) # sequence1 :: Apply f => V1 (f b) -> f (V1 b) #
Traversable1 f => Traversable1 (Lift f) # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f0 => (a -> f0 b) -> Lift f a -> f0 (Lift f b) # sequence1 :: Apply f0 => Lift f (f0 b) -> f0 (Lift f b) #
Traversable1 ((,) a) # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f => (a0 -> f b) -> (a, a0) -> f (a, b) # sequence1 :: Apply f => (a, f b) -> f (a, b) #
Bitraversable1 p => Traversable1 (Join p) # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f => (a -> f b) -> Join p a -> f (Join p b) # sequence1 :: Apply f => Join p (f b) -> f (Join p b) #
Traversable1 f => Traversable1 (Alt f) # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f0 => (a -> f0 b) -> Alt f a -> f0 (Alt f b) # sequence1 :: Apply f0 => Alt f (f0 b) -> f0 (Alt f b) #
Traversable1 f => Traversable1 (Rec1 f) # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f0 => (a -> f0 b) -> Rec1 f a -> f0 (Rec1 f b) # sequence1 :: Apply f0 => Rec1 f (f0 b) -> f0 (Rec1 f b) #
Traversable1 (Tagged a) # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f => (a0 -> f b) -> Tagged a a0 -> f (Tagged a b) # sequence1 :: Apply f => Tagged a (f b) -> f (Tagged a b) #
Traversable1 f => Traversable1 (Backwards f) # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f0 => (a -> f0 b) -> Backwards f a -> f0 (Backwards f b) # sequence1 :: Apply f0 => Backwards f (f0 b) -> f0 (Backwards f b) #
Traversable1 f => Traversable1 (IdentityT f) # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f0 => (a -> f0 b) -> IdentityT f a -> f0 (IdentityT f b) # sequence1 :: Apply f0 => IdentityT f (f0 b) -> f0 (IdentityT f b) #
Traversable1 f => Traversable1 (Reverse f) # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f0 => (a -> f0 b) -> Reverse f a -> f0 (Reverse f b) # sequence1 :: Apply f0 => Reverse f (f0 b) -> f0 (Reverse f b) #
(Traversable1 f, Traversable1 g) => Traversable1 (Product f g) # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f0 => (a -> f0 b) -> Product f g a -> f0 (Product f g b) # sequence1 :: Apply f0 => Product f g (f0 b) -> f0 (Product f g b) #
(Traversable1 f, Traversable1 g) => Traversable1 (Sum f g) # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f0 => (a -> f0 b) -> Sum f g a -> f0 (Sum f g b) # sequence1 :: Apply f0 => Sum f g (f0 b) -> f0 (Sum f g b) #
(Traversable1 f, Traversable1 g) => Traversable1 (f :*: g) # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f0 => (a -> f0 b) -> (f :*: g) a -> f0 ((f :*: g) b) # sequence1 :: Apply f0 => (f :*: g) (f0 b) -> f0 ((f :*: g) b) #
(Traversable1 f, Traversable1 g) => Traversable1 (f :+: g) # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f0 => (a -> f0 b) -> (f :+: g) a -> f0 ((f :+: g) b) # sequence1 :: Apply f0 => (f :+: g) (f0 b) -> f0 ((f :+: g) b) #
(Traversable1 f, Traversable1 g) => Traversable1 (Compose f g) # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f0 => (a -> f0 b) -> Compose f g a -> f0 (Compose f g b) # sequence1 :: Apply f0 => Compose f g (f0 b) -> f0 (Compose f g b) #
Traversable1 g => Traversable1 (Joker g a) # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f => (a0 -> f b) -> Joker g a a0 -> f (Joker g a b) # sequence1 :: Apply f => Joker g a (f b) -> f (Joker g a b) #
(Traversable1 f, Traversable1 g) => Traversable1 (f :.: g) # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f0 => (a -> f0 b) -> (f :.: g) a -> f0 ((f :.: g) b) # sequence1 :: Apply f0 => (f :.: g) (f0 b) -> f0 ((f :.: g) b) #
Traversable1 f => Traversable1 (M1 i c f) # |
Instance details Defined in Data.Semigroup.Traversable.Class Methods traverse1 :: Apply f0 => (a -> f0 b) -> M1 i c f a -> f0 (M1 i c f b) # sequence1 :: Apply f0 => M1 i c f (f0 b) -> f0 (M1 i c f 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 exmaple `data Bar a = MkBar a Int`

Since: 5.3.8

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

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 #

Default implementation of `foldMap1` given an implementation of `Traversable1`.