#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 706
#endif
#ifdef TRUSTWORTHY
#endif
module Control.Lens.Wrapped
( Wrapped(..)
, unwrapped
, wrapped', unwrapped'
, wrapping, unwrapping
, wrappings, unwrappings
, op
, ala, alaf
) where
import Control.Applicative
import Control.Arrow
import Control.Applicative.Backwards
import Control.Comonad.Trans.Traced
import Control.Exception
import Control.Lens.Internal.Review
import Control.Lens.Iso
import Control.Lens.Review
import Control.Monad.Trans.Cont
import Control.Monad.Trans.Error
import Control.Monad.Trans.Identity
import Control.Monad.Trans.List
import Control.Monad.Trans.Maybe
import Control.Monad.Trans.Reader
import qualified Control.Monad.Trans.RWS.Lazy as Lazy
import qualified Control.Monad.Trans.RWS.Strict as Strict
import qualified Control.Monad.Trans.State.Lazy as Lazy
import qualified Control.Monad.Trans.State.Strict as Strict
import qualified Control.Monad.Trans.Writer.Lazy as Lazy
import qualified Control.Monad.Trans.Writer.Strict as Strict
import Data.Foldable as Foldable
import Data.Functor.Compose
import Data.Functor.Contravariant
import qualified Data.Functor.Contravariant.Compose as Contravariant
import Data.Functor.Constant
import Data.Functor.Coproduct
import Data.Functor.Identity
import Data.Functor.Reverse
import Data.Hashable
import Data.IntSet as IntSet
import Data.IntMap as IntMap
import Data.HashSet as HashSet
import Data.HashMap.Lazy as HashMap
import Data.Map as Map
import Data.Monoid
import Data.Sequence as Seq hiding (length)
import Data.Set as Set
import Data.Tagged
class Wrapped s t a b | a -> s, b -> t, a t -> s, b s -> t where
wrapped :: Iso s t a b
instance Wrapped Bool Bool All All where
wrapped = iso All getAll
instance Wrapped Bool Bool Any Any where
wrapped = iso Any getAny
instance Wrapped a b (Sum a) (Sum b) where
wrapped = iso Sum getSum
instance Wrapped a b (Product a) (Product b) where
wrapped = iso Product getProduct
instance Wrapped (a -> m b) (u -> n v) (Kleisli m a b) (Kleisli n u v) where
wrapped = iso Kleisli runKleisli
instance Wrapped (m a) (n b) (WrappedMonad m a) (WrappedMonad n b) where
wrapped = iso WrapMonad unwrapMonad
instance Wrapped (a b c) (u v w) (WrappedArrow a b c) (WrappedArrow u v w) where
wrapped = iso WrapArrow unwrapArrow
instance Wrapped [a] [b] (ZipList a) (ZipList b) where
wrapped = iso ZipList getZipList
instance Wrapped a b (Const a x) (Const b y) where
wrapped = iso Const getConst
instance Wrapped a b (Dual a) (Dual b) where
wrapped = iso Dual getDual
instance Wrapped (a -> a) (b -> b) (Endo a) (Endo b) where
wrapped = iso Endo appEndo
instance Wrapped (Maybe a) (Maybe b) (First a) (First b) where
wrapped = iso First getFirst
instance Wrapped (Maybe a) (Maybe b) (Last a) (Last b) where
wrapped = iso Last getLast
instance (ArrowApply m, ArrowApply n) => Wrapped (m () a) (n () b) (ArrowMonad m a) (ArrowMonad n b) where
wrapped = iso ArrowMonad getArrowMonad
instance Wrapped a b (Reviewed s a) (Reviewed t b) where
wrapped = iso Reviewed runReviewed
instance Wrapped (f a) (f' a') (Backwards f a) (Backwards f' a') where
wrapped = iso Backwards forwards
instance Wrapped (f (g a)) (f' (g' a')) (Compose f g a) (Compose f' g' a') where
wrapped = iso Compose getCompose
instance Wrapped a a' (Constant a b) (Constant a' b') where
wrapped = iso Constant getConstant
instance Wrapped ((a -> m r) -> m r) ((a' -> m' r') -> m' r') (ContT r m a) (ContT r' m' a') where
wrapped = iso ContT runContT
instance Wrapped (m (Either e a)) (m' (Either e' a')) (ErrorT e m a) (ErrorT e' m' a') where
wrapped = iso ErrorT runErrorT
instance Wrapped a a' (Identity a) (Identity a') where
wrapped = iso Identity runIdentity
instance Wrapped (m a) (m' a') (IdentityT m a) (IdentityT m' a') where
wrapped = iso IdentityT runIdentityT
instance Wrapped (m [a]) (m' [a']) (ListT m a) (ListT m' a') where
wrapped = iso ListT runListT
instance Wrapped (m (Maybe a)) (m' (Maybe a')) (MaybeT m a) (MaybeT m' a') where
wrapped = iso MaybeT runMaybeT
instance Wrapped (r -> m a) (r' -> m' a') (ReaderT r m a) (ReaderT r' m' a') where
wrapped = iso ReaderT runReaderT
instance Wrapped (f a) (f' a') (Reverse f a) (Reverse f' a') where
wrapped = iso Reverse getReverse
instance Wrapped (r -> s -> m (a, s, w)) (r' -> s' -> m' (a', s', w')) (Lazy.RWST r w s m a) (Lazy.RWST r' w' s' m' a') where
wrapped = iso Lazy.RWST Lazy.runRWST
instance Wrapped (r -> s -> m (a, s, w)) (r' -> s' -> m' (a', s', w')) (Strict.RWST r w s m a) (Strict.RWST r' w' s' m' a') where
wrapped = iso Strict.RWST Strict.runRWST
instance Wrapped (s -> m (a, s)) (s' -> m' (a', s')) (Lazy.StateT s m a) (Lazy.StateT s' m' a') where
wrapped = iso Lazy.StateT Lazy.runStateT
instance Wrapped (s -> m (a, s)) (s' -> m' (a', s')) (Strict.StateT s m a) (Strict.StateT s' m' a') where
wrapped = iso Strict.StateT Strict.runStateT
instance Wrapped (m (a, w)) (m' (a', w')) (Lazy.WriterT w m a) (Lazy.WriterT w' m' a') where
wrapped = iso Lazy.WriterT Lazy.runWriterT
instance Wrapped (m (a, w)) (m' (a', w')) (Strict.WriterT w m a) (Strict.WriterT w' m' a') where
wrapped = iso Strict.WriterT Strict.runWriterT
instance Wrapped (Either (f a) (g a)) (Either (f' a') (g' a')) (Coproduct f g a) (Coproduct f' g' a') where
wrapped = iso Coproduct getCoproduct
instance Wrapped (w (m -> a)) (w' (m' -> a')) (TracedT m w a) (TracedT m' w' a') where
wrapped = iso TracedT runTracedT
instance (Hashable k, Eq k, Hashable k', Eq k') => Wrapped [(k, a)] [(k', b)] (HashMap k a) (HashMap k' b) where
wrapped = iso HashMap.fromList HashMap.toList
instance (Hashable a, Eq a, Hashable b, Eq b) => Wrapped [a] [b] (HashSet a) (HashSet b) where
wrapped = iso HashSet.fromList HashSet.toList
instance Wrapped [(Int, a)] [(Int, b)] (IntMap a) (IntMap b) where
wrapped = iso IntMap.fromList IntMap.toAscList
instance Wrapped [Int] [Int] IntSet IntSet where
wrapped = iso IntSet.fromList IntSet.toAscList
instance (Ord k, Ord k') => Wrapped [(k, a)] [(k', b)] (Map k a) (Map k' b) where
wrapped = iso Map.fromList Map.toAscList
instance (Ord a, Ord b) => Wrapped [a] [b] (Set a) (Set b) where
wrapped = iso Set.fromList Set.toAscList
instance Wrapped [a] [b] (Seq a) (Seq b) where
wrapped = iso Seq.fromList Foldable.toList
instance Wrapped (a -> Bool) (a' -> Bool) (Predicate a) (Predicate a') where
wrapped = iso Predicate getPredicate
instance Wrapped (a -> a -> Ordering) (a' -> a' -> Ordering) (Comparison a) (Comparison a') where
wrapped = iso Comparison getComparison
instance Wrapped (a -> a -> Bool) (a' -> a' -> Bool) (Equivalence a) (Equivalence a') where
wrapped = iso Equivalence getEquivalence
instance Wrapped (b -> a) (b' -> a') (Op a b) (Op a' b') where
wrapped = iso Op getOp
instance Wrapped (f (g a)) (f' (g' a')) (Contravariant.Compose f g a) (Contravariant.Compose f' g' a') where
wrapped = iso Contravariant.Compose Contravariant.getCompose
instance Wrapped (f (g a)) (f' (g' a')) (Contravariant.ComposeFC f g a) (Contravariant.ComposeFC f' g' a') where
wrapped = iso Contravariant.ComposeFC Contravariant.getComposeFC
instance Wrapped (f (g a)) (f' (g' a')) (Contravariant.ComposeCF f g a) (Contravariant.ComposeFC f' g' a') where
wrapped = iso Contravariant.ComposeCF Contravariant.getComposeFC
instance Wrapped a b (Tagged s a) (Tagged t b) where
wrapped = iso Tagged unTagged
instance Wrapped String String AssertionFailed AssertionFailed where
wrapped = iso AssertionFailed failedAssertion
instance Wrapped String String NoMethodError NoMethodError where
wrapped = iso NoMethodError getNoMethodError
instance Wrapped String String PatternMatchFail PatternMatchFail where
wrapped = iso PatternMatchFail getPatternMatchFail
instance Wrapped String String RecConError RecConError where
wrapped = iso RecConError getRecConError
instance Wrapped String String RecSelError RecSelError where
wrapped = iso RecSelError getRecSelError
instance Wrapped String String RecUpdError RecUpdError where
wrapped = iso RecUpdError getRecUpdError
instance Wrapped String String ErrorCall ErrorCall where
wrapped = iso ErrorCall getErrorCall
getErrorCall :: ErrorCall -> String
getErrorCall (ErrorCall x) = x
getRecUpdError :: RecUpdError -> String
getRecUpdError (RecUpdError x) = x
getRecSelError :: RecSelError -> String
getRecSelError (RecSelError x) = x
getRecConError :: RecConError -> String
getRecConError (RecConError x) = x
getPatternMatchFail :: PatternMatchFail -> String
getPatternMatchFail (PatternMatchFail x) = x
getNoMethodError :: NoMethodError -> String
getNoMethodError (NoMethodError x) = x
failedAssertion :: AssertionFailed -> String
failedAssertion (AssertionFailed x) = x
getArrowMonad :: ArrowApply m => ArrowMonad m a -> m () a
getArrowMonad (ArrowMonad x) = x
op :: Wrapped s s a a => (s -> a) -> a -> s
op f = review (wrapping f)
unwrapped :: Wrapped t s b a => Iso a b s t
unwrapped = from wrapped
wrapped' :: Wrapped s s a a => Iso' s a
wrapped' = wrapped
unwrapped' :: Wrapped s s a a => Iso' a s
unwrapped' = unwrapped
wrapping :: Wrapped s s a a => (s -> a) -> Iso s s a a
wrapping _ = wrapped
unwrapping :: Wrapped s s a a => (s -> a) -> Iso a a s s
unwrapping _ = unwrapped
wrappings :: Wrapped s t a b => (s -> a) -> (t -> b) -> Iso s t a b
wrappings _ _ = wrapped
unwrappings :: Wrapped t s b a => (s -> a) -> (t -> b) -> Iso a b s t
unwrappings _ _ = unwrapped
ala :: Wrapped s s a a => (s -> a) -> ((s -> a) -> e -> a) -> e -> s
ala = au . wrapping
alaf :: Wrapped s s a a => (s -> a) -> ((r -> a) -> e -> a) -> (r -> s) -> e -> s
alaf = auf . wrapping