lens-4.15.4: 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 Source #

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

Associated Types

type Unwrapped s :: * Source #

Methods

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

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) Source #

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 Source # |
Associated Types type Unwrapped PatternMatchFail :: * Source # Methods _Wrapped' :: Iso' PatternMatchFail (Unwrapped PatternMatchFail) Source #
Wrapped RecSelError Source # |
Associated Types type Unwrapped RecSelError :: * Source # Methods _Wrapped' :: Iso' RecSelError (Unwrapped RecSelError) Source #
Wrapped RecConError Source # |
Associated Types type Unwrapped RecConError :: * Source # Methods _Wrapped' :: Iso' RecConError (Unwrapped RecConError) Source #
Wrapped RecUpdError Source # |
Associated Types type Unwrapped RecUpdError :: * Source # Methods _Wrapped' :: Iso' RecUpdError (Unwrapped RecUpdError) Source #
Wrapped NoMethodError Source # |
Associated Types type Unwrapped NoMethodError :: * Source # Methods _Wrapped' :: Iso' NoMethodError (Unwrapped NoMethodError) Source #
Wrapped TypeError Source # |
Associated Types type Unwrapped TypeError :: * Source # Methods _Wrapped' :: Iso' TypeError (Unwrapped TypeError) Source #
Wrapped CDev Source # |
Associated Types type Unwrapped CDev :: * Source # Methods _Wrapped' :: Iso' CDev (Unwrapped CDev) Source #
Wrapped CIno Source # |
Associated Types type Unwrapped CIno :: * Source # Methods _Wrapped' :: Iso' CIno (Unwrapped CIno) Source #
Wrapped CMode Source # |
Associated Types type Unwrapped CMode :: * Source # Methods _Wrapped' :: Iso' CMode (Unwrapped CMode) Source #
Wrapped COff Source # |
Associated Types type Unwrapped COff :: * Source # Methods _Wrapped' :: Iso' COff (Unwrapped COff) Source #
Wrapped CPid Source # |
Associated Types type Unwrapped CPid :: * Source # Methods _Wrapped' :: Iso' CPid (Unwrapped CPid) Source #
Wrapped CSsize Source # |
Associated Types type Unwrapped CSsize :: * Source # Methods _Wrapped' :: Iso' CSsize (Unwrapped CSsize) Source #
Wrapped CGid Source # |
Associated Types type Unwrapped CGid :: * Source # Methods _Wrapped' :: Iso' CGid (Unwrapped CGid) Source #
Wrapped CNlink Source # |
Associated Types type Unwrapped CNlink :: * Source # Methods _Wrapped' :: Iso' CNlink (Unwrapped CNlink) Source #
Wrapped CUid Source # |
Associated Types type Unwrapped CUid :: * Source # Methods _Wrapped' :: Iso' CUid (Unwrapped CUid) Source #
Wrapped CCc Source # |
Associated Types type Unwrapped CCc :: * Source # Methods _Wrapped' :: Iso' CCc (Unwrapped CCc) Source #
Wrapped CSpeed Source # |
Associated Types type Unwrapped CSpeed :: * Source # Methods _Wrapped' :: Iso' CSpeed (Unwrapped CSpeed) Source #
Wrapped CTcflag Source # |
Associated Types type Unwrapped CTcflag :: * Source # Methods _Wrapped' :: Iso' CTcflag (Unwrapped CTcflag) Source #
Wrapped CRLim Source # |
Associated Types type Unwrapped CRLim :: * Source # Methods _Wrapped' :: Iso' CRLim (Unwrapped CRLim) Source #
Wrapped Fd Source # |
Associated Types type Unwrapped Fd :: * Source # Methods _Wrapped' :: Iso' Fd (Unwrapped Fd) Source #
Wrapped Errno Source # |
Associated Types type Unwrapped Errno :: * Source # Methods _Wrapped' :: Iso' Errno (Unwrapped Errno) Source #
Wrapped AssertionFailed Source # |
Associated Types type Unwrapped AssertionFailed :: * Source # Methods _Wrapped' :: Iso' AssertionFailed (Unwrapped AssertionFailed) Source #
Wrapped CChar Source # |
Associated Types type Unwrapped CChar :: * Source # Methods _Wrapped' :: Iso' CChar (Unwrapped CChar) Source #
Wrapped CSChar Source # |
Associated Types type Unwrapped CSChar :: * Source # Methods _Wrapped' :: Iso' CSChar (Unwrapped CSChar) Source #
Wrapped CUChar Source # |
Associated Types type Unwrapped CUChar :: * Source # Methods _Wrapped' :: Iso' CUChar (Unwrapped CUChar) Source #
Wrapped CShort Source # |
Associated Types type Unwrapped CShort :: * Source # Methods _Wrapped' :: Iso' CShort (Unwrapped CShort) Source #
Wrapped CUShort Source # |
Associated Types type Unwrapped CUShort :: * Source # Methods _Wrapped' :: Iso' CUShort (Unwrapped CUShort) Source #
Wrapped CInt Source # |
Associated Types type Unwrapped CInt :: * Source # Methods _Wrapped' :: Iso' CInt (Unwrapped CInt) Source #
Wrapped CUInt Source # |
Associated Types type Unwrapped CUInt :: * Source # Methods _Wrapped' :: Iso' CUInt (Unwrapped CUInt) Source #
Wrapped CLong Source # |
Associated Types type Unwrapped CLong :: * Source # Methods _Wrapped' :: Iso' CLong (Unwrapped CLong) Source #
Wrapped CULong Source # |
Associated Types type Unwrapped CULong :: * Source # Methods _Wrapped' :: Iso' CULong (Unwrapped CULong) Source #
Wrapped CLLong Source # |
Associated Types type Unwrapped CLLong :: * Source # Methods _Wrapped' :: Iso' CLLong (Unwrapped CLLong) Source #
Wrapped CULLong Source # |
Associated Types type Unwrapped CULLong :: * Source # Methods _Wrapped' :: Iso' CULLong (Unwrapped CULLong) Source #
Wrapped CFloat Source # |
Associated Types type Unwrapped CFloat :: * Source # Methods _Wrapped' :: Iso' CFloat (Unwrapped CFloat) Source #
Wrapped CDouble Source # |
Associated Types type Unwrapped CDouble :: * Source # Methods _Wrapped' :: Iso' CDouble (Unwrapped CDouble) Source #
Wrapped CPtrdiff Source # |
Associated Types type Unwrapped CPtrdiff :: * Source # Methods _Wrapped' :: Iso' CPtrdiff (Unwrapped CPtrdiff) Source #
Wrapped CSize Source # |
Associated Types type Unwrapped CSize :: * Source # Methods _Wrapped' :: Iso' CSize (Unwrapped CSize) Source #
Wrapped CWchar Source # |
Associated Types type Unwrapped CWchar :: * Source # Methods _Wrapped' :: Iso' CWchar (Unwrapped CWchar) Source #
Wrapped CSigAtomic Source # |
Associated Types type Unwrapped CSigAtomic :: * Source # Methods _Wrapped' :: Iso' CSigAtomic (Unwrapped CSigAtomic) Source #
Wrapped CClock Source # |
Associated Types type Unwrapped CClock :: * Source # Methods _Wrapped' :: Iso' CClock (Unwrapped CClock) Source #
Wrapped CTime Source # |
Associated Types type Unwrapped CTime :: * Source # Methods _Wrapped' :: Iso' CTime (Unwrapped CTime) Source #
Wrapped CUSeconds Source # |
Associated Types type Unwrapped CUSeconds :: * Source # Methods _Wrapped' :: Iso' CUSeconds (Unwrapped CUSeconds) Source #
Wrapped CSUSeconds Source # |
Associated Types type Unwrapped CSUSeconds :: * Source # Methods _Wrapped' :: Iso' CSUSeconds (Unwrapped CSUSeconds) Source #
Wrapped CIntPtr Source # |
Associated Types type Unwrapped CIntPtr :: * Source # Methods _Wrapped' :: Iso' CIntPtr (Unwrapped CIntPtr) Source #
Wrapped CUIntPtr Source # |
Associated Types type Unwrapped CUIntPtr :: * Source # Methods _Wrapped' :: Iso' CUIntPtr (Unwrapped CUIntPtr) Source #
Wrapped CIntMax Source # |
Associated Types type Unwrapped CIntMax :: * Source # Methods _Wrapped' :: Iso' CIntMax (Unwrapped CIntMax) Source #
Wrapped CUIntMax Source # |
Associated Types type Unwrapped CUIntMax :: * Source # Methods _Wrapped' :: Iso' CUIntMax (Unwrapped CUIntMax) Source #
Wrapped All Source # |
Associated Types type Unwrapped All :: * Source # Methods _Wrapped' :: Iso' All (Unwrapped All) Source #
Wrapped Any Source # |
Associated Types type Unwrapped Any :: * Source # Methods _Wrapped' :: Iso' Any (Unwrapped Any) Source #
Wrapped ErrorCall Source # |
Associated Types type Unwrapped ErrorCall :: * Source # Methods _Wrapped' :: Iso' ErrorCall (Unwrapped ErrorCall) Source #
Wrapped IntSet Source # |
Associated Types type Unwrapped IntSet :: * Source # Methods _Wrapped' :: Iso' IntSet (Unwrapped IntSet) Source #
Wrapped (Par1 p) Source # |
Associated Types type Unwrapped (Par1 p) :: * Source # Methods _Wrapped' :: Iso' (Par1 p) (Unwrapped (Par1 p)) Source #
Wrapped (Identity a) Source # |
Associated Types type Unwrapped (Identity a) :: * Source # Methods _Wrapped' :: Iso' (Identity a) (Unwrapped (Identity a)) Source #
Wrapped (Min a) Source # |
Associated Types type Unwrapped (Min a) :: * Source # Methods _Wrapped' :: Iso' (Min a) (Unwrapped (Min a)) Source #
Wrapped (Max a) Source # |
Associated Types type Unwrapped (Max a) :: * Source # Methods _Wrapped' :: Iso' (Max a) (Unwrapped (Max a)) Source #
Wrapped (First a) Source # |
Associated Types type Unwrapped (First a) :: * Source # Methods _Wrapped' :: Iso' (First a) (Unwrapped (First a)) Source #
Wrapped (Last a) Source # |
Associated Types type Unwrapped (Last a) :: * Source # Methods _Wrapped' :: Iso' (Last a) (Unwrapped (Last a)) Source #
Wrapped (WrappedMonoid a) Source # |
Associated Types type Unwrapped (WrappedMonoid a) :: * Source # Methods _Wrapped' :: Iso' (WrappedMonoid a) (Unwrapped (WrappedMonoid a)) Source #
Wrapped (Option a) Source # |
Associated Types type Unwrapped (Option a) :: * Source # Methods _Wrapped' :: Iso' (Option a) (Unwrapped (Option a)) Source #
Wrapped (NonEmpty a) Source # |
Associated Types type Unwrapped (NonEmpty a) :: * Source # Methods _Wrapped' :: Iso' (NonEmpty a) (Unwrapped (NonEmpty a)) Source #
Wrapped (ZipList a) Source # |
Associated Types type Unwrapped (ZipList a) :: * Source # Methods _Wrapped' :: Iso' (ZipList a) (Unwrapped (ZipList a)) Source #
Wrapped (Dual a) Source # |
Associated Types type Unwrapped (Dual a) :: * Source # Methods _Wrapped' :: Iso' (Dual a) (Unwrapped (Dual a)) Source #
Wrapped (Endo a) Source # |
Associated Types type Unwrapped (Endo a) :: * Source # Methods _Wrapped' :: Iso' (Endo a) (Unwrapped (Endo a)) Source #
Wrapped (Sum a) Source # |
Associated Types type Unwrapped (Sum a) :: * Source # Methods _Wrapped' :: Iso' (Sum a) (Unwrapped (Sum a)) Source #
Wrapped (Product a) Source # |
Associated Types type Unwrapped (Product a) :: * Source # Methods _Wrapped' :: Iso' (Product a) (Unwrapped (Product a)) Source #
Wrapped (First a) Source # |
Associated Types type Unwrapped (First a) :: * Source # Methods _Wrapped' :: Iso' (First a) (Unwrapped (First a)) Source #
Wrapped (Last a) Source # |
Associated Types type Unwrapped (Last a) :: * Source # Methods _Wrapped' :: Iso' (Last a) (Unwrapped (Last a)) Source #
Wrapped (Down a) Source # |
Associated Types type Unwrapped (Down a) :: * Source # Methods _Wrapped' :: Iso' (Down a) (Unwrapped (Down a)) Source #
Wrapped (IntMap a) Source # |
Associated Types type Unwrapped (IntMap a) :: * Source # Methods _Wrapped' :: Iso' (IntMap a) (Unwrapped (IntMap a)) Source #
Wrapped (Seq a) Source # |
Associated Types type Unwrapped (Seq a) :: * Source # Methods _Wrapped' :: Iso' (Seq a) (Unwrapped (Seq a)) Source #
Ord a => Wrapped (Set a) Source # |
Associated Types type Unwrapped (Set a) :: * Source # Methods _Wrapped' :: Iso' (Set a) (Unwrapped (Set a)) Source #
Wrapped (Predicate a) Source # |
Associated Types type Unwrapped (Predicate a) :: * Source # Methods _Wrapped' :: Iso' (Predicate a) (Unwrapped (Predicate a)) Source #
Wrapped (Comparison a) Source # |
Associated Types type Unwrapped (Comparison a) :: * Source # Methods _Wrapped' :: Iso' (Comparison a) (Unwrapped (Comparison a)) Source #
Wrapped (Equivalence a) Source # |
Associated Types type Unwrapped (Equivalence a) :: * Source # Methods _Wrapped' :: Iso' (Equivalence a) (Unwrapped (Equivalence a)) Source #
(Hashable a, Eq a) => Wrapped (HashSet a) Source # |
Associated Types type Unwrapped (HashSet a) :: * Source # Methods _Wrapped' :: Iso' (HashSet a) (Unwrapped (HashSet a)) Source #
Wrapped (Vector a) Source # |
Associated Types type Unwrapped (Vector a) :: * Source # Methods _Wrapped' :: Iso' (Vector a) (Unwrapped (Vector a)) Source #
Storable a => Wrapped (Vector a) Source # |
Associated Types type Unwrapped (Vector a) :: * Source # Methods _Wrapped' :: Iso' (Vector a) (Unwrapped (Vector a)) Source #
Unbox a => Wrapped (Vector a) Source # |
Associated Types type Unwrapped (Vector a) :: * Source # Methods _Wrapped' :: Iso' (Vector a) (Unwrapped (Vector a)) Source #
Prim a => Wrapped (Vector a) Source # |
Associated Types type Unwrapped (Vector a) :: * Source # Methods _Wrapped' :: Iso' (Vector a) (Unwrapped (Vector a)) Source #
Wrapped (Rec1 f p) Source # |
Associated Types type Unwrapped (Rec1 f p) :: * Source # Methods _Wrapped' :: Iso' (Rec1 f p) (Unwrapped (Rec1 f p)) Source #
Wrapped (WrappedMonad m a) Source # |
Associated Types type Unwrapped (WrappedMonad m a) :: * Source # Methods _Wrapped' :: Iso' (WrappedMonad m a) (Unwrapped (WrappedMonad m a)) Source #
Wrapped (ArrowMonad m a) Source # |
Associated Types type Unwrapped (ArrowMonad m a) :: * Source # Methods _Wrapped' :: Iso' (ArrowMonad m a) (Unwrapped (ArrowMonad m a)) Source #
Ord k => Wrapped (Map k a) Source # |
Associated Types type Unwrapped (Map k a) :: * Source # Methods _Wrapped' :: Iso' (Map k a) (Unwrapped (Map k a)) Source #
Wrapped (Op a b) Source # |
Associated Types type Unwrapped (Op a b) :: * Source # Methods _Wrapped' :: Iso' (Op a b) (Unwrapped (Op a b)) Source #
Wrapped (CatchT m a) Source # |
Associated Types type Unwrapped (CatchT m a) :: * Source # Methods _Wrapped' :: Iso' (CatchT m a) (Unwrapped (CatchT m a)) Source #
Wrapped (Alt f a) Source # |
Associated Types type Unwrapped (Alt f a) :: * Source # Methods _Wrapped' :: Iso' (Alt f a) (Unwrapped (Alt f a)) Source #
Wrapped (CoiterT w a) Source # |
Associated Types type Unwrapped (CoiterT w a) :: * Source # Methods _Wrapped' :: Iso' (CoiterT w a) (Unwrapped (CoiterT w a)) Source #
Wrapped (IterT m a) Source # |
Associated Types type Unwrapped (IterT m a) :: * Source # Methods _Wrapped' :: Iso' (IterT m a) (Unwrapped (IterT m a)) Source #
Wrapped (ListT m a) Source # |
Associated Types type Unwrapped (ListT m a) :: * Source # Methods _Wrapped' :: Iso' (ListT m a) (Unwrapped (ListT m a)) Source #
(Hashable k, Eq k) => Wrapped (HashMap k a) Source # |
Associated Types type Unwrapped (HashMap k a) :: * Source # Methods _Wrapped' :: Iso' (HashMap k a) (Unwrapped (HashMap k a)) Source #
Wrapped (WrappedApplicative f a) Source # |
Associated Types type Unwrapped (WrappedApplicative f a) :: * Source # Methods _Wrapped' :: Iso' (WrappedApplicative f a) (Unwrapped (WrappedApplicative f a)) Source #
Wrapped (MaybeApply f a) Source # |
Associated Types type Unwrapped (MaybeApply f a) :: * Source # Methods _Wrapped' :: Iso' (MaybeApply f a) (Unwrapped (MaybeApply f a)) Source #
Wrapped (MaybeT m a) Source # |
Associated Types type Unwrapped (MaybeT m a) :: * Source # Methods _Wrapped' :: Iso' (MaybeT m a) (Unwrapped (MaybeT m a)) Source #
Wrapped (K1 i c p) Source # |
Associated Types type Unwrapped (K1 i c p) :: * Source # Methods _Wrapped' :: Iso' (K1 i c p) (Unwrapped (K1 i c p)) Source #
Wrapped ((:.:) f g p) Source # |
Associated Types type Unwrapped ((:.:) f g p) :: * Source # Methods _Wrapped' :: Iso' ((f :.: g) p) (Unwrapped ((f :.: g) p)) Source #
Wrapped (WrappedArrow a b c) Source # |
Associated Types type Unwrapped (WrappedArrow a b c) :: * Source # Methods _Wrapped' :: Iso' (WrappedArrow a b c) (Unwrapped (WrappedArrow a b c)) Source #
Wrapped (Kleisli m a b) Source # |
Associated Types type Unwrapped (Kleisli m a b) :: * Source # Methods _Wrapped' :: Iso' (Kleisli m a b) (Unwrapped (Kleisli m a b)) Source #
Wrapped (Const k a x) Source # |
Associated Types type Unwrapped (Const k a x) :: * Source # Methods _Wrapped' :: Iso' (Const k a x) (Unwrapped (Const k a x)) Source #
Wrapped (Alt k f a) Source # |
Associated Types type Unwrapped (Alt k f a) :: * Source # Methods _Wrapped' :: Iso' (Alt k f a) (Unwrapped (Alt k f a)) Source #
Wrapped (Join k p a) Source # |
Associated Types type Unwrapped (Join k p a) :: * Source # Methods _Wrapped' :: Iso' (Join k p a) (Unwrapped (Join k p a)) Source #
Wrapped (Fix k p a) Source # |
Associated Types type Unwrapped (Fix k p a) :: * Source # Methods _Wrapped' :: Iso' (Fix k p a) (Unwrapped (Fix k p a)) Source #
Wrapped (TracedT m w a) Source # |
Associated Types type Unwrapped (TracedT m w a) :: * Source # Methods _Wrapped' :: Iso' (TracedT m w a) (Unwrapped (TracedT m w a)) Source #
Wrapped (IdentityT k m a) Source # |
Associated Types type Unwrapped (IdentityT k m a) :: * Source # Methods _Wrapped' :: Iso' (IdentityT k m a) (Unwrapped (IdentityT k m a)) Source #
Wrapped (Compose f g a) Source # |
Associated Types type Unwrapped (Compose f g a) :: * Source # Methods _Wrapped' :: Iso' (Compose f g a) (Unwrapped (Compose f g a)) Source #
Wrapped (ComposeFC f g a) Source # |
Associated Types type Unwrapped (ComposeFC f g a) :: * Source # Methods _Wrapped' :: Iso' (ComposeFC f g a) (Unwrapped (ComposeFC f g a)) Source #
Wrapped (ComposeCF f g a) Source # |
Associated Types type Unwrapped (ComposeCF f g a) :: * Source # Methods _Wrapped' :: Iso' (ComposeCF f g a) (Unwrapped (ComposeCF f g a)) Source #
Wrapped (ApT f g a) Source # |
Associated Types type Unwrapped (ApT f g a) :: * Source # Methods _Wrapped' :: Iso' (ApT f g a) (Unwrapped (ApT f g a)) Source #
Wrapped (CofreeT f w a) Source # |
Associated Types type Unwrapped (CofreeT f w a) :: * Source # Methods _Wrapped' :: Iso' (CofreeT f w a) (Unwrapped (CofreeT f w a)) Source #
Wrapped (FreeT f m a) Source # |
Associated Types type Unwrapped (FreeT f m a) :: * Source # Methods _Wrapped' :: Iso' (FreeT f m a) (Unwrapped (FreeT f m a)) Source #
Wrapped (ErrorT e m a) Source # |
Associated Types type Unwrapped (ErrorT e m a) :: * Source # Methods _Wrapped' :: Iso' (ErrorT e m a) (Unwrapped (ErrorT e m a)) Source #
Wrapped (ExceptT e m a) Source # |
Associated Types type Unwrapped (ExceptT e m a) :: * Source # Methods _Wrapped' :: Iso' (ExceptT e m a) (Unwrapped (ExceptT e m a)) Source #
Wrapped (StateT s m a) Source # |
Associated Types type Unwrapped (StateT s m a) :: * Source # Methods _Wrapped' :: Iso' (StateT s m a) (Unwrapped (StateT s m a)) Source #
Wrapped (StateT s m a) Source # |
Associated Types type Unwrapped (StateT s m a) :: * Source # Methods _Wrapped' :: Iso' (StateT s m a) (Unwrapped (StateT s m a)) Source #
Wrapped (WriterT w m a) Source # |
Associated Types type Unwrapped (WriterT w m a) :: * Source # Methods _Wrapped' :: Iso' (WriterT w m a) (Unwrapped (WriterT w m a)) Source #
Wrapped (WriterT w m a) Source # |
Associated Types type Unwrapped (WriterT w m a) :: * Source # Methods _Wrapped' :: Iso' (WriterT w m a) (Unwrapped (WriterT w m a)) Source #
Wrapped (Star f d c) Source # |
Associated Types type Unwrapped (Star f d c) :: * Source # Methods _Wrapped' :: Iso' (Star f d c) (Unwrapped (Star f d c)) Source #
Wrapped (Costar f d c) Source # |
Associated Types type Unwrapped (Costar f d c) :: * Source # Methods _Wrapped' :: Iso' (Costar f d c) (Unwrapped (Costar f d c)) Source #
Wrapped (WrappedArrow p a b) Source # |
Associated Types type Unwrapped (WrappedArrow p a b) :: * Source # Methods _Wrapped' :: Iso' (WrappedArrow p a b) (Unwrapped (WrappedArrow p a b)) Source #
Wrapped (Forget r a b) Source # |
Associated Types type Unwrapped (Forget r a b) :: * Source # Methods _Wrapped' :: Iso' (Forget r a b) (Unwrapped (Forget r a b)) Source #
Wrapped (Static f a b) Source # |
Associated Types type Unwrapped (Static f a b) :: * Source # Methods _Wrapped' :: Iso' (Static f a b) (Unwrapped (Static f a b)) Source #
Wrapped (Tagged k s a) Source # |
Associated Types type Unwrapped (Tagged k s a) :: * Source # Methods _Wrapped' :: Iso' (Tagged k s a) (Unwrapped (Tagged k s a)) Source #
Wrapped (Reverse k f a) Source # |
Associated Types type Unwrapped (Reverse k f a) :: * Source # Methods _Wrapped' :: Iso' (Reverse k f a) (Unwrapped (Reverse k f a)) Source #
Wrapped (Backwards k f a) Source # |
Associated Types type Unwrapped (Backwards k f a) :: * Source # Methods _Wrapped' :: Iso' (Backwards k f a) (Unwrapped (Backwards k f a)) Source #
Wrapped (Constant k a b) Source # |
Associated Types type Unwrapped (Constant k a b) :: * Source # Methods _Wrapped' :: Iso' (Constant k a b) (Unwrapped (Constant k a b)) Source #
Wrapped (M1 i c f p) Source # |
Associated Types type Unwrapped (M1 i c f p) :: * Source # Methods _Wrapped' :: Iso' (M1 i c f p) (Unwrapped (M1 i c f p)) Source #
Wrapped (ContT k r m a) Source # |
Associated Types type Unwrapped (ContT k r m a) :: * Source # Methods _Wrapped' :: Iso' (ContT k r m a) (Unwrapped (ContT k r m a)) Source #
Wrapped (ReaderT k r m a) Source # |
Associated Types type Unwrapped (ReaderT k r m a) :: * Source # Methods _Wrapped' :: Iso' (ReaderT k r m a) (Unwrapped (ReaderT k r m a)) Source #
Wrapped (Cayley f p a b) Source # |
Associated Types type Unwrapped (Cayley f p a b) :: * Source # Methods _Wrapped' :: Iso' (Cayley f p a b) (Unwrapped (Cayley f p a b)) Source #
Wrapped (Compose k k1 f g a) Source # |
Associated Types type Unwrapped (Compose k k1 f g a) :: * Source # Methods _Wrapped' :: Iso' (Compose k k1 f g a) (Unwrapped (Compose k k1 f g a)) Source #
Wrapped (WrappedBifunctor k k1 p a b) Source # |
Associated Types type Unwrapped (WrappedBifunctor k k1 p a b) :: * Source # Methods _Wrapped' :: Iso' (WrappedBifunctor k k1 p a b) (Unwrapped (WrappedBifunctor k k1 p a b)) Source #
Wrapped (Joker k k1 g a b) Source # |
Associated Types type Unwrapped (Joker k k1 g a b) :: * Source # Methods _Wrapped' :: Iso' (Joker k k1 g a b) (Unwrapped (Joker k k1 g a b)) Source #
Wrapped (Flip k k1 p a b) Source # |
Associated Types type Unwrapped (Flip k k1 p a b) :: * Source # Methods _Wrapped' :: Iso' (Flip k k1 p a b) (Unwrapped (Flip k k1 p a b)) Source #
Wrapped (Clown k k1 f a b) Source # |
Associated Types type Unwrapped (Clown k k1 f a b) :: * Source # Methods _Wrapped' :: Iso' (Clown k k1 f a b) (Unwrapped (Clown k k1 f a b)) Source #
Wrapped (RWST r w s m a) Source # |
Associated Types type Unwrapped (RWST r w s m a) :: * Source # Methods _Wrapped' :: Iso' (RWST r w s m a) (Unwrapped (RWST r w s m a)) Source #
Wrapped (RWST r w s m a) Source # |
Associated Types type Unwrapped (RWST r w s m a) :: * Source # Methods _Wrapped' :: Iso' (RWST r w s m a) (Unwrapped (RWST r w s m a)) Source #
Wrapped (Dual k k1 k2 a b) Source # |
Associated Types type Unwrapped (Dual k k1 k2 a b) :: * Source # Methods _Wrapped' :: Iso' (Dual k k1 k2 a b) (Unwrapped (Dual k k1 k2 a b)) Source #
Wrapped (WrappedCategory k k1 k2 a b) Source # |
Associated Types type Unwrapped (WrappedCategory k k1 k2 a b) :: * Source # Methods _Wrapped' :: Iso' (WrappedCategory k k1 k2 a b) (Unwrapped (WrappedCategory k k1 k2 a b)) Source #
Wrapped (Semi k k1 m a b) Source # |
Associated Types type Unwrapped (Semi k k1 m a b) :: * Source # Methods _Wrapped' :: Iso' (Semi k k1 m a b) (Unwrapped (Semi k k1 m a b)) Source #
Wrapped (Tannen k k1 k2 f p a b) Source # |
Associated Types type Unwrapped (Tannen k k1 k2 f p a b) :: * Source # Methods _Wrapped' :: Iso' (Tannen k k1 k2 f p a b) (Unwrapped (Tannen k k1 k2 f p a b)) Source #
Wrapped (Biff k k1 k2 k3 p f g a b) Source # |
Associated Types type Unwrapped (Biff k k1 k2 k3 p f g a b) :: * Source # Methods _Wrapped' :: Iso' (Biff k k1 k2 k3 p f g a b) (Unwrapped (Biff k k1 k2 k3 p f g a b)) Source #

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

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

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 Source #

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 Source #

Instances

(~) * t PatternMatchFail => Rewrapped PatternMatchFail t Source # |
(~) * t RecSelError => Rewrapped RecSelError t Source # |
(~) * t RecConError => Rewrapped RecConError t Source # |
(~) * t RecUpdError => Rewrapped RecUpdError t Source # |
(~) * t NoMethodError => Rewrapped NoMethodError t Source # |
(~) * t TypeError => Rewrapped TypeError t Source # |
Rewrapped CDev t Source # |
Rewrapped CIno t Source # |
Rewrapped CMode t Source # |
Rewrapped COff t Source # |
Rewrapped CPid t Source # |
Rewrapped CSsize t Source # |
Rewrapped CGid t Source # |
Rewrapped CNlink t Source # |
Rewrapped CUid t Source # |
Rewrapped CCc t Source # |
Rewrapped CSpeed t Source # |
Rewrapped CTcflag t Source # |
Rewrapped CRLim t Source # |
Rewrapped Fd t Source # |
Rewrapped Errno t Source # |
(~) * t AssertionFailed => Rewrapped AssertionFailed t Source # |
Rewrapped CChar t Source # |
Rewrapped CSChar t Source # |
Rewrapped CUChar t Source # |
Rewrapped CShort t Source # |
Rewrapped CUShort t Source # |
Rewrapped CInt t Source # |
Rewrapped CUInt t Source # |
Rewrapped CLong t Source # |
Rewrapped CULong t Source # |
Rewrapped CLLong t Source # |
Rewrapped CULLong t Source # |
Rewrapped CFloat t Source # |
Rewrapped CDouble t Source # |
Rewrapped CPtrdiff t Source # |
Rewrapped CSize t Source # |
Rewrapped CWchar t Source # |
Rewrapped CSigAtomic t Source # |
Rewrapped CClock t Source # |
Rewrapped CTime t Source # |
Rewrapped CUSeconds t Source # |
Rewrapped CSUSeconds t Source # |
Rewrapped CIntPtr t Source # |
Rewrapped CUIntPtr t Source # |
Rewrapped CIntMax t Source # |
Rewrapped CUIntMax t Source # |
(~) * t All => Rewrapped All t Source # |
(~) * t Any => Rewrapped Any t Source # |
(~) * t ErrorCall => Rewrapped ErrorCall t Source # |
(~) * t IntSet => Rewrapped IntSet t Source # | Use ``wrapping` `fromList``. unwrapping returns a sorted list.
(~) * t (Par1 p') => Rewrapped (Par1 p) t Source # |
(~) * t (Identity b) => Rewrapped (Identity a) t Source # |
(~) * t (Min b) => Rewrapped (Min a) t Source # |
(~) * t (Max b) => Rewrapped (Max a) t Source # |
(~) * t (First b) => Rewrapped (First a) t Source # |
(~) * t (Last b) => Rewrapped (Last a) t Source # |
(~) * t (WrappedMonoid b) => Rewrapped (WrappedMonoid a) t Source # |
(~) * t (Option b) => Rewrapped (Option a) t Source # |
(~) * t (NonEmpty b) => Rewrapped (NonEmpty a) t Source # |
(~) * t (ZipList b) => Rewrapped (ZipList a) t Source # |
(~) * t (Dual b) => Rewrapped (Dual a) t Source # |
(~) * t (Endo b) => Rewrapped (Endo a) t Source # |
(~) * t (Sum b) => Rewrapped (Sum a) t Source # |
(~) * t (Product b) => Rewrapped (Product a) t Source # |
(~) * t (First b) => Rewrapped (First a) t Source # |
(~) * t (Last b) => Rewrapped (Last a) t Source # |
(~) * t (Down b) => Rewrapped (Down a) t Source # |
(~) * t (IntMap a') => Rewrapped (IntMap a) t Source # | Use ``wrapping` `fromList``. unwrapping returns a sorted list.
(~) * t (Seq a') => Rewrapped (Seq a) t Source # |
((~) * t (Set a'), Ord a) => Rewrapped (Set a) t Source # | Use ``wrapping` `fromList``. unwrapping returns a sorted list.
(~) * t (Predicate b) => Rewrapped (Predicate a) t Source # |
(~) * t (Comparison b) => Rewrapped (Comparison a) t Source # |
(~) * t (Equivalence b) => Rewrapped (Equivalence a) t Source # |
((~) * t (HashSet a'), Hashable a, Eq a) => Rewrapped (HashSet a) t Source # | Use ``wrapping` `fromList``. Unwrapping returns some permutation of the list.
(~) * t (Vector a') => Rewrapped (Vector a) t Source # |
(Storable a, (~) * t (Vector a')) => Rewrapped (Vector a) t Source # |
(Unbox a, (~) * t (Vector a')) => Rewrapped (Vector a) t Source # |
(Prim a, (~) * t (Vector a')) => Rewrapped (Vector a) t Source # |
(~) * t (Rec1 f' p') => Rewrapped (Rec1 f p) t Source # |
(~) * t (WrappedMonad m' a') => Rewrapped (WrappedMonad m a) t Source # |
(~) * t (ArrowMonad m' a') => Rewrapped (ArrowMonad m a) t Source # |
((~) * t (Map k' a'), Ord k) => Rewrapped (Map k a) t Source # | Use ``wrapping` `fromList``. unwrapping returns a sorted list.
(~) * t (Op a' b') => Rewrapped (Op a b) t Source # |
(~) * t (CatchT m' a') => Rewrapped (CatchT m a) t Source # |
(~) * t (Alt f' a') => Rewrapped (Alt f a) t Source # |
(~) * t (CoiterT w' a') => Rewrapped (CoiterT w a) t Source # |
(~) * t (IterT m' a') => Rewrapped (IterT m a) t Source # |
(~) * t (ListT n b) => Rewrapped (ListT m a) t Source # |
((~) * t (HashMap k' a'), Hashable k, Eq k) => Rewrapped (HashMap k a) t Source # | Use ``wrapping` `fromList``. Unwrapping returns some permutation of the list.
(~) * t (WrappedApplicative f' a') => Rewrapped (WrappedApplicative f a) t Source # |
(~) * t (MaybeApply f' a') => Rewrapped (MaybeApply f a) t Source # |
(~) * t (MaybeT n b) => Rewrapped (MaybeT m a) t Source # |
(~) * t (K1 i' c' p') => Rewrapped (K1 i c p) t Source # |
(~) * t ((:.:) f' g' p') => Rewrapped ((:.:) f g p) t Source # |
(~) * t (WrappedArrow a' b' c') => Rewrapped (WrappedArrow a b c) t Source # |
(~) * t (Kleisli m' a' b') => Rewrapped (Kleisli m a b) t Source # |
(~) * t (Const k1 a' x') => Rewrapped (Const k a x) t Source # |
(~) * t (Alt k1 g b) => Rewrapped (Alt k f a) t Source # |
(~) * t (Join k1 p' a') => Rewrapped (Join k p a) t Source # |
(~) * t (Fix k1 p' a') => Rewrapped (Fix k p a) t Source # |
(~) * t (TracedT m' w' a') => Rewrapped (TracedT m w a) t Source # |
(~) * t (IdentityT k1 n b) => Rewrapped (IdentityT k m a) t Source # |
(~) * t (Compose f' g' a') => Rewrapped (Compose f g a) t Source # |
(~) * t (ComposeFC f' g' a') => Rewrapped (ComposeFC f g a) t Source # |
(~) * t (ComposeCF f' g' a') => Rewrapped (ComposeCF f g a) t Source # |
(~) * t (ApT f' g' a') => Rewrapped (ApT f g a) t Source # |
(~) * t (CofreeT f' w' a') => Rewrapped (CofreeT f w a) t Source # |
(~) * t (FreeT f' m' a') => Rewrapped (FreeT f m a) t Source # |
(~) * t (ErrorT e' m' a') => Rewrapped (ErrorT e m a) t Source # |
(~) * t (ExceptT e' m' a') => Rewrapped (ExceptT e m a) t Source # |
(~) * t (StateT s' m' a') => Rewrapped (StateT s m a) t Source # |
(~) * t (StateT s' m' a') => Rewrapped (StateT s m a) t Source # |
(~) * t (WriterT w' m' a') => Rewrapped (WriterT w m a) t Source # |
(~) * t (WriterT w' m' a') => Rewrapped (WriterT w m a) t Source # |
(~) * t (Star f' d' c') => Rewrapped (Star f d c) t Source # |
(~) * t (Costar f' d' c') => Rewrapped (Costar f d c) t Source # |
(~) * t (WrappedArrow p' a' b') => Rewrapped (WrappedArrow p a b) t Source # |
(~) * t (Forget r' a' b') => Rewrapped (Forget r a b) t Source # |
(~) * t (Static f' a' b') => Rewrapped (Static f a b) t Source # |
(~) * t (Tagged k1 s' a') => Rewrapped (Tagged k s a) t Source # |
(~) * t (Reverse k1 g b) => Rewrapped (Reverse k f a) t Source # |
(~) * t (Backwards k1 g b) => Rewrapped (Backwards k f a) t Source # |
(~) * t (Constant k1 a' b') => Rewrapped (Constant k a b) t Source # |
(~) * t (M1 i' c' f' p') => Rewrapped (M1 i c f p) t Source # |
(~) * t (ContT k1 r' m' a') => Rewrapped (ContT k r m a) t Source # |
(~) * t (ReaderT k1 s n b) => Rewrapped (ReaderT k r m a) t Source # |
(~) * t (Cayley f' p' a' b') => Rewrapped (Cayley f p a b) t Source # |
(~) * t (Compose k2 k3 f' g' a') => Rewrapped (Compose k k1 f g a) t Source # |
(~) * t (WrappedBifunctor k2 k3 p' a' b') => Rewrapped (WrappedBifunctor k k1 p a b) t Source # |
(~) * t (Joker k2 k3 g' a' b') => Rewrapped (Joker k k1 g a b) t Source # |
(~) * t (Flip k2 k3 p' a' b') => Rewrapped (Flip k k1 p a b) t Source # |
(~) * t (Clown k2 k3 f' a' b') => Rewrapped (Clown k k1 f a b) t Source # |
(~) * t (RWST r' w' s' m' a') => Rewrapped (RWST r w s m a) t Source # |
(~) * t (RWST r' w' s' m' a') => Rewrapped (RWST r w s m a) t Source # |
(~) * t (Dual k2 k3 k' a' b') => Rewrapped (Dual k k1 k4 a b) t Source # |
(~) * t (WrappedCategory k2 k3 k' a' b') => Rewrapped (WrappedCategory k k1 k4 a b) t Source # |
(~) * t (Semi k2 k3 m' a' b') => Rewrapped (Semi k k1 m a b) t Source # |
(~) * t (Tannen k4 k5 k6 f' p' a' b') => Rewrapped (Tannen k k1 k2 f p a b) t Source # |
(~) * t (Biff k4 k5 k6 k7 p' f' g' a' b') => Rewrapped (Biff k k1 k2 k3 p f g a b) t Source # |

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

Instances

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

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

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 Source #

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

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 Source #

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 Source #

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) Source #

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) Source #

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 Source #

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

# Generics

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

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