distributive-0.6.1: 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 #

Methods

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

Instances
GDistributive Par1 Source # 
Instance details

Defined in Data.Distributive.Generic

Methods

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

GDistributive (U1 :: Type -> Type) Source # 
Instance details

Defined in Data.Distributive.Generic

Methods

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

Distributive f => GDistributive (Rec1 f) Source # 
Instance details

Defined in Data.Distributive.Generic

Methods

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

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

Defined in Data.Distributive.Generic

Methods

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

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

Defined in Data.Distributive.Generic

Methods

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

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

Defined in Data.Distributive.Generic

Methods

gcollect :: Functor f => (a0 -> (a :.: b) b0) -> f a0 -> (a :.: b) (f b0) 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.