semigroupoids-5.1: Semigroupoids: Category sans id

Copyright | (C) 2011-2015 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | provisional
Portability | portable
Safe Haskell | Safe
Language | Haskell98

Data.Functor.Extend

Contents

- Extendable Functors

Description

Synopsis

- class Functor w => Extend w where

# 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

duplicated | extended

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 [] # |
Methods duplicated :: [a] -> [[a]] # extended :: ([a] -> b) -> [a] -> [b] #
Extend Maybe # |
Methods duplicated :: Maybe a -> Maybe (Maybe a) # extended :: (Maybe a -> b) -> Maybe a -> Maybe b #
Extend Identity # |
Methods duplicated :: Identity a -> Identity (Identity a) # extended :: (Identity a -> b) -> Identity a -> Identity b #
Extend NonEmpty # |
Methods duplicated :: NonEmpty a -> NonEmpty (NonEmpty a) # extended :: (NonEmpty a -> b) -> NonEmpty a -> NonEmpty b #
Extend Tree # |
Methods duplicated :: Tree a -> Tree (Tree a) # extended :: (Tree a -> b) -> Tree a -> Tree b #
Extend Seq # |
Methods duplicated :: Seq a -> Seq (Seq a) # extended :: (Seq a -> b) -> Seq a -> Seq b #
Semigroup m => Extend ((->) m) # |
Methods duplicated :: (m -> a) -> m -> m -> a # extended :: ((m -> a) -> b) -> (m -> a) -> m -> b #
Extend (Either a) # |
Methods duplicated :: Either a a -> Either a (Either a a) # extended :: (Either a a -> b) -> Either a a -> Either a b #
Extend ((,) e) # |
Methods duplicated :: (e, a) -> (e, (e, a)) # extended :: ((e, a) -> b) -> (e, a) -> (e, b) #
Extend f => Extend (MaybeApply f) # |
Methods duplicated :: 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) # |
Methods duplicated :: 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) # |
Methods duplicated :: 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) # |
Methods duplicated :: 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) # |
Methods duplicated :: IdentityT * w a -> IdentityT * w (IdentityT * w a) # extended :: (IdentityT * w a -> b) -> IdentityT * w a -> IdentityT * w b #
(Extend f, Semigroup a) => Extend (Static f a) # |
Methods duplicated :: 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) # |
Methods duplicated :: 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 #