Control.Lens.Wrapped

lens-4.14: Lenses, Folds and Traversals

Copyright | (C) 2012-16 Edward Kmett, Michael Sloan
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | experimental
Portability | Rank2, MPTCs, fundeps
Safe Haskell | Trustworthy
Language | Haskell98

Control.Lens.Wrapped

Contents

- Wrapping and Unwrapping monomorphically
- Wrapping and unwrapping polymorphically
- Operations
- Pattern Synonyms

Description

The `Wrapped` class provides similar functionality as `Control.Newtype`, from the `newtype` package, but in a more convenient and efficient form.

There are a few functions from `newtype` that are not provided here, because they can be done with the `Iso` directly:

    Control.Newtype.over Sum f ≡ _Unwrapping Sum %~ f
    Control.Newtype.under Sum f ≡ _Wrapping Sum %~ f
    Control.Newtype.overF Sum f ≡ mapping (_Unwrapping Sum) %~ f
    Control.Newtype.underF Sum f ≡ mapping (_Wrapping Sum) %~ f

`under` can also be used with `_Unwrapping` to provide the equivalent of `Control.Newtype.under`. Also, most use cases don't need full polymorphism, so only the single constructor `_Wrapping` functions would be needed.

These equivalences aren't 100% honest, because `newtype`'s operators need to rely on two `Newtype` constraints. This means that the wrapper used for the output is not necessarily the same as the input.

Synopsis

- class Wrapped s where
  - type Unwrapped s :: *
- _Unwrapped' :: Wrapped s => Iso' (Unwrapped s) s
- _Wrapping' :: Wrapped s => (Unwrapped s -> s) -> Iso' s (Unwrapped s)
- _Unwrapping' :: Wrapped s => (Unwrapped s -> s) -> Iso' (Unwrapped s) s
- class Wrapped s => Rewrapped s t
- class (Rewrapped s t, Rewrapped t s) => Rewrapping s t
- _Wrapped :: Rewrapping s t => Iso s t (Unwrapped s) (Unwrapped t)
- _Unwrapped :: Rewrapping s t => Iso (Unwrapped t) (Unwrapped s) t s
- _Wrapping :: Rewrapping s t => (Unwrapped s -> s) -> Iso s t (Unwrapped s) (Unwrapped t)
- _Unwrapping :: Rewrapping s t => (Unwrapped s -> s) -> Iso (Unwrapped t) (Unwrapped s) t s
- op :: Wrapped s => (Unwrapped s -> s) -> s -> Unwrapped s
- ala :: (Functor f, Rewrapping s t) => (Unwrapped s -> s) -> ((Unwrapped t -> t) -> f s) -> f (Unwrapped s)
- alaf :: (Functor f, Functor g, Rewrapping s t) => (Unwrapped s -> s) -> (f t -> g s) -> f (Unwrapped t) -> g (Unwrapped s)
- pattern Wrapped :: forall s. Rewrapped s s => Unwrapped s -> s
- pattern Unwrapped :: forall t. Rewrapped t t => t -> Unwrapped t

# Wrapping and Unwrapping monomorphically

class Wrapped s where #

`Wrapped` provides isomorphisms to wrap and unwrap newtypes or data types with one constructor.

Associated Types

type Unwrapped s :: * #

Methods

_Wrapped' :: Iso' s (Unwrapped s) #

An isomorphism between `s` and `a`.

Instances

Wrapped PatternMatchFail # |
Associated Types type Unwrapped PatternMatchFail :: * # Methods _Wrapped' :: Iso' PatternMatchFail (Unwrapped PatternMatchFail) #
Wrapped RecSelError # |
Associated Types type Unwrapped RecSelError :: * # Methods _Wrapped' :: Iso' RecSelError (Unwrapped RecSelError) #
Wrapped RecConError # |
Associated Types type Unwrapped RecConError :: * # Methods _Wrapped' :: Iso' RecConError (Unwrapped RecConError) #
Wrapped RecUpdError # |
Associated Types type Unwrapped RecUpdError :: * # Methods _Wrapped' :: Iso' RecUpdError (Unwrapped RecUpdError) #
Wrapped NoMethodError # |
Associated Types type Unwrapped NoMethodError :: * # Methods _Wrapped' :: Iso' NoMethodError (Unwrapped NoMethodError) #
Wrapped AssertionFailed # |
Associated Types type Unwrapped AssertionFailed :: * # Methods _Wrapped' :: Iso' AssertionFailed (Unwrapped AssertionFailed) #
Wrapped All # |
Associated Types type Unwrapped All :: * # Methods _Wrapped' :: Iso' All (Unwrapped All) #
Wrapped Any # |
Associated Types type Unwrapped Any :: * # Methods _Wrapped' :: Iso' Any (Unwrapped Any) #
Wrapped ErrorCall # |
Associated Types type Unwrapped ErrorCall :: * # Methods _Wrapped' :: Iso' ErrorCall (Unwrapped ErrorCall) #
Wrapped IntSet # |
Associated Types type Unwrapped IntSet :: * # Methods _Wrapped' :: Iso' IntSet (Unwrapped IntSet) #
Wrapped (Identity a) # |
Associated Types type Unwrapped (Identity a) :: * # Methods _Wrapped' :: Iso' (Identity a) (Unwrapped (Identity a)) #
Wrapped (Min a) # |
Associated Types type Unwrapped (Min a) :: * # Methods _Wrapped' :: Iso' (Min a) (Unwrapped (Min a)) #
Wrapped (Max a) # |
Associated Types type Unwrapped (Max a) :: * # Methods _Wrapped' :: Iso' (Max a) (Unwrapped (Max a)) #
Wrapped (First a) # |
Associated Types type Unwrapped (First a) :: * # Methods _Wrapped' :: Iso' (First a) (Unwrapped (First a)) #
Wrapped (Last a) # |
Associated Types type Unwrapped (Last a) :: * # Methods _Wrapped' :: Iso' (Last a) (Unwrapped (Last a)) #
Wrapped (WrappedMonoid a) # |
Associated Types type Unwrapped (WrappedMonoid a) :: * # Methods _Wrapped' :: Iso' (WrappedMonoid a) (Unwrapped (WrappedMonoid a)) #
Wrapped (Option a) # |
Associated Types type Unwrapped (Option a) :: * # Methods _Wrapped' :: Iso' (Option a) (Unwrapped (Option a)) #
Wrapped (NonEmpty a) # |
Associated Types type Unwrapped (NonEmpty a) :: * # Methods _Wrapped' :: Iso' (NonEmpty a) (Unwrapped (NonEmpty a)) #
Wrapped (ZipList a) # |
Associated Types type Unwrapped (ZipList a) :: * # Methods _Wrapped' :: Iso' (ZipList a) (Unwrapped (ZipList a)) #
Wrapped (Dual a) # |
Associated Types type Unwrapped (Dual a) :: * # Methods _Wrapped' :: Iso' (Dual a) (Unwrapped (Dual a)) #
Wrapped (Endo a) # |
Associated Types type Unwrapped (Endo a) :: * # Methods _Wrapped' :: Iso' (Endo a) (Unwrapped (Endo a)) #
Wrapped (Sum a) # |
Associated Types type Unwrapped (Sum a) :: * # Methods _Wrapped' :: Iso' (Sum a) (Unwrapped (Sum a)) #
Wrapped (Product a) # |
Associated Types type Unwrapped (Product a) :: * # Methods _Wrapped' :: Iso' (Product a) (Unwrapped (Product a)) #
Wrapped (First a) # |
Associated Types type Unwrapped (First a) :: * # Methods _Wrapped' :: Iso' (First a) (Unwrapped (First a)) #
Wrapped (Last a) # |
Associated Types type Unwrapped (Last a) :: * # Methods _Wrapped' :: Iso' (Last a) (Unwrapped (Last a)) #
Wrapped (Down a) # |
Associated Types type Unwrapped (Down a) :: * # Methods _Wrapped' :: Iso' (Down a) (Unwrapped (Down a)) #
Wrapped (Seq a) # |
Associated Types type Unwrapped (Seq a) :: * # Methods _Wrapped' :: Iso' (Seq a) (Unwrapped (Seq a)) #
Wrapped (IntMap a) # |
Associated Types type Unwrapped (IntMap a) :: * # Methods _Wrapped' :: Iso' (IntMap a) (Unwrapped (IntMap a)) #
Ord a => Wrapped (Set a) # |
Associated Types type Unwrapped (Set a) :: * # Methods _Wrapped' :: Iso' (Set a) (Unwrapped (Set a)) #
Wrapped (Predicate a) # |
Associated Types type Unwrapped (Predicate a) :: * # Methods _Wrapped' :: Iso' (Predicate a) (Unwrapped (Predicate a)) #
Wrapped (Comparison a) # |
Associated Types type Unwrapped (Comparison a) :: * # Methods _Wrapped' :: Iso' (Comparison a) (Unwrapped (Comparison a)) #
Wrapped (Equivalence a) # |
Associated Types type Unwrapped (Equivalence a) :: * # Methods _Wrapped' :: Iso' (Equivalence a) (Unwrapped (Equivalence a)) #
(Hashable a, Eq a) => Wrapped (HashSet a) # |
Associated Types type Unwrapped (HashSet a) :: * # Methods _Wrapped' :: Iso' (HashSet a) (Unwrapped (HashSet a)) #
Wrapped (Vector a) # |
Associated Types type Unwrapped (Vector a) :: * # Methods _Wrapped' :: Iso' (Vector a) (Unwrapped (Vector a)) #
Unbox a => Wrapped (Vector a) # |
Associated Types type Unwrapped (Vector a) :: * # Methods _Wrapped' :: Iso' (Vector a) (Unwrapped (Vector a)) #
Storable a => Wrapped (Vector a) # |
Associated Types type Unwrapped (Vector a) :: * # Methods _Wrapped' :: Iso' (Vector a) (Unwrapped (Vector a)) #
Prim a => Wrapped (Vector a) # |
Associated Types type Unwrapped (Vector a) :: * # Methods _Wrapped' :: Iso' (Vector a) (Unwrapped (Vector a)) #
Wrapped (Op a b) # |
Associated Types type Unwrapped (Op a b) :: * # Methods _Wrapped' :: Iso' (Op a b) (Unwrapped (Op a b)) #
Wrapped (WrappedMonad m a) # |
Associated Types type Unwrapped (WrappedMonad m a) :: * # Methods _Wrapped' :: Iso' (WrappedMonad m a) (Unwrapped (WrappedMonad m a)) #
Wrapped (ArrowMonad m a) # |
Associated Types type Unwrapped (ArrowMonad m a) :: * # Methods _Wrapped' :: Iso' (ArrowMonad m a) (Unwrapped (ArrowMonad m a)) #
Ord k => Wrapped (Map k a) # |
Associated Types type Unwrapped (Map k a) :: * # Methods _Wrapped' :: Iso' (Map k a) (Unwrapped (Map k a)) #
Wrapped (ListT m a) # |
Associated Types type Unwrapped (ListT m a) :: * # Methods _Wrapped' :: Iso' (ListT m a) (Unwrapped (ListT m a)) #
Wrapped (MaybeT m a) # |
Associated Types type Unwrapped (MaybeT m a) :: * # Methods _Wrapped' :: Iso' (MaybeT m a) (Unwrapped (MaybeT m a)) #
(Hashable k, Eq k) => Wrapped (HashMap k a) # |
Associated Types type Unwrapped (HashMap k a) :: * # Methods _Wrapped' :: Iso' (HashMap k a) (Unwrapped (HashMap k a)) #
Wrapped (WrappedArrow a b c) # |
Associated Types type Unwrapped (WrappedArrow a b c) :: * # Methods _Wrapped' :: Iso' (WrappedArrow a b c) (Unwrapped (WrappedArrow a b c)) #
Wrapped (Kleisli m a b) # |
Associated Types type Unwrapped (Kleisli m a b) :: * # Methods _Wrapped' :: Iso' (Kleisli m a b) (Unwrapped (Kleisli m a b)) #
Wrapped (Const k a x) # |
Associated Types type Unwrapped (Const k a x) :: * # Methods _Wrapped' :: Iso' (Const k a x) (Unwrapped (Const k a x)) #
Wrapped (Alt k f a) # |
Associated Types type Unwrapped (Alt k f a) :: * # Methods _Wrapped' :: Iso' (Alt k f a) (Unwrapped (Alt k f a)) #
Wrapped (TracedT m w a) # |
Associated Types type Unwrapped (TracedT m w a) :: * # Methods _Wrapped' :: Iso' (TracedT m w a) (Unwrapped (TracedT m w a)) #
Wrapped (IdentityT k m a) # |
Associated Types type Unwrapped (IdentityT k m a) :: * # Methods _Wrapped' :: Iso' (IdentityT k m a) (Unwrapped (IdentityT k m a)) #
Wrapped (Compose f g a) # |
Associated Types type Unwrapped (Compose f g a) :: * # Methods _Wrapped' :: Iso' (Compose f g a) (Unwrapped (Compose f g a)) #
Wrapped (ComposeFC f g a) # |
Associated Types type Unwrapped (ComposeFC f g a) :: * # Methods _Wrapped' :: Iso' (ComposeFC f g a) (Unwrapped (ComposeFC f g a)) #
Wrapped (ComposeCF f g a) # |
Associated Types type Unwrapped (ComposeCF f g a) :: * # Methods _Wrapped' :: Iso' (ComposeCF f g a) (Unwrapped (ComposeCF f g a)) #
Wrapped (ErrorT e m a) # |
Associated Types type Unwrapped (ErrorT e m a) :: * # Methods _Wrapped' :: Iso' (ErrorT e m a) (Unwrapped (ErrorT e m a)) #
Wrapped (StateT s m a) # |
Associated Types type Unwrapped (StateT s m a) :: * # Methods _Wrapped' :: Iso' (StateT s m a) (Unwrapped (StateT s m a)) #
Wrapped (StateT s m a) # |
Associated Types type Unwrapped (StateT s m a) :: * # Methods _Wrapped' :: Iso' (StateT s m a) (Unwrapped (StateT s m a)) #
Wrapped (WriterT w m a) # |
Associated Types type Unwrapped (WriterT w m a) :: * # Methods _Wrapped' :: Iso' (WriterT w m a) (Unwrapped (WriterT w m a)) #
Wrapped (WriterT w m a) # |
Associated Types type Unwrapped (WriterT w m a) :: * # Methods _Wrapped' :: Iso' (WriterT w m a) (Unwrapped (WriterT w m a)) #
Wrapped (Tagged k s a) # |
Associated Types type Unwrapped (Tagged k s a) :: * # Methods _Wrapped' :: Iso' (Tagged k s a) (Unwrapped (Tagged k s a)) #
Wrapped (Reverse k f a) # |
Associated Types type Unwrapped (Reverse k f a) :: * # Methods _Wrapped' :: Iso' (Reverse k f a) (Unwrapped (Reverse k f a)) #
Wrapped (Backwards k f a) # |
Associated Types type Unwrapped (Backwards k f a) :: * # Methods _Wrapped' :: Iso' (Backwards k f a) (Unwrapped (Backwards k f a)) #
Wrapped (Constant k a b) # |
Associated Types type Unwrapped (Constant k a b) :: * # Methods _Wrapped' :: Iso' (Constant k a b) (Unwrapped (Constant k a b)) #
Wrapped (ContT k r m a) # |
Associated Types type Unwrapped (ContT k r m a) :: * # Methods _Wrapped' :: Iso' (ContT k r m a) (Unwrapped (ContT k r m a)) #
Wrapped (ReaderT k r m a) # |
Associated Types type Unwrapped (ReaderT k r m a) :: * # Methods _Wrapped' :: Iso' (ReaderT k r m a) (Unwrapped (ReaderT k r m a)) #
Wrapped (Compose k k1 f g a) # |
Associated Types type Unwrapped (Compose k k1 f g a) :: * # Methods _Wrapped' :: Iso' (Compose k k1 f g a) (Unwrapped (Compose k k1 f g a)) #
Wrapped (RWST r w s m a) # |
Associated Types type Unwrapped (RWST r w s m a) :: * # Methods _Wrapped' :: Iso' (RWST r w s m a) (Unwrapped (RWST r w s m a)) #
Wrapped (RWST r w s m a) # |
Associated Types type Unwrapped (RWST r w s m a) :: * # Methods _Wrapped' :: Iso' (RWST r w s m a) (Unwrapped (RWST r w s m a)) #

_Unwrapped' :: Wrapped s => Iso' (Unwrapped s) s #

_Wrapping' :: Wrapped s => (Unwrapped s -> s) -> Iso' s (Unwrapped s) #

This is a convenient version of `_Wrapped` with an argument that's ignored.

The user supplied function is ignored, merely its type is used.

_Unwrapping' :: Wrapped s => (Unwrapped s -> s) -> Iso' (Unwrapped s) s #

This is a convenient version of `_Wrapped` with an argument that's ignored.

The user supplied function is ignored, merely its type is used.

# Wrapping and unwrapping polymorphically

class Wrapped s => Rewrapped s t #

Instances

(~) * t PatternMatchFail => Rewrapped PatternMatchFail t # |
(~) * t RecSelError => Rewrapped RecSelError t # |
(~) * t RecConError => Rewrapped RecConError t # |
(~) * t RecUpdError => Rewrapped RecUpdError t # |
(~) * t NoMethodError => Rewrapped NoMethodError t # |
(~) * t AssertionFailed => Rewrapped AssertionFailed t # |
(~) * t All => Rewrapped All t # |
(~) * t Any => Rewrapped Any t # |
(~) * t ErrorCall => Rewrapped ErrorCall t # |
(~) * t IntSet => Rewrapped IntSet t # | Use ``wrapping` `fromList``. unwrapping returns a sorted list.
(~) * t (Identity b) => Rewrapped (Identity a) t # |
(~) * t (Min b) => Rewrapped (Min a) t # |
(~) * t (Max b) => Rewrapped (Max a) t # |
(~) * t (First b) => Rewrapped (First a) t # |
(~) * t (Last b) => Rewrapped (Last a) t # |
(~) * t (WrappedMonoid b) => Rewrapped (WrappedMonoid a) t # |
(~) * t (Option b) => Rewrapped (Option a) t # |
(~) * t (NonEmpty b) => Rewrapped (NonEmpty a) t # |
(~) * t (ZipList b) => Rewrapped (ZipList a) t # |
(~) * t (Dual b) => Rewrapped (Dual a) t # |
(~) * t (Endo b) => Rewrapped (Endo b) t # |
(~) * t (Sum b) => Rewrapped (Sum a) t # |
(~) * t (Product b) => Rewrapped (Product a) t # |
(~) * t (First b) => Rewrapped (First a) t # |
(~) * t (Last b) => Rewrapped (Last a) t # |
(~) * t (Down a) => Rewrapped (Down a) t # |
(~) * t (Seq a') => Rewrapped (Seq a) t # |
(~) * t (IntMap a') => Rewrapped (IntMap a) t # | Use ``wrapping` `fromList``. unwrapping returns a sorted list.
((~) * t (Set a'), Ord a) => Rewrapped (Set a) t # | Use ``wrapping` `fromList``. unwrapping returns a sorted list.
(~) * t (Predicate b) => Rewrapped (Predicate a) t # |
(~) * t (Comparison b) => Rewrapped (Comparison a) t # |
(~) * t (Equivalence b) => Rewrapped (Equivalence a) t # |
((~) * t (HashSet a'), Hashable a, Eq a) => Rewrapped (HashSet a) t # | Use ``wrapping` `fromList``. Unwrapping returns some permutation of the list.
(~) * t (Vector a') => Rewrapped (Vector a) t # |
(Unbox a, (~) * t (Vector a')) => Rewrapped (Vector a) t # |
(Storable a, (~) * t (Vector a')) => Rewrapped (Vector a) t # |
(Prim a, (~) * t (Vector a')) => Rewrapped (Vector a) t # |
(~) * t (Op a' b') => Rewrapped (Op a b) t # |
(~) * t (WrappedMonad m' a') => Rewrapped (WrappedMonad m a) t # |
(~) * t (ArrowMonad m' a') => Rewrapped (ArrowMonad m a) t # |
((~) * t (Map k' a'), Ord k) => Rewrapped (Map k a) t # | Use ``wrapping` `fromList``. unwrapping returns a sorted list.
(~) * t (ListT n b) => Rewrapped (ListT m a) t # |
(~) * t (MaybeT n b) => Rewrapped (MaybeT m a) t # |
((~) * t (HashMap k' a'), Hashable k, Eq k) => Rewrapped (HashMap k a) t # | Use ``wrapping` `fromList``. Unwrapping returns some permutation of the list.
(~) * t (WrappedArrow a' b' c') => Rewrapped (WrappedArrow a b c) t # |
(~) * t (Kleisli m' a' b') => Rewrapped (Kleisli m a b) t # |
(~) * t (Const k a' x') => Rewrapped (Const k1 a x) t # |
(~) * t (Alt k g b) => Rewrapped (Alt k1 f a) t # |
(~) * t (TracedT m' w' a') => Rewrapped (TracedT m w a) t # |
(~) * t (IdentityT k n b) => Rewrapped (IdentityT k1 m a) t # |
(~) * t (Compose f' g' a') => Rewrapped (Compose f g a) t # |
(~) * t (ComposeFC f' g' a') => Rewrapped (ComposeFC f g a) t # |
(~) * t (ComposeCF f' g' a') => Rewrapped (ComposeCF f g a) t # |
(~) * t (ErrorT e' m' a') => Rewrapped (ErrorT e m a) t # |
(~) * t (StateT s' m' a') => Rewrapped (StateT s m a) t # |
(~) * t (StateT s' m' a') => Rewrapped (StateT s m a) t # |
(~) * t (WriterT w' m' a') => Rewrapped (WriterT w m a) t # |
(~) * t (WriterT w' m' a') => Rewrapped (WriterT w m a) t # |
(~) * t (Tagged k s' a') => Rewrapped (Tagged k1 s a) t # |
(~) * t (Reverse k g b) => Rewrapped (Reverse k1 f a) t # |
(~) * t (Backwards k g b) => Rewrapped (Backwards k1 f a) t # |
(~) * t (Constant k a' b') => Rewrapped (Constant k1 a b) t # |
(~) * t (ContT k r' m' a') => Rewrapped (ContT k1 r m a) t # |
(~) * t (ReaderT k r n b) => Rewrapped (ReaderT k1 r m a) t # |
(~) * t (Compose k k1 f' g' a') => Rewrapped (Compose k2 k3 f g a) t # |
(~) * t (RWST r' w' s' m' a') => Rewrapped (RWST r w s m a) t # |
(~) * t (RWST r' w' s' m' a') => Rewrapped (RWST r w s m a) t # |

class (Rewrapped s t, Rewrapped t s) => Rewrapping s t #

Instances

(Rewrapped s t, Rewrapped t s) => Rewrapping s t # |

_Wrapped :: Rewrapping s t => Iso s t (Unwrapped s) (Unwrapped t) #

Work under a newtype wrapper.

    >>> Const "hello" & _Wrapped %~ Prelude.length & getConst
    5

    _Wrapped   ≡ from _Unwrapped
    _Unwrapped ≡ from _Wrapped

_Unwrapped :: Rewrapping s t => Iso (Unwrapped t) (Unwrapped s) t s #

_Wrapping :: Rewrapping s t => (Unwrapped s -> s) -> Iso s t (Unwrapped s) (Unwrapped t) #

This is a convenient version of `_Wrapped` with an argument that's ignored.

The user supplied function is ignored, merely its types are used.

_Unwrapping :: Rewrapping s t => (Unwrapped s -> s) -> Iso (Unwrapped t) (Unwrapped s) t s #

This is a convenient version of `_Unwrapped` with an argument that's ignored.

The user supplied function is ignored, merely its types are used.

# Operations

op :: Wrapped s => (Unwrapped s -> s) -> s -> Unwrapped s #

Given the constructor for a `Wrapped` type, return a deconstructor that is its inverse.

Assuming the `Wrapped` instance is legal, these laws hold:

    op f . f ≡ id
    f . op f ≡ id

    >>> op Identity (Identity 4)
    4

    >>> op Const (Const "hello")
    "hello"

ala :: (Functor f, Rewrapping s t) => (Unwrapped s -> s) -> ((Unwrapped t -> t) -> f s) -> f (Unwrapped s) #

This combinator is based on `ala` from Conor McBride's work on Epigram.

As with `_Wrapping`, the user supplied function for the newtype is ignored.

    >>> ala Sum foldMap [1,2,3,4]
    10

    >>> ala All foldMap [True,True]
    True

    >>> ala All foldMap [True,False]
    False

    >>> ala Any foldMap [False,False]
    False

    >>> ala Any foldMap [True,False]
    True

    >>> ala Sum foldMap [1,2,3,4]
    10

    >>> ala Product foldMap [1,2,3,4]
    24

You may want to think of this combinator as having the following, simpler, type.

    ala :: Rewrapping s t => (Unwrapped s -> s) -> ((Unwrapped t -> t) -> e -> s) -> e -> Unwrapped s

alaf :: (Functor f, Functor g, Rewrapping s t) => (Unwrapped s -> s) -> (f t -> g s) -> f (Unwrapped t) -> g (Unwrapped s) #

This combinator is based on `ala'` from Conor McBride's work on Epigram.

As with `_Wrapping`, the user supplied function for the newtype is ignored.

    alaf :: Rewrapping s t => (Unwrapped s -> s) -> ((r ->  t) -> e -> s) -> (r -> Unwrapped t) -> e -> Unwrapped s

    >>> alaf Sum foldMap Prelude.length ["hello","world"]
    10

# Pattern Synonyms

pattern Wrapped :: forall s. Rewrapped s s => Unwrapped s -> s #

pattern Unwrapped :: forall t. Rewrapped t t => t -> Unwrapped t #