lens-4.15.3: 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
- Generics

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
- _GWrapped' :: (Generic s, D1 d (C1 c (S1 s' (Rec0 a))) ~ Rep s, Unwrapped s ~ GUnwrapped (Rep s)) => Iso' s (Unwrapped s)

# 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`.

If your type has a `Generic` instance, `_Wrapped'` will default to `_GWrapped'`, and you can choose to not override it with your own definition.

_Wrapped' :: (Generic s, D1 d (C1 c (S1 s' (Rec0 a))) ~ Rep s, Unwrapped s ~ GUnwrapped (Rep s)) => Iso' s (Unwrapped s) #

An isomorphism between `s` and `a`.

If your type has a `Generic` instance, `_Wrapped'` will default to `_GWrapped'`, and you can choose to not override it with your own definition.

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 TypeError # |
Associated Types type Unwrapped TypeError :: * # Methods _Wrapped' :: Iso' TypeError (Unwrapped TypeError) #
Wrapped CDev # |
Associated Types type Unwrapped CDev :: * # Methods _Wrapped' :: Iso' CDev (Unwrapped CDev) #
Wrapped CIno # |
Associated Types type Unwrapped CIno :: * # Methods _Wrapped' :: Iso' CIno (Unwrapped CIno) #
Wrapped CMode # |
Associated Types type Unwrapped CMode :: * # Methods _Wrapped' :: Iso' CMode (Unwrapped CMode) #
Wrapped COff # |
Associated Types type Unwrapped COff :: * # Methods _Wrapped' :: Iso' COff (Unwrapped COff) #
Wrapped CPid # |
Associated Types type Unwrapped CPid :: * # Methods _Wrapped' :: Iso' CPid (Unwrapped CPid) #
Wrapped CSsize # |
Associated Types type Unwrapped CSsize :: * # Methods _Wrapped' :: Iso' CSsize (Unwrapped CSsize) #
Wrapped CGid # |
Associated Types type Unwrapped CGid :: * # Methods _Wrapped' :: Iso' CGid (Unwrapped CGid) #
Wrapped CNlink # |
Associated Types type Unwrapped CNlink :: * # Methods _Wrapped' :: Iso' CNlink (Unwrapped CNlink) #
Wrapped CUid # |
Associated Types type Unwrapped CUid :: * # Methods _Wrapped' :: Iso' CUid (Unwrapped CUid) #
Wrapped CCc # |
Associated Types type Unwrapped CCc :: * # Methods _Wrapped' :: Iso' CCc (Unwrapped CCc) #
Wrapped CSpeed # |
Associated Types type Unwrapped CSpeed :: * # Methods _Wrapped' :: Iso' CSpeed (Unwrapped CSpeed) #
Wrapped CTcflag # |
Associated Types type Unwrapped CTcflag :: * # Methods _Wrapped' :: Iso' CTcflag (Unwrapped CTcflag) #
Wrapped CRLim # |
Associated Types type Unwrapped CRLim :: * # Methods _Wrapped' :: Iso' CRLim (Unwrapped CRLim) #
Wrapped Fd # |
Associated Types type Unwrapped Fd :: * # Methods _Wrapped' :: Iso' Fd (Unwrapped Fd) #
Wrapped Errno # |
Associated Types type Unwrapped Errno :: * # Methods _Wrapped' :: Iso' Errno (Unwrapped Errno) #
Wrapped AssertionFailed # |
Associated Types type Unwrapped AssertionFailed :: * # Methods _Wrapped' :: Iso' AssertionFailed (Unwrapped AssertionFailed) #
Wrapped CChar # |
Associated Types type Unwrapped CChar :: * # Methods _Wrapped' :: Iso' CChar (Unwrapped CChar) #
Wrapped CSChar # |
Associated Types type Unwrapped CSChar :: * # Methods _Wrapped' :: Iso' CSChar (Unwrapped CSChar) #
Wrapped CUChar # |
Associated Types type Unwrapped CUChar :: * # Methods _Wrapped' :: Iso' CUChar (Unwrapped CUChar) #
Wrapped CShort # |
Associated Types type Unwrapped CShort :: * # Methods _Wrapped' :: Iso' CShort (Unwrapped CShort) #
Wrapped CUShort # |
Associated Types type Unwrapped CUShort :: * # Methods _Wrapped' :: Iso' CUShort (Unwrapped CUShort) #
Wrapped CInt # |
Associated Types type Unwrapped CInt :: * # Methods _Wrapped' :: Iso' CInt (Unwrapped CInt) #
Wrapped CUInt # |
Associated Types type Unwrapped CUInt :: * # Methods _Wrapped' :: Iso' CUInt (Unwrapped CUInt) #
Wrapped CLong # |
Associated Types type Unwrapped CLong :: * # Methods _Wrapped' :: Iso' CLong (Unwrapped CLong) #
Wrapped CULong # |
Associated Types type Unwrapped CULong :: * # Methods _Wrapped' :: Iso' CULong (Unwrapped CULong) #
Wrapped CLLong # |
Associated Types type Unwrapped CLLong :: * # Methods _Wrapped' :: Iso' CLLong (Unwrapped CLLong) #
Wrapped CULLong # |
Associated Types type Unwrapped CULLong :: * # Methods _Wrapped' :: Iso' CULLong (Unwrapped CULLong) #
Wrapped CFloat # |
Associated Types type Unwrapped CFloat :: * # Methods _Wrapped' :: Iso' CFloat (Unwrapped CFloat) #
Wrapped CDouble # |
Associated Types type Unwrapped CDouble :: * # Methods _Wrapped' :: Iso' CDouble (Unwrapped CDouble) #
Wrapped CPtrdiff # |
Associated Types type Unwrapped CPtrdiff :: * # Methods _Wrapped' :: Iso' CPtrdiff (Unwrapped CPtrdiff) #
Wrapped CSize # |
Associated Types type Unwrapped CSize :: * # Methods _Wrapped' :: Iso' CSize (Unwrapped CSize) #
Wrapped CWchar # |
Associated Types type Unwrapped CWchar :: * # Methods _Wrapped' :: Iso' CWchar (Unwrapped CWchar) #
Wrapped CSigAtomic # |
Associated Types type Unwrapped CSigAtomic :: * # Methods _Wrapped' :: Iso' CSigAtomic (Unwrapped CSigAtomic) #
Wrapped CClock # |
Associated Types type Unwrapped CClock :: * # Methods _Wrapped' :: Iso' CClock (Unwrapped CClock) #
Wrapped CTime # |
Associated Types type Unwrapped CTime :: * # Methods _Wrapped' :: Iso' CTime (Unwrapped CTime) #
Wrapped CUSeconds # |
Associated Types type Unwrapped CUSeconds :: * # Methods _Wrapped' :: Iso' CUSeconds (Unwrapped CUSeconds) #
Wrapped CSUSeconds # |
Associated Types type Unwrapped CSUSeconds :: * # Methods _Wrapped' :: Iso' CSUSeconds (Unwrapped CSUSeconds) #
Wrapped CIntPtr # |
Associated Types type Unwrapped CIntPtr :: * # Methods _Wrapped' :: Iso' CIntPtr (Unwrapped CIntPtr) #
Wrapped CUIntPtr # |
Associated Types type Unwrapped CUIntPtr :: * # Methods _Wrapped' :: Iso' CUIntPtr (Unwrapped CUIntPtr) #
Wrapped CIntMax # |
Associated Types type Unwrapped CIntMax :: * # Methods _Wrapped' :: Iso' CIntMax (Unwrapped CIntMax) #
Wrapped CUIntMax # |
Associated Types type Unwrapped CUIntMax :: * # Methods _Wrapped' :: Iso' CUIntMax (Unwrapped CUIntMax) #
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 (Par1 p) # |
Associated Types type Unwrapped (Par1 p) :: * # Methods _Wrapped' :: Iso' (Par1 p) (Unwrapped (Par1 p)) #
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 (IntMap a) # |
Associated Types type Unwrapped (IntMap a) :: * # Methods _Wrapped' :: Iso' (IntMap a) (Unwrapped (IntMap a)) #
Wrapped (Seq a) # |
Associated Types type Unwrapped (Seq a) :: * # Methods _Wrapped' :: Iso' (Seq a) (Unwrapped (Seq 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)) #
Storable 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)) #
Prim a => Wrapped (Vector a) # |
Associated Types type Unwrapped (Vector a) :: * # Methods _Wrapped' :: Iso' (Vector a) (Unwrapped (Vector a)) #
Wrapped (Rec1 f p) # |
Associated Types type Unwrapped (Rec1 f p) :: * # Methods _Wrapped' :: Iso' (Rec1 f p) (Unwrapped (Rec1 f p)) #
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 (CatchT m a) # |
Associated Types type Unwrapped (CatchT m a) :: * # Methods _Wrapped' :: Iso' (CatchT m a) (Unwrapped (CatchT m a)) #
Wrapped (Alt f a) # |
Associated Types type Unwrapped (Alt f a) :: * # Methods _Wrapped' :: Iso' (Alt f a) (Unwrapped (Alt f a)) #
Wrapped (CoiterT w a) # |
Associated Types type Unwrapped (CoiterT w a) :: * # Methods _Wrapped' :: Iso' (CoiterT w a) (Unwrapped (CoiterT w a)) #
Wrapped (IterT m a) # |
Associated Types type Unwrapped (IterT m a) :: * # Methods _Wrapped' :: Iso' (IterT m a) (Unwrapped (IterT m a)) #
Wrapped (ListT m a) # |
Associated Types type Unwrapped (ListT m a) :: * # Methods _Wrapped' :: Iso' (ListT m a) (Unwrapped (ListT 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 (WrappedApplicative f a) # |
Associated Types type Unwrapped (WrappedApplicative f a) :: * # Methods _Wrapped' :: Iso' (WrappedApplicative f a) (Unwrapped (WrappedApplicative f a)) #
Wrapped (MaybeApply f a) # |
Associated Types type Unwrapped (MaybeApply f a) :: * # Methods _Wrapped' :: Iso' (MaybeApply f a) (Unwrapped (MaybeApply f a)) #
Wrapped (MaybeT m a) # |
Associated Types type Unwrapped (MaybeT m a) :: * # Methods _Wrapped' :: Iso' (MaybeT m a) (Unwrapped (MaybeT m a)) #
Wrapped (K1 i c p) # |
Associated Types type Unwrapped (K1 i c p) :: * # Methods _Wrapped' :: Iso' (K1 i c p) (Unwrapped (K1 i c p)) #
Wrapped ((:.:) f g p) # |
Associated Types type Unwrapped ((:.:) f g p) :: * # Methods _Wrapped' :: Iso' ((f :.: g) p) (Unwrapped ((f :.: g) p)) #
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 (Join k p a) # |
Associated Types type Unwrapped (Join k p a) :: * # Methods _Wrapped' :: Iso' (Join k p a) (Unwrapped (Join k p a)) #
Wrapped (Fix k p a) # |
Associated Types type Unwrapped (Fix k p a) :: * # Methods _Wrapped' :: Iso' (Fix k p a) (Unwrapped (Fix k p 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 (ApT f g a) # |
Associated Types type Unwrapped (ApT f g a) :: * # Methods _Wrapped' :: Iso' (ApT f g a) (Unwrapped (ApT f g a)) #
Wrapped (CofreeT f w a) # |
Associated Types type Unwrapped (CofreeT f w a) :: * # Methods _Wrapped' :: Iso' (CofreeT f w a) (Unwrapped (CofreeT f w a)) #
Wrapped (FreeT f m a) # |
Associated Types type Unwrapped (FreeT f m a) :: * # Methods _Wrapped' :: Iso' (FreeT f m a) (Unwrapped (FreeT f m 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 (ExceptT e m a) # |
Associated Types type Unwrapped (ExceptT e m a) :: * # Methods _Wrapped' :: Iso' (ExceptT e m a) (Unwrapped (ExceptT 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 (Star f d c) # |
Associated Types type Unwrapped (Star f d c) :: * # Methods _Wrapped' :: Iso' (Star f d c) (Unwrapped (Star f d c)) #
Wrapped (Costar f d c) # |
Associated Types type Unwrapped (Costar f d c) :: * # Methods _Wrapped' :: Iso' (Costar f d c) (Unwrapped (Costar f d c)) #
Wrapped (WrappedArrow p a b) # |
Associated Types type Unwrapped (WrappedArrow p a b) :: * # Methods _Wrapped' :: Iso' (WrappedArrow p a b) (Unwrapped (WrappedArrow p a b)) #
Wrapped (Forget r a b) # |
Associated Types type Unwrapped (Forget r a b) :: * # Methods _Wrapped' :: Iso' (Forget r a b) (Unwrapped (Forget r a b)) #
Wrapped (Static f a b) # |
Associated Types type Unwrapped (Static f a b) :: * # Methods _Wrapped' :: Iso' (Static f a b) (Unwrapped (Static f a b)) #
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 (M1 i c f p) # |
Associated Types type Unwrapped (M1 i c f p) :: * # Methods _Wrapped' :: Iso' (M1 i c f p) (Unwrapped (M1 i c f p)) #
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 (Cayley f p a b) # |
Associated Types type Unwrapped (Cayley f p a b) :: * # Methods _Wrapped' :: Iso' (Cayley f p a b) (Unwrapped (Cayley f p a b)) #
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 (WrappedBifunctor k k1 p a b) # |
Associated Types type Unwrapped (WrappedBifunctor k k1 p a b) :: * # Methods _Wrapped' :: Iso' (WrappedBifunctor k k1 p a b) (Unwrapped (WrappedBifunctor k k1 p a b)) #
Wrapped (Joker k k1 g a b) # |
Associated Types type Unwrapped (Joker k k1 g a b) :: * # Methods _Wrapped' :: Iso' (Joker k k1 g a b) (Unwrapped (Joker k k1 g a b)) #
Wrapped (Flip k k1 p a b) # |
Associated Types type Unwrapped (Flip k k1 p a b) :: * # Methods _Wrapped' :: Iso' (Flip k k1 p a b) (Unwrapped (Flip k k1 p a b)) #
Wrapped (Clown k k1 f a b) # |
Associated Types type Unwrapped (Clown k k1 f a b) :: * # Methods _Wrapped' :: Iso' (Clown k k1 f a b) (Unwrapped (Clown k k1 f a b)) #
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)) #
Wrapped (Dual k k1 k2 a b) # |
Associated Types type Unwrapped (Dual k k1 k2 a b) :: * # Methods _Wrapped' :: Iso' (Dual k k1 k2 a b) (Unwrapped (Dual k k1 k2 a b)) #
Wrapped (WrappedCategory k k1 k2 a b) # |
Associated Types type Unwrapped (WrappedCategory k k1 k2 a b) :: * # Methods _Wrapped' :: Iso' (WrappedCategory k k1 k2 a b) (Unwrapped (WrappedCategory k k1 k2 a b)) #
Wrapped (Semi k k1 m a b) # |
Associated Types type Unwrapped (Semi k k1 m a b) :: * # Methods _Wrapped' :: Iso' (Semi k k1 m a b) (Unwrapped (Semi k k1 m a b)) #
Wrapped (Tannen k k1 k2 f p a b) # |
Associated Types type Unwrapped (Tannen k k1 k2 f p a b) :: * # Methods _Wrapped' :: Iso' (Tannen k k1 k2 f p a b) (Unwrapped (Tannen k k1 k2 f p a b)) #
Wrapped (Biff k k1 k2 k3 p f g a b) # |
Associated Types type Unwrapped (Biff k k1 k2 k3 p f g a b) :: * # Methods _Wrapped' :: Iso' (Biff k k1 k2 k3 p f g a b) (Unwrapped (Biff k k1 k2 k3 p f g a b)) #

_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 TypeError => Rewrapped TypeError t # |
Rewrapped CDev t # |
Rewrapped CIno t # |
Rewrapped CMode t # |
Rewrapped COff t # |
Rewrapped CPid t # |
Rewrapped CSsize t # |
Rewrapped CGid t # |
Rewrapped CNlink t # |
Rewrapped CUid t # |
Rewrapped CCc t # |
Rewrapped CSpeed t # |
Rewrapped CTcflag t # |
Rewrapped CRLim t # |
Rewrapped Fd t # |
Rewrapped Errno t # |
(~) * t AssertionFailed => Rewrapped AssertionFailed t # |
Rewrapped CChar t # |
Rewrapped CSChar t # |
Rewrapped CUChar t # |
Rewrapped CShort t # |
Rewrapped CUShort t # |
Rewrapped CInt t # |
Rewrapped CUInt t # |
Rewrapped CLong t # |
Rewrapped CULong t # |
Rewrapped CLLong t # |
Rewrapped CULLong t # |
Rewrapped CFloat t # |
Rewrapped CDouble t # |
Rewrapped CPtrdiff t # |
Rewrapped CSize t # |
Rewrapped CWchar t # |
Rewrapped CSigAtomic t # |
Rewrapped CClock t # |
Rewrapped CTime t # |
Rewrapped CUSeconds t # |
Rewrapped CSUSeconds t # |
Rewrapped CIntPtr t # |
Rewrapped CUIntPtr t # |
Rewrapped CIntMax t # |
Rewrapped CUIntMax 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 (Par1 p') => Rewrapped (Par1 p) t # |
(~) * 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 a) 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 b) => Rewrapped (Down a) t # |
(~) * t (IntMap a') => Rewrapped (IntMap a) t # | Use ``wrapping` `fromList``. unwrapping returns a sorted list.
(~) * t (Seq a') => Rewrapped (Seq a) t # |
((~) * 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 # |
(Storable a, (~) * t (Vector a')) => Rewrapped (Vector a) t # |
(Unbox a, (~) * t (Vector a')) => Rewrapped (Vector a) t # |
(Prim a, (~) * t (Vector a')) => Rewrapped (Vector a) t # |
(~) * t (Rec1 f' p') => Rewrapped (Rec1 f p) 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 (CatchT m' a') => Rewrapped (CatchT m a) t # |
(~) * t (Alt f' a') => Rewrapped (Alt f a) t # |
(~) * t (CoiterT w' a') => Rewrapped (CoiterT w a) t # |
(~) * t (IterT m' a') => Rewrapped (IterT m a) t # |
(~) * t (ListT n b) => Rewrapped (ListT 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 (WrappedApplicative f' a') => Rewrapped (WrappedApplicative f a) t # |
(~) * t (MaybeApply f' a') => Rewrapped (MaybeApply f a) t # |
(~) * t (MaybeT n b) => Rewrapped (MaybeT m a) t # |
(~) * t (K1 i' c' p') => Rewrapped (K1 i c p) t # |
(~) * t ((:.:) f' g' p') => Rewrapped ((:.:) f g p) t # |
(~) * t (WrappedArrow a' b' c') => Rewrapped (WrappedArrow a b c) t # |
(~) * t (Kleisli m' a' b') => Rewrapped (Kleisli m a b) t # |
(~) * t (Const k1 a' x') => Rewrapped (Const k a x) t # |
(~) * t (Alt k1 g b) => Rewrapped (Alt k f a) t # |
(~) * t (Join k1 p' a') => Rewrapped (Join k p a) t # |
(~) * t (Fix k1 p' a') => Rewrapped (Fix k p a) t # |
(~) * t (TracedT m' w' a') => Rewrapped (TracedT m w a) t # |
(~) * t (IdentityT k1 n b) => Rewrapped (IdentityT k 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 (ApT f' g' a') => Rewrapped (ApT f g a) t # |
(~) * t (CofreeT f' w' a') => Rewrapped (CofreeT f w a) t # |
(~) * t (FreeT f' m' a') => Rewrapped (FreeT f m a) t # |
(~) * t (ErrorT e' m' a') => Rewrapped (ErrorT e m a) t # |
(~) * t (ExceptT e' m' a') => Rewrapped (ExceptT 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 (Star f' d' c') => Rewrapped (Star f d c) t # |
(~) * t (Costar f' d' c') => Rewrapped (Costar f d c) t # |
(~) * t (WrappedArrow p' a' b') => Rewrapped (WrappedArrow p a b) t # |
(~) * t (Forget r' a' b') => Rewrapped (Forget r a b) t # |
(~) * t (Static f' a' b') => Rewrapped (Static f a b) t # |
(~) * t (Tagged k1 s' a') => Rewrapped (Tagged k s a) t # |
(~) * t (Reverse k1 g b) => Rewrapped (Reverse k f a) t # |
(~) * t (Backwards k1 g b) => Rewrapped (Backwards k f a) t # |
(~) * t (Constant k1 a' b') => Rewrapped (Constant k a b) t # |
(~) * t (M1 i' c' f' p') => Rewrapped (M1 i c f p) t # |
(~) * t (ContT k1 r' m' a') => Rewrapped (ContT k r m a) t # |
(~) * t (ReaderT k1 s n b) => Rewrapped (ReaderT k r m a) t # |
(~) * t (Cayley f' p' a' b') => Rewrapped (Cayley f p a b) t # |
(~) * t (Compose k2 k3 f' g' a') => Rewrapped (Compose k k1 f g a) t # |
(~) * t (WrappedBifunctor k2 k3 p' a' b') => Rewrapped (WrappedBifunctor k k1 p a b) t # |
(~) * t (Joker k2 k3 g' a' b') => Rewrapped (Joker k k1 g a b) t # |
(~) * t (Flip k2 k3 p' a' b') => Rewrapped (Flip k k1 p a b) t # |
(~) * t (Clown k2 k3 f' a' b') => Rewrapped (Clown k k1 f a b) 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 # |
(~) * t (Dual k2 k3 k' a' b') => Rewrapped (Dual k k1 k4 a b) t # |
(~) * t (WrappedCategory k2 k3 k' a' b') => Rewrapped (WrappedCategory k k1 k4 a b) t # |
(~) * t (Semi k2 k3 m' a' b') => Rewrapped (Semi k k1 m a b) t # |
(~) * t (Tannen k4 k5 k6 f' p' a' b') => Rewrapped (Tannen k k1 k2 f p a b) t # |
(~) * t (Biff k4 k5 k6 k7 p' f' g' a' b') => Rewrapped (Biff k k1 k2 k3 p f g a b) 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 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 #

# Generics

_GWrapped' :: (Generic s, D1 d (C1 c (S1 s' (Rec0 a))) ~ Rep s, Unwrapped s ~ GUnwrapped (Rep s)) => Iso' s (Unwrapped s) #

Implement the `_Wrapped` operation for a type using its `Generic` instance.