semigroupoids-5.2.1: Semigroupoids: Category sans id

Data.Functor.Extend

Contents

Description

Synopsis

Extendable Functors

There are two ways to define an Extend instance:

I. Provide definitions for extended satisfying this law:

extended f . extended g = extended (f . extended g)

II. Alternately, you may choose to provide definitions for duplicated satisfying this law:

duplicated . duplicated = fmap duplicated . duplicated

You may of course, choose to define both duplicated and extended. In that case you must also satisfy these laws:

extended f = fmap f . duplicated
duplicated = extended id

These are the default definitions of extended and duplicated.

class Functor w => Extend w where #

Minimal complete definition

Methods

duplicated :: w a -> w (w a) #

duplicated = extended id
fmap (fmap f) . duplicated = duplicated . fmap f

extended :: (w a -> b) -> w a -> w b #

extended f  = fmap f . duplicated

Instances

 Extend [] # Methodsduplicated :: [a] -> [[a]] #extended :: ([a] -> b) -> [a] -> [b] # # Methodsduplicated :: Maybe a -> Maybe (Maybe a) #extended :: (Maybe a -> b) -> Maybe a -> Maybe b # # Methodsduplicated :: Identity a -> Identity (Identity a) #extended :: (Identity a -> b) -> Identity a -> Identity b # # Methodsduplicated :: NonEmpty a -> NonEmpty (NonEmpty a) #extended :: (NonEmpty a -> b) -> NonEmpty a -> NonEmpty b # # Methodsduplicated :: Tree a -> Tree (Tree a) #extended :: (Tree a -> b) -> Tree a -> Tree b # # Methodsduplicated :: Seq a -> Seq (Seq a) #extended :: (Seq a -> b) -> Seq a -> Seq b # Semigroup m => Extend ((->) m) # Methodsduplicated :: (m -> a) -> m -> m -> a #extended :: ((m -> a) -> b) -> (m -> a) -> m -> b # Extend (Either a) # Methodsduplicated :: Either a a -> Either a (Either a a) #extended :: (Either a a -> b) -> Either a a -> Either a b # Extend ((,) e) # Methodsduplicated :: (e, a) -> (e, (e, a)) #extended :: ((e, a) -> b) -> (e, a) -> (e, b) # # Methodsduplicated :: Proxy * a -> Proxy * (Proxy * a) #extended :: (Proxy * a -> b) -> Proxy * a -> Proxy * b # Extend f => Extend (MaybeApply f) # Methodsduplicated :: MaybeApply f a -> MaybeApply f (MaybeApply f a) #extended :: (MaybeApply f a -> b) -> MaybeApply f a -> MaybeApply f b # (Extend w, Semigroup m) => Extend (TracedT m w) # Methodsduplicated :: TracedT m w a -> TracedT m w (TracedT m w a) #extended :: (TracedT m w a -> b) -> TracedT m w a -> TracedT m w b # Extend w => Extend (StoreT s w) # Methodsduplicated :: StoreT s w a -> StoreT s w (StoreT s w a) #extended :: (StoreT s w a -> b) -> StoreT s w a -> StoreT s w b # Extend w => Extend (EnvT e w) # Methodsduplicated :: EnvT e w a -> EnvT e w (EnvT e w a) #extended :: (EnvT e w a -> b) -> EnvT e w a -> EnvT e w b # Extend w => Extend (IdentityT * w) # Methodsduplicated :: IdentityT * w a -> IdentityT * w (IdentityT * w a) #extended :: (IdentityT * w a -> b) -> IdentityT * w a -> IdentityT * w b # # Methodsduplicated :: Tagged * a a -> Tagged * a (Tagged * a a) #extended :: (Tagged * a a -> b) -> Tagged * a a -> Tagged * a b # (Extend f, Semigroup a) => Extend (Static f a) # Methodsduplicated :: Static f a a -> Static f a (Static f a a) #extended :: (Static f a a -> b) -> Static f a a -> Static f a b # (Extend f, Extend g) => Extend (Sum * f g) # Methodsduplicated :: Sum * f g a -> Sum * f g (Sum * f g a) #extended :: (Sum * f g a -> b) -> Sum * f g a -> Sum * f g b #