constrained-0.1: Generalization of standard Functor, Foldable, and Traversable classes

Copyright(c) Sergey Vinokurov 2019
LicenseBSD-2 (see LICENSE)
Maintainersergey@debian
Safe HaskellNone
LanguageHaskell2010

Data.Traversable.Constrained

Description

 
Synopsis

Documentation

class (CFunctor f, CFoldable f) => CTraversable f where Source #

Like Traversable but allows elements to have constraints on them. Laws are the same:

ctraverse pure == pure
ctraverse (f <=< g) == ctraverse f <=< ctraverse g

NB There's no aplicative version because Vectors from the http://hackage.haskell.org/package/vector package only support monadic traversals. Since they're one of the main motivation for this package, Applicative version of traversals will not exist.

Minimal complete definition

Nothing

Methods

ctraverse :: (Constraints f a, Constraints f b, Monad m) => (a -> m b) -> f a -> m (f b) Source #

csequence :: (Constraints f a, Constraints f (m a), Monad m) => f (m a) -> m (f a) Source #

ctraverse :: (Constraints f a, Constraints f b, Monad m, Traversable f) => (a -> m b) -> f a -> m (f b) Source #

Instances
CTraversable [] Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints [] a, Constraints [] b, Monad m) => (a -> m b) -> [a] -> m [b] Source #

csequence :: (Constraints [] a, Constraints [] (m a), Monad m) => [m a] -> m [a] Source #

CTraversable Maybe Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints Maybe a, Constraints Maybe b, Monad m) => (a -> m b) -> Maybe a -> m (Maybe b) Source #

csequence :: (Constraints Maybe a, Constraints Maybe (m a), Monad m) => Maybe (m a) -> m (Maybe a) Source #

CTraversable Min Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints Min a, Constraints Min b, Monad m) => (a -> m b) -> Min a -> m (Min b) Source #

csequence :: (Constraints Min a, Constraints Min (m a), Monad m) => Min (m a) -> m (Min a) Source #

CTraversable Max Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints Max a, Constraints Max b, Monad m) => (a -> m b) -> Max a -> m (Max b) Source #

csequence :: (Constraints Max a, Constraints Max (m a), Monad m) => Max (m a) -> m (Max a) Source #

CTraversable First Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints First a, Constraints First b, Monad m) => (a -> m b) -> First a -> m (First b) Source #

csequence :: (Constraints First a, Constraints First (m a), Monad m) => First (m a) -> m (First a) Source #

CTraversable Last Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints Last a, Constraints Last b, Monad m) => (a -> m b) -> Last a -> m (Last b) Source #

csequence :: (Constraints Last a, Constraints Last (m a), Monad m) => Last (m a) -> m (Last a) Source #

CTraversable ZipList Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints ZipList a, Constraints ZipList b, Monad m) => (a -> m b) -> ZipList a -> m (ZipList b) Source #

csequence :: (Constraints ZipList a, Constraints ZipList (m a), Monad m) => ZipList (m a) -> m (ZipList a) Source #

CTraversable Identity Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints Identity a, Constraints Identity b, Monad m) => (a -> m b) -> Identity a -> m (Identity b) Source #

csequence :: (Constraints Identity a, Constraints Identity (m a), Monad m) => Identity (m a) -> m (Identity a) Source #

CTraversable Dual Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints Dual a, Constraints Dual b, Monad m) => (a -> m b) -> Dual a -> m (Dual b) Source #

csequence :: (Constraints Dual a, Constraints Dual (m a), Monad m) => Dual (m a) -> m (Dual a) Source #

CTraversable Sum Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints Sum a, Constraints Sum b, Monad m) => (a -> m b) -> Sum a -> m (Sum b) Source #

csequence :: (Constraints Sum a, Constraints Sum (m a), Monad m) => Sum (m a) -> m (Sum a) Source #

CTraversable Product Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints Product a, Constraints Product b, Monad m) => (a -> m b) -> Product a -> m (Product b) Source #

csequence :: (Constraints Product a, Constraints Product (m a), Monad m) => Product (m a) -> m (Product a) Source #

CTraversable NonEmpty Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints NonEmpty a, Constraints NonEmpty b, Monad m) => (a -> m b) -> NonEmpty a -> m (NonEmpty b) Source #

csequence :: (Constraints NonEmpty a, Constraints NonEmpty (m a), Monad m) => NonEmpty (m a) -> m (NonEmpty a) Source #

CTraversable (Either a) Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints (Either a) a0, Constraints (Either a) b, Monad m) => (a0 -> m b) -> Either a a0 -> m (Either a b) Source #

csequence :: (Constraints (Either a) a0, Constraints (Either a) (m a0), Monad m) => Either a (m a0) -> m (Either a a0) Source #

CTraversable ((,) a) Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints ((,) a) a0, Constraints ((,) a) b, Monad m) => (a0 -> m b) -> (a, a0) -> m (a, b) Source #

csequence :: (Constraints ((,) a) a0, Constraints ((,) a) (m a0), Monad m) => (a, m a0) -> m (a, a0) Source #

CTraversable (Const a :: Type -> Type) Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints (Const a) a0, Constraints (Const a) b, Monad m) => (a0 -> m b) -> Const a a0 -> m (Const a b) Source #

csequence :: (Constraints (Const a) a0, Constraints (Const a) (m a0), Monad m) => Const a (m a0) -> m (Const a a0) Source #

CTraversable f => CTraversable (Ap f) Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints (Ap f) a, Constraints (Ap f) b, Monad m) => (a -> m b) -> Ap f a -> m (Ap f b) Source #

csequence :: (Constraints (Ap f) a, Constraints (Ap f) (m a), Monad m) => Ap f (m a) -> m (Ap f a) Source #

CTraversable f => CTraversable (Alt f) Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints (Alt f) a, Constraints (Alt f) b, Monad m) => (a -> m b) -> Alt f a -> m (Alt f b) Source #

csequence :: (Constraints (Alt f) a, Constraints (Alt f) (m a), Monad m) => Alt f (m a) -> m (Alt f a) Source #

(CTraversable f, CTraversable g) => CTraversable (Product f g) Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints (Product f g) a, Constraints (Product f g) b, Monad m) => (a -> m b) -> Product f g a -> m (Product f g b) Source #

csequence :: (Constraints (Product f g) a, Constraints (Product f g) (m a), Monad m) => Product f g (m a) -> m (Product f g a) Source #

(CTraversable f, CTraversable g) => CTraversable (Sum f g) Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints (Sum f g) a, Constraints (Sum f g) b, Monad m) => (a -> m b) -> Sum f g a -> m (Sum f g b) Source #

csequence :: (Constraints (Sum f g) a, Constraints (Sum f g) (m a), Monad m) => Sum f g (m a) -> m (Sum f g a) Source #

(CTraversable f, CTraversable g) => CTraversable (Compose f g) Source # 
Instance details

Defined in Data.Traversable.Constrained

Methods

ctraverse :: (Constraints (Compose f g) a, Constraints (Compose f g) b, Monad m) => (a -> m b) -> Compose f g a -> m (Compose f g b) Source #

csequence :: (Constraints (Compose f g) a, Constraints (Compose f g) (m a), Monad m) => Compose f g (m a) -> m (Compose f g a) Source #

cfor :: (CTraversable f, Constraints f a, Constraints f b, Monad m) => f a -> (a -> m b) -> m (f b) Source #

ctraverse with araguments flipped.

class Constrained (f :: k2 -> k1) Source #

Specification of constrains that a functor might impose on its elements. For example, sets typically require that their elements are ordered and unboxed vectors require elements to have an instance of special class that allows them to be packed in memory.

NB The Constraints type family is associated with a typeclass in order to improve type inference. Whenever a typeclass constraint will be present, instance is guaranteed to exist and typechecker is going to take advantage of that.

Associated Types

type Constraints (f :: k2 -> k1) :: k2 -> Constraint Source #

Instances
Constrained f => Constrained (Alt f :: k2 -> Type) Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints (Alt f) :: k2 -> Constraint Source #

Constrained f => Constrained (Ap f :: k2 -> Type) Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints (Ap f) :: k2 -> Constraint Source #

Constrained (Const a :: k2 -> Type) Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints (Const a) :: k2 -> Constraint Source #

(Constrained f, Constrained g) => Constrained (Sum f g :: k2 -> Type) Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints (Sum f g) :: k2 -> Constraint Source #

(Constrained f, Constrained g) => Constrained (Product f g :: k2 -> Type) Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints (Product f g) :: k2 -> Constraint Source #

(Constrained f, Constrained g) => Constrained (Compose f g :: k2 -> Type) Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints (Compose f g) :: k2 -> Constraint Source #

Constrained [] Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints [] :: k2 -> Constraint Source #

Constrained Maybe Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints Maybe :: k2 -> Constraint Source #

Constrained Min Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints Min :: k2 -> Constraint Source #

Constrained Max Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints Max :: k2 -> Constraint Source #

Constrained First Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints First :: k2 -> Constraint Source #

Constrained Last Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints Last :: k2 -> Constraint Source #

Constrained ZipList Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints ZipList :: k2 -> Constraint Source #

Constrained Identity Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints Identity :: k2 -> Constraint Source #

Constrained Dual Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints Dual :: k2 -> Constraint Source #

Constrained Sum Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints Sum :: k2 -> Constraint Source #

Constrained Product Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints Product :: k2 -> Constraint Source #

Constrained NonEmpty Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints NonEmpty :: k2 -> Constraint Source #

Constrained (Either a :: Type -> Type) Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints (Either a) :: k2 -> Constraint Source #

Constrained ((,) a :: Type -> Type) Source # 
Instance details

Defined in Data.Constrained

Associated Types

type Constraints ((,) a) :: k2 -> Constraint Source #