distributive-0.5.3: Distributive functors -- Dual to Traversable

Data.Distributive.Generic

Description

Synopsis

# Documentation

class GDistributive g where #

Minimal complete definition

gcollect

Methods

gcollect :: Functor f => (a -> g b) -> f a -> g (f b) #

Instances

 # Methodsgcollect :: Functor f => (a -> U1 b) -> f a -> U1 (f b) # # Methodsgcollect :: Functor f => (a -> Par1 b) -> f a -> Par1 (f b) # # Methodsgcollect :: Functor f => (a -> Rec1 f b) -> f a -> Rec1 f (f b) # (GDistributive a, GDistributive b) => GDistributive ((:*:) a b) # Methodsgcollect :: Functor f => (a -> (a :*: b) b) -> f a -> (a :*: b) (f b) # (Distributive a, GDistributive b) => GDistributive ((:.:) a b) # Methodsgcollect :: Functor f => (a -> (a :.: b) b) -> f a -> (a :.: b) (f b) # GDistributive f => GDistributive (M1 i c f) # Methodsgcollect :: Functor f => (a -> M1 i c f b) -> f a -> M1 i c f (f b) #

genericCollect :: (Functor f, Generic1 g, GDistributive (Rep1 g)) => (a -> g b) -> f a -> g (f b) #

collect derived from a Generic1 type

This can be used to easily produce a Distributive instance for a type with a Generic1 instance,

data V2 a = V2 a a deriving (Show, Functor, Generic1)
instance Distributive V2' where collect = genericCollect

genericDistribute :: (Functor f, Generic1 g, GDistributive (Rep1 g)) => f (g a) -> g (f a) #

distribute derived from a Generic1 type

It's often more efficient to use genericCollect instead.