semigroupoids-5.0.1: Semigroupoids: Category sans id

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

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

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 [] 
Extend Identity 
Extend Maybe 
Extend Tree 
Extend Seq 
Extend NonEmpty 
Semigroup m => Extend ((->) m) 
Extend (Either a) 
Extend ((,) e) 
Extend w => Extend (IdentityT w) 
Extend f => Extend (MaybeApply f) 
(Extend w, Semigroup m) => Extend (TracedT m w) 
Extend w => Extend (StoreT s w) 
Extend w => Extend (EnvT e w) 
(Extend f, Extend g) => Extend (Sum f g) 
(Extend f, Semigroup a) => Extend (Static f a)