Converts a universal adapter instance back into a polymorphic adapter.
Modulelens-family-core-2.1.3Haskell2010
Lens.Family.Clone
This module is provided for "Haskell 2022" compatibility.
If you are able to use Rank2Types, I advise you to instead use the rank 2 aliases
Adapter,Adapter'Prism,Prism'Lens,Lens'Traversal,Traversal'Setter,Setter'Grate,Grate'Resetter,Resetter'Grid,Grid'Fold,Fold'Getter,Getter'Reviewer,Reviewer'
from the lens-family package instead.
cloneLens allows one to circumvent the need for rank 2 types by allowing one to take a universal monomorphic lens instance and rederive a polymorphic instance.
When you require a lens family parameter you use the type ALens s t a b (or ALens' s a).
Then, inside a where clause, you use cloneLens to create a Lens type.
For example.
example :: ALens s t a b -> Example
example l = ... x^.cl ... cl .~ y ...
where
cl x = cloneLens l xNote: It is important to eta-expand the definition of cl to avoid the dreaded monomorphism restriction.
cloneAdapter, cloneGrate, cloneTraversal, cloneSetter, cloneResetter, cloneGetter, and cloneFold provides similar functionality for adapters, grates, traversals, setters, resetters, getters, and folds respectively. Unfortunately, it is not yet known how to clone prisms and grids.
Note: Cloning is only need if you use a functional reference multiple times with different instances.
- 21 types
- 2 classes
- 8 values
- Packagelens-family-core-2.1.3
- Exports31
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceClone.hs
Converts a universal lens instance back into a polymorphic lens.
Converts a universal grate instance back into a polymorphic grater.
Converts a universal traversal instance back into a polymorphic traversal.
Converts a universal setter instance back into a polymorphic setter.
Converts a universal resetter instance back into a polymorphic resetter.
Converts a universal getter instance back into a polymorphic getter.
Converts a universal fold instance back into a polymorphic fold.
Types
12 declarationsAnAdapter s t a b is a universal Adapter s t a b instance
AnAdapter' s a is a universal Adapter' s a instance
ALens s t a b is a universal Lens s t a b instance
ALens' s a is a universal Lens' s a instance
ATraversal s t a b is a universal Traversal s t a b instance
ATraversal' a b is a universal Traversal' a b instance
AGetter s t a b is a universal Getter s t a b instance
AGetter' s a is a universal Getter' s a instance
AFold s t a b is a universal Fold s t a b instance
AFold' s a is a universal Fold' s a instance
Instances2Functor, Applicative
Functor (PKleeneStore i j)Defined in lens-family-core-2.1.3 · Lens.Family.CloneApplicative (PKleeneStore i j)Defined in lens-family-core-2.1.3 · Lens.Family.Clone
Re-exports
11 declarationsInstances8Phantom, …
Phantom (Const a)Defined in lens-family-core-2.1.3 · Lens.Family.PhantomPhantom (Constant a)Defined in lens-family-core-2.1.3 · Lens.Family.PhantomPhantom f => Phantom (AlongsideLeft f a)Defined in lens-family-core-2.1.3 · Lens.Family.StockPhantom f => Phantom (AlongsideRight f a)Defined in lens-family-core-2.1.3 · Lens.Family.StockPhantom f => Phantom (Backwards f)Defined in lens-family-core-2.1.3 · Lens.Family.PhantomPhantom g => Phantom (FromG e g)Defined in lens-family-core-2.1.3 · Lens.Family.StockPhantom g => Phantom (FromF i j g)Defined in lens-family-core-2.1.3 · Lens.Family.Stock(Phantom f, Functor g) => Phantom (Compose f g)Defined in lens-family-core-2.1.3 · Lens.Family.Phantom