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

Minimal complete definition

gcollect

Methods

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

Instances

GDistributive U1 # 

Methods

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

GDistributive Par1 # 

Methods

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

Distributive f => GDistributive (Rec1 f) # 

Methods

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

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

Methods

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

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

Methods

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

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

Methods

gcollect :: 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.