lens-3.5: Lenses, Folds and Traversals

PortabilityRank2Types
Stabilityprovisional
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellTrustworthy

Control.Lens.Classes

Contents

Description

 

Synopsis

Getters

class (Functor f, Trustworthy f) => Gettable f whereSource

Generalizing Const so we can apply simple Applicative transformations to it and so we can get nicer error messages

A Gettable Functor ignores its argument, which it carries solely as a phantom type parameter.

To ensure this, an instance of Gettable is required to satisfy:

id = fmap f = coerce

Which is equivalent to making a Gettable f an "anyvariant" functor.

Due to the structure of this library, if you built an illegal Gettable instance that defined coerce = undefined, it would be possible to produce code that would unsafeCoerce.

This would violate the promises of SafeHaskell.

That said, the existing instances are all safe. To verify that any additional instances that *you* provide are safe, you must

 import Control.Lens.Unsafe

and provide an instance of Trustworthy for your data type. That module does not make SafeHaskell guarantees, so by doing so you've taken the SafeHaskell proof obligation into your own hands.

Methods

coerce :: f a -> f bSource

Replace the phantom type argument.

noEffect :: (Applicative f, Gettable f) => f aSource

The mempty equivalent for a Gettable Applicative Functor.

Actions

class (Monad m, Gettable f) => Effective m r f | f -> m r whereSource

An Effective Functor ignores its argument and is isomorphic to a monad wrapped around a value.

That said, the monad is possibly rather unrelated to any Applicative structure.

Methods

effective :: Isomorphic k => k (m r) (f a)Source

Instances

ineffective :: Effective m r f => Isomorphic k => k (f a) (m r)Source

A convenient antonym that is used internally.

Setters

class Applicative f => Settable f whereSource

Anything Settable must be isomorphic to the Identity Functor.

Methods

untainted :: f a -> aSource

untainted# :: (a -> f b) -> a -> bSource

tainted# :: (a -> b) -> a -> f bSource

Instances

Settable Identity

so you can pass our a Setter into combinators from other lens libraries

Settable Mutator 
(Applicative (Backwards f), Settable f) => Settable (Backwards f)

backwards

(Applicative (Compose f g), Settable f, Settable g) => Settable (Compose f g)