endo-0.2.0.0: Endomorphism utilities.

Copyright(c) 2013-2015 Peter Trško
LicenseBSD3
Maintainerpeter.trsko@gmail.com
Stabilityexperimental
PortabilityNoImplicitPrelude
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Monoid.Endo

Contents

Description

Utilities for Endo data type from Data.Monoid module.

Synopsis

Endo

type E a = a -> a Source

Type synonym for endomorphsm; it can be used to simplify type signatures.

newtype Endo a :: * -> *

The monoid of endomorphisms under composition.

Constructors

Endo 

Fields

appEndo :: a -> a
 

Instances

Generic (Endo a) 
Monoid (Endo a) 
AnEndo (Endo a) 
FoldEndoArgs (Endo a) 
type Rep (Endo a) = D1 D1Endo (C1 C1_0Endo (S1 S1_0_0Endo (Rec0 (a -> a)))) 
type EndoOperatesOn (Endo a) = a 
type ResultOperatesOn (Endo a) = a 
type Result (Endo a) = Endo a 

runEndo :: a -> Endo a -> a Source

Flipped version of appEndo.

mapEndo :: (E a -> E b) -> Endo a -> Endo b Source

Transform function wrapped in Endo.

mapEndo2 :: (E a -> E b -> E c) -> Endo a -> Endo b -> Endo c Source

Variation of mapEndo for functions with arity two.

liftEndo :: Functor f => Endo a -> Endo (f a) Source

Apply fmap to function wrapped in Endo. It's a short hand for mapEndo fmap.

Lens

endo :: Functor f => (E a -> f (E b)) -> Endo a -> f (Endo b) Source

Lens for Endo. In terms of lens package it would have type:

endo :: Lens (Endo a) (Endo b) (E a) (E b)

For details see lens package.