distributive-0.5.2: Distributive functors -- Dual to Traversable

Copyright(C) 2011-2016 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityprovisional
Portabilityportable
Safe HaskellTrustworthy
LanguageHaskell98

Data.Distributive.Generic

Description

 

Synopsis

Documentation

class GDistributive g where Source #

Minimal complete definition

gcollect

Methods

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

Instances

GDistributive U1 Source # 

Methods

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

GDistributive Par1 Source # 

Methods

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

Distributive f => GDistributive (Rec1 f) Source # 

Methods

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

(GDistributive a, GDistributive b) => GDistributive ((:*:) a b) Source # 

Methods

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

(Distributive a, GDistributive b) => GDistributive ((:.:) a b) Source # 

Methods

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

GDistributive f => GDistributive (M1 i c f) Source # 

Methods

gcollect :: Functor f => (a -> M1 i c f b) -> f a -> M1 i c f (f b) Source #

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

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) Source #

distribute derived from a Generic1 type

It's often more efficient to use genericCollect instead.