| Portability | portable |
|---|---|
| Stability | provisional |
| Maintainer | Edward Kmett <ekmett@gmail.com> |
| Safe Haskell | Safe-Inferred |
Data.Functor.Extend
Contents
Description
- class Functor w => Extend w where
- duplicated :: w a -> w (w a)
- extended :: (w a -> b) -> w a -> w b
Extendable Functors
There are two ways to define an Extend instance:
I. Provide definitions for extend
satisfying this law:
extended f . extended g = extended (f . extended g)
II. Alternately, you may choose to provide definitions for duplicate
satisfying this law:
duplicated . duplicated = fmap duplicated . duplicated
These are both equivalent to the statement that (->-) is associative
(f ->- g) ->- h = f ->- (g ->- h)
You may of course, choose to define both duplicate and extend.
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 whereSource
Methods
duplicated :: w a -> w (w a)Source
duplicated = extended id fmap (fmap f) . duplicated = duplicated . fmap f
extended :: (w a -> b) -> w a -> w bSource
extended f = fmap f . duplicated
Instances
| Extend [] | |
| Extend Maybe | |
| Extend Tree | |
| Extend Seq | |
| Extend NonEmpty | |
| Extend Identity | |
| (Functor ((->) m), Semigroup m) => Extend ((->) m) | |
| Functor (Either a) => Extend (Either a) | |
| Functor ((,) e) => Extend ((,) e) | |
| (Functor (IdentityT w), Extend w) => Extend (IdentityT w) | |
| (Functor (MaybeApply f), Extend f) => Extend (MaybeApply f) | |
| (Functor (Static f a), Extend f, Semigroup a) => Extend (Static f a) |