-- |
-- Module: Optics.Each.Core
-- Description: An 'IxTraversal' for each element of a (potentially monomorphic) container.
--
-- This module defines the 'Each' class, which provides an 'IxTraversal' that
-- extracts 'each' element of a (potentially monomorphic) container.
--
-- Note that orphan instances for this class are defined in the @Optics.Each@
-- module from @optics-extra@, so if you are not simply depending on @optics@
-- you may wish to import that module instead.
--
{-# LANGUAGE UndecidableInstances #-}
module Optics.Each.Core
  (
  -- * Each
    Each(..)
  ) where

import Data.Complex (Complex (..))
import Data.Functor.Identity (Identity (..))
import Data.List.NonEmpty (NonEmpty (..))
import Data.Tree (Tree (..))
import Data.Ix (Ix)

import Data.Array (Array)
import Data.IntMap (IntMap)
import qualified Data.IntMap as IntMap
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Sequence (Seq)

import Optics.IxLens
import Optics.IxTraversal
import Optics.Optic

-- | Extract 'each' element of a (potentially monomorphic) container.
--
-- >>> over each (*10) (1,2,3)
-- (10,20,30)
--
-- >>> iover each (\i a -> a*10 + succ i) (1,2,3)
-- (11,22,33)
--
class Each i s t a b | s -> i a, t -> i b, s b -> t, t a -> s where
  each :: IxTraversal i s t a b

  default each
    :: (TraversableWithIndex i g, s ~ g a, t ~ g b)
    => IxTraversal i s t a b
  each = IxTraversal i s t a b
forall i (f :: * -> *) a b.
TraversableWithIndex i f =>
IxTraversal i (f a) (f b) a b
itraversed
  {-# INLINE[1] each #-}

-- | @'each' :: 'IxTraversal' 'Int' (a, a) (b, b) a b@
instance
  (a ~ a1,
   b ~ b1
  ) => Each Int (a, a1)
                (b, b1) a b where
  each :: IxTraversal Int (a, a1) (b, b1) a b
each = IxTraversalVL Int (a, a1) (b, b1) a b
-> IxTraversal Int (a, a1) (b, b1) a b
forall i s t a b. IxTraversalVL i s t a b -> IxTraversal i s t a b
itraversalVL (IxTraversalVL Int (a, a1) (b, b1) a b
 -> IxTraversal Int (a, a1) (b, b1) a b)
-> IxTraversalVL Int (a, a1) (b, b1) a b
-> IxTraversal Int (a, a1) (b, b1) a b
forall a b. (a -> b) -> a -> b
$ \Int -> a -> f b
f (a0, a1) ->
    (,) (b -> b -> (b, b)) -> f b -> f (b -> (b, b))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> a -> f b
f Int
0 a
a0 f (b -> (b, b)) -> f b -> f (b, b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
1 a
a1
  {-# INLINE[1] each #-}

-- | @'each' :: 'IxTraversal' 'Int' (a, a, a) (b, b, b) a b@
instance
  (a ~ a1, a ~ a2,
   b ~ b1, b ~ b2
  ) => Each Int (a, a1, a2)
                (b, b1, b2) a b where
  each :: IxTraversal Int (a, a1, a2) (b, b1, b2) a b
each = IxTraversalVL Int (a, a1, a2) (b, b1, b2) a b
-> IxTraversal Int (a, a1, a2) (b, b1, b2) a b
forall i s t a b. IxTraversalVL i s t a b -> IxTraversal i s t a b
itraversalVL (IxTraversalVL Int (a, a1, a2) (b, b1, b2) a b
 -> IxTraversal Int (a, a1, a2) (b, b1, b2) a b)
-> IxTraversalVL Int (a, a1, a2) (b, b1, b2) a b
-> IxTraversal Int (a, a1, a2) (b, b1, b2) a b
forall a b. (a -> b) -> a -> b
$ \Int -> a -> f b
f (a0, a1, a2) ->
    (,,) (b -> b -> b -> (b, b, b)) -> f b -> f (b -> b -> (b, b, b))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> a -> f b
f Int
0 a
a0 f (b -> b -> (b, b, b)) -> f b -> f (b -> (b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
1 a
a1 f (b -> (b, b, b)) -> f b -> f (b, b, b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
2 a
a2
  {-# INLINE[1] each #-}

-- | @'each' :: 'IxTraversal' 'Int' (a, a, a, a) (b, b, b, b) a b@
instance
  (a ~ a1, a ~ a2, a ~ a3,
   b ~ b1, b ~ b2, b ~ b3
  ) => Each Int (a, a1, a2, a3)
                (b, b1, b2, b3) a b where
  each :: IxTraversal Int (a, a1, a2, a3) (b, b1, b2, b3) a b
each = IxTraversalVL Int (a, a1, a2, a3) (b, b1, b2, b3) a b
-> IxTraversal Int (a, a1, a2, a3) (b, b1, b2, b3) a b
forall i s t a b. IxTraversalVL i s t a b -> IxTraversal i s t a b
itraversalVL (IxTraversalVL Int (a, a1, a2, a3) (b, b1, b2, b3) a b
 -> IxTraversal Int (a, a1, a2, a3) (b, b1, b2, b3) a b)
-> IxTraversalVL Int (a, a1, a2, a3) (b, b1, b2, b3) a b
-> IxTraversal Int (a, a1, a2, a3) (b, b1, b2, b3) a b
forall a b. (a -> b) -> a -> b
$ \Int -> a -> f b
f (a0, a1, a2, a3) ->
    (,,,) (b -> b -> b -> b -> (b, b, b, b))
-> f b -> f (b -> b -> b -> (b, b, b, b))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> a -> f b
f Int
0 a
a0 f (b -> b -> b -> (b, b, b, b))
-> f b -> f (b -> b -> (b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
1 a
a1 f (b -> b -> (b, b, b, b)) -> f b -> f (b -> (b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
2 a
a2 f (b -> (b, b, b, b)) -> f b -> f (b, b, b, b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
3 a
a3
  {-# INLINE[1] each #-}

-- | @'each' :: 'IxTraversal' 'Int' (a, a, a, a, a) (b, b, b, b, b) a b@
instance
  (a ~ a1, a ~ a2, a ~ a3, a ~ a4,
   b ~ b1, b ~ b2, b ~ b3, b ~ b4
  ) => Each Int (a, a1, a2, a3, a4)
                (b, b1, b2, b3, b4) a b where
  each :: IxTraversal Int (a, a1, a2, a3, a4) (b, b1, b2, b3, b4) a b
each = IxTraversalVL Int (a, a1, a2, a3, a4) (b, b1, b2, b3, b4) a b
-> IxTraversal Int (a, a1, a2, a3, a4) (b, b1, b2, b3, b4) a b
forall i s t a b. IxTraversalVL i s t a b -> IxTraversal i s t a b
itraversalVL (IxTraversalVL Int (a, a1, a2, a3, a4) (b, b1, b2, b3, b4) a b
 -> IxTraversal Int (a, a1, a2, a3, a4) (b, b1, b2, b3, b4) a b)
-> IxTraversalVL Int (a, a1, a2, a3, a4) (b, b1, b2, b3, b4) a b
-> IxTraversal Int (a, a1, a2, a3, a4) (b, b1, b2, b3, b4) a b
forall a b. (a -> b) -> a -> b
$ \Int -> a -> f b
f (a0, a1, a2, a3, a4) ->
    (,,,,) (b -> b -> b -> b -> b -> (b, b, b, b, b))
-> f b -> f (b -> b -> b -> b -> (b, b, b, b, b))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> a -> f b
f Int
0 a
a0 f (b -> b -> b -> b -> (b, b, b, b, b))
-> f b -> f (b -> b -> b -> (b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
1 a
a1 f (b -> b -> b -> (b, b, b, b, b))
-> f b -> f (b -> b -> (b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
2 a
a2 f (b -> b -> (b, b, b, b, b)) -> f b -> f (b -> (b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
3 a
a3 f (b -> (b, b, b, b, b)) -> f b -> f (b, b, b, b, b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
4 a
a4
  {-# INLINE[1] each #-}

-- | @'each' :: 'IxTraversal' 'Int' (a, a, a, a, a, a) (b, b, b, b, b, b) a b@
instance
  (a ~ a1, a ~ a2, a ~ a3, a ~ a4, a ~ a5,
   b ~ b1, b ~ b2, b ~ b3, b ~ b4, b ~ b5
  ) => Each Int (a, a1, a2, a3, a4, a5)
                (b, b1, b2, b3, b4, b5) a b where
  each :: IxTraversal Int (a, a1, a2, a3, a4, a5) (b, b1, b2, b3, b4, b5) a b
each = IxTraversalVL
  Int (a, a1, a2, a3, a4, a5) (b, b1, b2, b3, b4, b5) a b
-> IxTraversal
     Int (a, a1, a2, a3, a4, a5) (b, b1, b2, b3, b4, b5) a b
forall i s t a b. IxTraversalVL i s t a b -> IxTraversal i s t a b
itraversalVL (IxTraversalVL
   Int (a, a1, a2, a3, a4, a5) (b, b1, b2, b3, b4, b5) a b
 -> IxTraversal
      Int (a, a1, a2, a3, a4, a5) (b, b1, b2, b3, b4, b5) a b)
-> IxTraversalVL
     Int (a, a1, a2, a3, a4, a5) (b, b1, b2, b3, b4, b5) a b
-> IxTraversal
     Int (a, a1, a2, a3, a4, a5) (b, b1, b2, b3, b4, b5) a b
forall a b. (a -> b) -> a -> b
$ \Int -> a -> f b
f (a0, a1, a2, a3, a4, a5) ->
    (,,,,,) (b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b))
-> f b -> f (b -> b -> b -> b -> b -> (b, b, b, b, b, b))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> a -> f b
f Int
0 a
a0 f (b -> b -> b -> b -> b -> (b, b, b, b, b, b))
-> f b -> f (b -> b -> b -> b -> (b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
1 a
a1 f (b -> b -> b -> b -> (b, b, b, b, b, b))
-> f b -> f (b -> b -> b -> (b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
2 a
a2 f (b -> b -> b -> (b, b, b, b, b, b))
-> f b -> f (b -> b -> (b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
3 a
a3 f (b -> b -> (b, b, b, b, b, b))
-> f b -> f (b -> (b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
4 a
a4
            f (b -> (b, b, b, b, b, b)) -> f b -> f (b, b, b, b, b, b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
5 a
a5
  {-# INLINE[1] each #-}

-- | @'each' :: 'IxTraversal' 'Int' (a, a, a, a, a, a, a) (b, b, b, b, b, b, b)
-- a b@
instance
  (a ~ a1, a ~ a2, a ~ a3, a ~ a4, a ~ a5, a ~ a6,
   b ~ b1, b ~ b2, b ~ b3, b ~ b4, b ~ b5, b ~ b6
  ) => Each Int (a, a1, a2, a3, a4, a5, a6)
                (b, b1, b2, b3, b4, b5, b6) a b where
  each :: IxTraversal
  Int (a, a1, a2, a3, a4, a5, a6) (b, b1, b2, b3, b4, b5, b6) a b
each = IxTraversalVL
  Int (a, a1, a2, a3, a4, a5, a6) (b, b1, b2, b3, b4, b5, b6) a b
-> IxTraversal
     Int (a, a1, a2, a3, a4, a5, a6) (b, b1, b2, b3, b4, b5, b6) a b
forall i s t a b. IxTraversalVL i s t a b -> IxTraversal i s t a b
itraversalVL (IxTraversalVL
   Int (a, a1, a2, a3, a4, a5, a6) (b, b1, b2, b3, b4, b5, b6) a b
 -> IxTraversal
      Int (a, a1, a2, a3, a4, a5, a6) (b, b1, b2, b3, b4, b5, b6) a b)
-> IxTraversalVL
     Int (a, a1, a2, a3, a4, a5, a6) (b, b1, b2, b3, b4, b5, b6) a b
-> IxTraversal
     Int (a, a1, a2, a3, a4, a5, a6) (b, b1, b2, b3, b4, b5, b6) a b
forall a b. (a -> b) -> a -> b
$ \Int -> a -> f b
f (a0, a1, a2, a3, a4, a5, a6) ->
    (,,,,,,) (b -> b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b, b))
-> f b -> f (b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> a -> f b
f Int
0 a
a0 f (b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b, b))
-> f b -> f (b -> b -> b -> b -> b -> (b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
1 a
a1 f (b -> b -> b -> b -> b -> (b, b, b, b, b, b, b))
-> f b -> f (b -> b -> b -> b -> (b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
2 a
a2 f (b -> b -> b -> b -> (b, b, b, b, b, b, b))
-> f b -> f (b -> b -> b -> (b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
3 a
a3 f (b -> b -> b -> (b, b, b, b, b, b, b))
-> f b -> f (b -> b -> (b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
4 a
a4
             f (b -> b -> (b, b, b, b, b, b, b))
-> f b -> f (b -> (b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
5 a
a5 f (b -> (b, b, b, b, b, b, b)) -> f b -> f (b, b, b, b, b, b, b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
6 a
a6
  {-# INLINE[1] each #-}

-- | @'each' :: 'IxTraversal' 'Int' (a, a, a, a, a, a, a, a) (b, b, b, b, b, b,
-- b, b) a b@
instance
  (a ~ a1, a ~ a2, a ~ a3, a ~ a4, a ~ a5, a ~ a6, a ~ a7,
   b ~ b1, b ~ b2, b ~ b3, b ~ b4, b ~ b5, b ~ b6, b ~ b7
  ) => Each Int (a, a1, a2, a3, a4, a5, a6, a7)
                (b, b1, b2, b3, b4, b5, b6, b7) a b where
  each :: IxTraversal
  Int
  (a, a1, a2, a3, a4, a5, a6, a7)
  (b, b1, b2, b3, b4, b5, b6, b7)
  a
  b
each = IxTraversalVL
  Int
  (a, a1, a2, a3, a4, a5, a6, a7)
  (b, b1, b2, b3, b4, b5, b6, b7)
  a
  b
-> IxTraversal
     Int
     (a, a1, a2, a3, a4, a5, a6, a7)
     (b, b1, b2, b3, b4, b5, b6, b7)
     a
     b
forall i s t a b. IxTraversalVL i s t a b -> IxTraversal i s t a b
itraversalVL (IxTraversalVL
   Int
   (a, a1, a2, a3, a4, a5, a6, a7)
   (b, b1, b2, b3, b4, b5, b6, b7)
   a
   b
 -> IxTraversal
      Int
      (a, a1, a2, a3, a4, a5, a6, a7)
      (b, b1, b2, b3, b4, b5, b6, b7)
      a
      b)
-> IxTraversalVL
     Int
     (a, a1, a2, a3, a4, a5, a6, a7)
     (b, b1, b2, b3, b4, b5, b6, b7)
     a
     b
-> IxTraversal
     Int
     (a, a1, a2, a3, a4, a5, a6, a7)
     (b, b1, b2, b3, b4, b5, b6, b7)
     a
     b
forall a b. (a -> b) -> a -> b
$ \Int -> a -> f b
f (a0, a1, a2, a3, a4, a5, a6, a7) ->
    (,,,,,,,) (b -> b -> b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b))
-> f b
-> f (b -> b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> a -> f b
f Int
0 a
a0 f (b -> b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b))
-> f b
-> f (b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
1 a
a1 f (b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b))
-> f b -> f (b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
2 a
a2 f (b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b))
-> f b -> f (b -> b -> b -> b -> (b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
3 a
a3 f (b -> b -> b -> b -> (b, b, b, b, b, b, b, b))
-> f b -> f (b -> b -> b -> (b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
4 a
a4
              f (b -> b -> b -> (b, b, b, b, b, b, b, b))
-> f b -> f (b -> b -> (b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
5 a
a5 f (b -> b -> (b, b, b, b, b, b, b, b))
-> f b -> f (b -> (b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
6 a
a6 f (b -> (b, b, b, b, b, b, b, b))
-> f b -> f (b, b, b, b, b, b, b, b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
7 a
a7
  {-# INLINE[1] each #-}

-- | @'each' :: 'IxTraversal' 'Int' (a, a, a, a, a, a, a, a, a) (b, b, b, b, b,
-- b, b, b, b) a b@
instance
  (a ~ a1, a ~ a2, a ~ a3, a ~ a4, a ~ a5, a ~ a6, a ~ a7, a ~ a8,
   b ~ b1, b ~ b2, b ~ b3, b ~ b4, b ~ b5, b ~ b6, b ~ b7, b ~ b8
  ) => Each Int (a, a1, a2, a3, a4, a5, a6, a7, a8)
                (b, b1, b2, b3, b4, b5, b6, b7, b8) a b where
  each :: IxTraversal
  Int
  (a, a1, a2, a3, a4, a5, a6, a7, a8)
  (b, b1, b2, b3, b4, b5, b6, b7, b8)
  a
  b
each = IxTraversalVL
  Int
  (a, a1, a2, a3, a4, a5, a6, a7, a8)
  (b, b1, b2, b3, b4, b5, b6, b7, b8)
  a
  b
-> IxTraversal
     Int
     (a, a1, a2, a3, a4, a5, a6, a7, a8)
     (b, b1, b2, b3, b4, b5, b6, b7, b8)
     a
     b
forall i s t a b. IxTraversalVL i s t a b -> IxTraversal i s t a b
itraversalVL (IxTraversalVL
   Int
   (a, a1, a2, a3, a4, a5, a6, a7, a8)
   (b, b1, b2, b3, b4, b5, b6, b7, b8)
   a
   b
 -> IxTraversal
      Int
      (a, a1, a2, a3, a4, a5, a6, a7, a8)
      (b, b1, b2, b3, b4, b5, b6, b7, b8)
      a
      b)
-> IxTraversalVL
     Int
     (a, a1, a2, a3, a4, a5, a6, a7, a8)
     (b, b1, b2, b3, b4, b5, b6, b7, b8)
     a
     b
-> IxTraversal
     Int
     (a, a1, a2, a3, a4, a5, a6, a7, a8)
     (b, b1, b2, b3, b4, b5, b6, b7, b8)
     a
     b
forall a b. (a -> b) -> a -> b
$ \Int -> a -> f b
f (a0, a1, a2, a3, a4, a5, a6, a7, a8) ->
    (,,,,,,,,) (b
 -> b
 -> b
 -> b
 -> b
 -> b
 -> b
 -> b
 -> b
 -> (b, b, b, b, b, b, b, b, b))
-> f b
-> f (b
      -> b -> b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> a -> f b
f Int
0 a
a0 f (b
   -> b -> b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b, b))
-> f b
-> f (b
      -> b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
1 a
a1 f (b -> b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b, b))
-> f b
-> f (b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
2 a
a2 f (b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b, b))
-> f b -> f (b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
3 a
a3 f (b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b, b))
-> f b -> f (b -> b -> b -> b -> (b, b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
4 a
a4
               f (b -> b -> b -> b -> (b, b, b, b, b, b, b, b, b))
-> f b -> f (b -> b -> b -> (b, b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
5 a
a5 f (b -> b -> b -> (b, b, b, b, b, b, b, b, b))
-> f b -> f (b -> b -> (b, b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
6 a
a6 f (b -> b -> (b, b, b, b, b, b, b, b, b))
-> f b -> f (b -> (b, b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
7 a
a7 f (b -> (b, b, b, b, b, b, b, b, b))
-> f b -> f (b, b, b, b, b, b, b, b, b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
8 a
a8
  {-# INLINE[1] each #-}

-- | @'each' :: 'IxTraversal' 'Int' (a, a, a, a, a, a, a, a, a, a) (b, b, b, b,
-- b, b, b, b, b, b) a b@
instance
  (a ~ a1, a ~ a2, a ~ a3, a ~ a4, a ~ a5, a ~ a6, a ~ a7, a ~ a8, a ~ a9,
   b ~ b1, b ~ b2, b ~ b3, b ~ b4, b ~ b5, b ~ b6, b ~ b7, b ~ b8, b ~ b9
  ) => Each Int (a, a1, a2, a3, a4, a5, a6, a7, a8, a9)
                (b, b1, b2, b3, b4, b5, b6, b7, b8, b9) a b where
  each :: IxTraversal
  Int
  (a, a1, a2, a3, a4, a5, a6, a7, a8, a9)
  (b, b1, b2, b3, b4, b5, b6, b7, b8, b9)
  a
  b
each = IxTraversalVL
  Int
  (a, a1, a2, a3, a4, a5, a6, a7, a8, a9)
  (b, b1, b2, b3, b4, b5, b6, b7, b8, b9)
  a
  b
-> IxTraversal
     Int
     (a, a1, a2, a3, a4, a5, a6, a7, a8, a9)
     (b, b1, b2, b3, b4, b5, b6, b7, b8, b9)
     a
     b
forall i s t a b. IxTraversalVL i s t a b -> IxTraversal i s t a b
itraversalVL (IxTraversalVL
   Int
   (a, a1, a2, a3, a4, a5, a6, a7, a8, a9)
   (b, b1, b2, b3, b4, b5, b6, b7, b8, b9)
   a
   b
 -> IxTraversal
      Int
      (a, a1, a2, a3, a4, a5, a6, a7, a8, a9)
      (b, b1, b2, b3, b4, b5, b6, b7, b8, b9)
      a
      b)
-> IxTraversalVL
     Int
     (a, a1, a2, a3, a4, a5, a6, a7, a8, a9)
     (b, b1, b2, b3, b4, b5, b6, b7, b8, b9)
     a
     b
-> IxTraversal
     Int
     (a, a1, a2, a3, a4, a5, a6, a7, a8, a9)
     (b, b1, b2, b3, b4, b5, b6, b7, b8, b9)
     a
     b
forall a b. (a -> b) -> a -> b
$ \Int -> a -> f b
f (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) ->
    (,,,,,,,,,) (b
 -> b
 -> b
 -> b
 -> b
 -> b
 -> b
 -> b
 -> b
 -> b
 -> (b, b, b, b, b, b, b, b, b, b))
-> f b
-> f (b
      -> b
      -> b
      -> b
      -> b
      -> b
      -> b
      -> b
      -> b
      -> (b, b, b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> a -> f b
f Int
0 a
a0 f (b
   -> b
   -> b
   -> b
   -> b
   -> b
   -> b
   -> b
   -> b
   -> (b, b, b, b, b, b, b, b, b, b))
-> f b
-> f (b
      -> b
      -> b
      -> b
      -> b
      -> b
      -> b
      -> b
      -> (b, b, b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
1 a
a1 f (b
   -> b
   -> b
   -> b
   -> b
   -> b
   -> b
   -> b
   -> (b, b, b, b, b, b, b, b, b, b))
-> f b
-> f (b
      -> b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
2 a
a2 f (b
   -> b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b, b, b))
-> f b
-> f (b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
3 a
a3 f (b -> b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b, b, b))
-> f b
-> f (b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
4 a
a4
                f (b -> b -> b -> b -> b -> (b, b, b, b, b, b, b, b, b, b))
-> f b -> f (b -> b -> b -> b -> (b, b, b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
5 a
a5 f (b -> b -> b -> b -> (b, b, b, b, b, b, b, b, b, b))
-> f b -> f (b -> b -> b -> (b, b, b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
6 a
a6 f (b -> b -> b -> (b, b, b, b, b, b, b, b, b, b))
-> f b -> f (b -> b -> (b, b, b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
7 a
a7 f (b -> b -> (b, b, b, b, b, b, b, b, b, b))
-> f b -> f (b -> (b, b, b, b, b, b, b, b, b, b))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
8 a
a8 f (b -> (b, b, b, b, b, b, b, b, b, b))
-> f b -> f (b, b, b, b, b, b, b, b, b, b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> a -> f b
f Int
9 a
a9
  {-# INLINE[1] each #-}

-- | @'each' :: 'IxTraversal' ('Either' () ()) ('Either' a a) ('Either' b b) a
-- b@
instance
  (a ~ a', b ~ b'
  ) => Each (Either () ()) (Either a a') (Either b b') a b where
  each :: IxTraversal (Either () ()) (Either a a') (Either b b') a b
each = Optic A_Lens (WithIx (Either () ())) (Either a a) (Either b b) a b
-> Optic
     A_Traversal (WithIx (Either () ())) (Either a a) (Either b b) a b
forall destKind srcKind (is :: IxList) s t a b.
Is srcKind destKind =>
Optic srcKind is s t a b -> Optic destKind is s t a b
castOptic Optic A_Lens (WithIx (Either () ())) (Either a a) (Either b b) a b
forall a b. IxLens (Either () ()) (Either a a) (Either b b) a b
chosen
  {-# INLINE[1] each #-}

-- | @'each' :: ('RealFloat' a, 'RealFloat' b) => 'IxTraversal' (Either () ())
-- ('Complex' a) ('Complex' b) a b@
instance Each (Either () ()) (Complex a) (Complex b) a b where
  each :: IxTraversal (Either () ()) (Complex a) (Complex b) a b
each = IxTraversalVL (Either () ()) (Complex a) (Complex b) a b
-> IxTraversal (Either () ()) (Complex a) (Complex b) a b
forall i s t a b. IxTraversalVL i s t a b -> IxTraversal i s t a b
itraversalVL (IxTraversalVL (Either () ()) (Complex a) (Complex b) a b
 -> IxTraversal (Either () ()) (Complex a) (Complex b) a b)
-> IxTraversalVL (Either () ()) (Complex a) (Complex b) a b
-> IxTraversal (Either () ()) (Complex a) (Complex b) a b
forall a b. (a -> b) -> a -> b
$ \Either () () -> a -> f b
f (a :+ b) -> b -> b -> Complex b
forall a. a -> a -> Complex a
(:+) (b -> b -> Complex b) -> f b -> f (b -> Complex b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Either () () -> a -> f b
f (() -> Either () ()
forall a b. a -> Either a b
Left ()) a
a f (b -> Complex b) -> f b -> f (Complex b)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Either () () -> a -> f b
f (() -> Either () ()
forall a b. b -> Either a b
Right ()) a
b
  {-# INLINE[1] each #-}

-- | @'each' :: 'IxTraversal' k ('Map' k a) ('Map' k b) a b@
instance k ~ k' => Each k (Map k a) (Map k' b) a b where
  -- traverseWithKey has best performance for all flavours for some reason.
  each :: IxTraversal k (Map k a) (Map k' b) a b
each = IxTraversalVL k (Map k a) (Map k' b) a b
-> IxTraversal k (Map k a) (Map k' b) a b
forall i s t a b. IxTraversalVL i s t a b -> IxTraversal i s t a b
itraversalVL IxTraversalVL k (Map k a) (Map k' b) a b
forall (t :: * -> *) k a b.
Applicative t =>
(k -> a -> t b) -> Map k a -> t (Map k b)
Map.traverseWithKey
  {-# INLINE[1] each #-}

-- | @'each' :: 'IxTraversal' 'Int' ('IntMap' a) ('IntMap' b) a b@
instance Each Int (IntMap a) (IntMap b) a b where
  -- traverseWithKey has best performance for all flavours for some reason.
  each :: IxTraversal Int (IntMap a) (IntMap b) a b
each = IxTraversalVL Int (IntMap a) (IntMap b) a b
-> IxTraversal Int (IntMap a) (IntMap b) a b
forall i s t a b. IxTraversalVL i s t a b -> IxTraversal i s t a b
itraversalVL IxTraversalVL Int (IntMap a) (IntMap b) a b
forall (t :: * -> *) a b.
Applicative t =>
(Int -> a -> t b) -> IntMap a -> t (IntMap b)
IntMap.traverseWithKey
  {-# INLINE[1] each #-}

-- | @'each' :: 'IxTraversal' 'Int' [a] [b] a b@
instance Each Int [a] [b] a b

-- | @'each' :: 'IxTraversal' 'Int' (NonEmpty a) (NonEmpty b) a b@
instance Each Int (NonEmpty a) (NonEmpty b) a b

-- | @'each' :: 'IxTraversal' () ('Identity' a) ('Identity' b) a b@
instance Each () (Identity a) (Identity b) a b

-- | @'each' :: 'IxTraversal' () ('Maybe' a) ('Maybe' b) a b@
instance Each () (Maybe a) (Maybe b) a b

-- | @'each' :: 'IxTraversal' 'Int' ('Seq' a) ('Seq' b) a b@
instance Each Int (Seq a) (Seq b) a b

-- | @'each' :: 'IxTraversal' [Int] ('Tree' a) ('Tree' b) a b@
instance Each [Int] (Tree a) (Tree b) a b

-- | @'each' :: 'Ix' i => 'IxTraversal' i ('Array' i a) ('Array' i b) a b@
instance (Ix i, i ~ j) => Each i (Array i a) (Array j b) a b

-- $setup
-- >>> import Optics.Core