Agda-2.4.2: A dependently typed functional programming language and proof assistant

Safe HaskellSafe-Inferred

Agda.Utils.Functor

Contents

Description

Utilities for functors.

Synopsis

Documentation

($>) :: Functor f => f a -> b -> f bSource

(<.>) :: Functor m => (b -> c) -> (a -> m b) -> a -> m cSource

Composition: pure function after functorial (monadic) function.

for :: Functor m => m a -> (a -> b) -> m bSource

The true pure for loop. for is a misnomer, it should be forA.

class Functor t => Decoration t whereSource

A decoration is a functor that is traversable into any functor.

The Functor superclass is given because of the limitations of the Haskell class system. traverseF actually implies functoriality.

Minimal complete definition: traverseF or distributeF.

Methods

traverseF :: Functor m => (a -> m b) -> t a -> m (t b)Source

traverseF is the defining property.

distributeF :: Functor m => t (m a) -> m (t a)Source

Decorations commute into any functor.

Instances

Decoration Identity

The identity functor is a decoration.

Decoration Ranged 
Decoration Type' 
Decoration ((,) a)

A typical decoration is pairing with some stuff.

Decoration (Named name) 
Decoration (Dom c) 
Decoration (Arg c) 
(Decoration d, Decoration t) => Decoration (Compose d t)

Decorations compose. (Thus, they form a category.)

dmap :: Decoration t => (a -> b) -> t a -> t bSource

Any decoration is traversable with traverse = traverseF. Just like any Traversable is a functor, so is any decoration, given by just traverseF, a functor.

dget :: Decoration t => t a -> aSource

Any decoration is a lens. set is a special case of fmap.

The constant functor.

Maybe. Can only be traversed into pointed functors.

Other disjoint sum types, like lists etc.

(<$>) :: Functor f => (a -> b) -> f a -> f b