Skip to content

Commit

Permalink
Using the new Indexable definition we can strip many explicit signatu…
Browse files Browse the repository at this point in the history
…res from indexed types.
  • Loading branch information
ekmett committed Feb 21, 2013
1 parent c9466d3 commit b3c7e23
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 55 deletions.
20 changes: 10 additions & 10 deletions src/Control/Lens/Each.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,62 +137,62 @@ class (Functor f, Index s ~ Index t) => Each f s t a b | s -> a, t -> b, s b ->

-- | @'each' :: 'IndexedTraversal' 'Int' (a,a) (b,b) a b@
instance (Applicative f, a~a', b~b') => Each f (a,a') (b,b') a b where
each f ~(a,b) = (,) <$> f' (0 :: Int) a <*> f' 1 b
each f ~(a,b) = (,) <$> f' 0 a <*> f' 1 b
where f' = Lens.indexed f
{-# INLINE each #-}

-- | @'each' :: 'IndexedTraversal' 'Int' (a,a,a) (b,b,b) a b@
instance (Applicative f, a~a2, a~a3, b~b2, b~b3) => Each f (a,a2,a3) (b,b2,b3) a b where
each f ~(a,b,c) = (,,) <$> f' (0 :: Int) a <*> f' 1 b <*> f' 2 c
each f ~(a,b,c) = (,,) <$> f' 0 a <*> f' 1 b <*> f' 2 c
where f' = Lens.indexed f
{-# INLINE each #-}

-- | @'each' :: 'IndexedTraversal' 'Int' (a,a,a,a) (b,b,b,b) a b@
instance (Applicative f, a~a2, a~a3, a~a4, b~b2, b~b3, b~b4) => Each f (a,a2,a3,a4) (b,b2,b3,b4) a b where
each f ~(a,b,c,d) = (,,,) <$> f' (0 :: Int) a <*> f' 1 b <*> f' 2 c <*> f' 3 d
each f ~(a,b,c,d) = (,,,) <$> f' 0 a <*> f' 1 b <*> f' 2 c <*> f' 3 d
where f' = Lens.indexed f
{-# INLINE each #-}

-- | @'each' :: 'IndexedTraversal' 'Int' (a,a,a,a,a) (b,b,b,b,b) a b@
instance (Applicative f, a~a2, a~a3, a~a4, a~a5, b~b2, b~b3, b~b4, b~b5) => Each f (a,a2,a3,a4,a5) (b,b2,b3,b4,b5) a b where
each f ~(a,b,c,d,e) = (,,,,) <$> f' (0 :: Int) a <*> f' 1 b <*> f' 2 c <*> f' 3 d <*> f' 4 e
each f ~(a,b,c,d,e) = (,,,,) <$> f' 0 a <*> f' 1 b <*> f' 2 c <*> f' 3 d <*> f' 4 e
where f' = Lens.indexed f
{-# INLINE each #-}

-- | @'each' :: 'IndexedTraversal' 'Int' (a,a,a,a,a,a) (b,b,b,b,b,b) a b@
instance (Applicative f, a~a2, a~a3, a~a4, a~a5, a~a6, b~b2, b~b3, b~b4, b~b5, b~b6) => Each f (a,a2,a3,a4,a5,a6) (b,b2,b3,b4,b5,b6) a b where
each f ~(a,b,c,d,e,g) = (,,,,,) <$> f' (0 :: Int) a <*> f' 1 b <*> f' 2 c <*> f' 3 d <*> f' 4 e <*> f' 5 g
each f ~(a,b,c,d,e,g) = (,,,,,) <$> f' 0 a <*> f' 1 b <*> f' 2 c <*> f' 3 d <*> f' 4 e <*> f' 5 g
where f' = Lens.indexed f
{-# INLINE each #-}

-- | @'each' :: 'IndexedTraversal' 'Int' (a,a,a,a,a,a,a) (b,b,b,b,b,b,b) a b@
instance (Applicative f, a~a2, a~a3, a~a4, a~a5, a~a6, a~a7, b~b2, b~b3, b~b4, b~b5, b~b6, b~b7) => Each f (a,a2,a3,a4,a5,a6,a7) (b,b2,b3,b4,b5,b6,b7) a b where
each f ~(a,b,c,d,e,g,h) = (,,,,,,) <$> f' (0 :: Int) a <*> f' 1 b <*> f' 2 c <*> f' 3 d <*> f' 4 e <*> f' 5 g <*> f' 6 h
each f ~(a,b,c,d,e,g,h) = (,,,,,,) <$> f' 0 a <*> f' 1 b <*> f' 2 c <*> f' 3 d <*> f' 4 e <*> f' 5 g <*> f' 6 h
where f' = Lens.indexed f
{-# INLINE each #-}

-- | @'each' :: 'IndexedTraversal' 'Int' (a,a,a,a,a,a,a,a) (b,b,b,b,b,b,b,b) a b@
instance (Applicative f, a~a2, a~a3, a~a4, a~a5, a~a6, a~a7, a~a8, b~b2, b~b3, b~b4, b~b5, b~b6, b~b7, b~b8) => Each f (a,a2,a3,a4,a5,a6,a7,a8) (b,b2,b3,b4,b5,b6,b7,b8) a b where
each f ~(a,b,c,d,e,g,h,i) = (,,,,,,,) <$> f' (0 :: Int) a <*> f' 1 b <*> f' 2 c <*> f' 3 d <*> f' 4 e <*> f' 5 g <*> f' 6 h <*> f' 7 i
each f ~(a,b,c,d,e,g,h,i) = (,,,,,,,) <$> f' 0 a <*> f' 1 b <*> f' 2 c <*> f' 3 d <*> f' 4 e <*> f' 5 g <*> f' 6 h <*> f' 7 i
where f' = Lens.indexed f
{-# INLINE each #-}

-- | @'each' :: 'IndexedTraversal' 'Int' (a,a,a,a,a,a,a,a,a) (b,b,b,b,b,b,b,b,b) a b@
instance (Applicative f, a~a2, a~a3, a~a4, a~a5, a~a6, a~a7, a~a8, a~a9, b~b2, b~b3, b~b4, b~b5, b~b6, b~b7, b~b8, b~b9) => Each f (a,a2,a3,a4,a5,a6,a7,a8,a9) (b,b2,b3,b4,b5,b6,b7,b8,b9) a b where
each f ~(a,b,c,d,e,g,h,i,j) = (,,,,,,,,) <$> f' (0 :: Int) a <*> f' 1 b <*> f' 2 c <*> f' 3 d <*> f' 4 e <*> f' 5 g <*> f' 6 h <*> f' 7 i <*> f' 8 j
each f ~(a,b,c,d,e,g,h,i,j) = (,,,,,,,,) <$> f' 0 a <*> f' 1 b <*> f' 2 c <*> f' 3 d <*> f' 4 e <*> f' 5 g <*> f' 6 h <*> f' 7 i <*> f' 8 j
where f' = Lens.indexed f
{-# INLINE each #-}

#if MIN_VERSION_base(4,4,0)
-- | @'each' :: ('RealFloat' a, 'RealFloat' b) => 'IndexedTraversal' 'Int' ('Complex' a) ('Complex' b) a b@
instance Applicative f => Each f (Complex a) (Complex b) a b where
each f (a :+ b) = (:+) <$> f' (0 :: Int) a <*> f' (1 :: Int) b
each f (a :+ b) = (:+) <$> f' 0 a <*> f' 1 b
where f' = Lens.indexed f
{-# INLINE each #-}
#else
-- | @'each' :: 'IndexedTraversal' 'Int' ('Complex' a) ('Complex' b) a b@
instance (Applicative f, RealFloat a, RealFloat b) => Each f (Complex a) (Complex b) a b where
each f (a :+ b) = (:+) <$> f' (0 :: Int) a <*> f' 1 b
each f (a :+ b) = (:+) <$> f' 0 a <*> f' 1 b
where f' = Lens.indexed f
{-# INLINE each #-}
#endif
Expand Down
91 changes: 46 additions & 45 deletions src/Control/Lens/Tuple.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,41 +75,42 @@ class Field1 s t a b | s -> a, t -> b, s b -> t, t a -> s where
_1 :: IndexedLens Int s t a b

instance Field1 (Identity a) (Identity b) a b where
_1 f (Identity a) = Identity <$> indexed f (0 :: Int) a
_1 f (Identity a) = Identity <$> indexed f 0 a

-- | @
-- '_1' k ~(a,b) = (\\a' -> (a',b)) 'Data.Functor.<$>' k a
-- @
instance Field1 (a,b) (a',b) a a' where
_1 k ~(a,b) = indexed k (0 :: Int) a <&> \a' -> (a',b)
-- _1 k ~(a,b) = indexed k 0 a <&> \a' -> (a',b)
_1 k ~(a,b) = indexed k 0 a <&> \a' -> (a',b)
{-# INLINE _1 #-}

instance Field1 (a,b,c) (a',b,c) a a' where
_1 k ~(a,b,c) = indexed k (0 :: Int) a <&> \a' -> (a',b,c)
_1 k ~(a,b,c) = indexed k 0 a <&> \a' -> (a',b,c)
{-# INLINE _1 #-}

instance Field1 (a,b,c,d) (a',b,c,d) a a' where
_1 k ~(a,b,c,d) = indexed k (0 :: Int) a <&> \a' -> (a',b,c,d)
_1 k ~(a,b,c,d) = indexed k 0 a <&> \a' -> (a',b,c,d)
{-# INLINE _1 #-}

instance Field1 (a,b,c,d,e) (a',b,c,d,e) a a' where
_1 k ~(a,b,c,d,e) = indexed k (0 :: Int) a <&> \a' -> (a',b,c,d,e)
_1 k ~(a,b,c,d,e) = indexed k 0 a <&> \a' -> (a',b,c,d,e)
{-# INLINE _1 #-}

instance Field1 (a,b,c,d,e,f) (a',b,c,d,e,f) a a' where
_1 k ~(a,b,c,d,e,f) = indexed k (0 :: Int) a <&> \a' -> (a',b,c,d,e,f)
_1 k ~(a,b,c,d,e,f) = indexed k 0 a <&> \a' -> (a',b,c,d,e,f)
{-# INLINE _1 #-}

instance Field1 (a,b,c,d,e,f,g) (a',b,c,d,e,f,g) a a' where
_1 k ~(a,b,c,d,e,f,g) = indexed k (0 :: Int) a <&> \a' -> (a',b,c,d,e,f,g)
_1 k ~(a,b,c,d,e,f,g) = indexed k 0 a <&> \a' -> (a',b,c,d,e,f,g)
{-# INLINE _1 #-}

instance Field1 (a,b,c,d,e,f,g,h) (a',b,c,d,e,f,g,h) a a' where
_1 k ~(a,b,c,d,e,f,g,h) = indexed k (0 :: Int) a <&> \a' -> (a',b,c,d,e,f,g,h)
_1 k ~(a,b,c,d,e,f,g,h) = indexed k 0 a <&> \a' -> (a',b,c,d,e,f,g,h)
{-# INLINE _1 #-}

instance Field1 (a,b,c,d,e,f,g,h,i) (a',b,c,d,e,f,g,h,i) a a' where
_1 k ~(a,b,c,d,e,f,g,h,i) = indexed k (0 :: Int) a <&> \a' -> (a',b,c,d,e,f,g,h,i)
_1 k ~(a,b,c,d,e,f,g,h,i) = indexed k 0 a <&> \a' -> (a',b,c,d,e,f,g,h,i)
{-# INLINE _1 #-}

-- | Provides access to the 2nd field of a tuple.
Expand Down Expand Up @@ -137,35 +138,35 @@ class Field2 s t a b | s -> a, t -> b, s b -> t, t a -> s where
-- '_2' k ~(a,b) = (\\b' -> (a,b')) 'Data.Functor.<$>' k b
-- @
instance Field2 (a,b) (a,b') b b' where
_2 k ~(a,b) = indexed k (1 :: Int) b <&> \b' -> (a,b')
_2 k ~(a,b) = indexed k 1 b <&> \b' -> (a,b')
{-# INLINE _2 #-}

instance Field2 (a,b,c) (a,b',c) b b' where
_2 k ~(a,b,c) = indexed k (1 :: Int) b <&> \b' -> (a,b',c)
_2 k ~(a,b,c) = indexed k 1 b <&> \b' -> (a,b',c)
{-# INLINE _2 #-}

instance Field2 (a,b,c,d) (a,b',c,d) b b' where
_2 k ~(a,b,c,d) = indexed k (1 :: Int) b <&> \b' -> (a,b',c,d)
_2 k ~(a,b,c,d) = indexed k 1 b <&> \b' -> (a,b',c,d)
{-# INLINE _2 #-}

instance Field2 (a,b,c,d,e) (a,b',c,d,e) b b' where
_2 k ~(a,b,c,d,e) = indexed k (1 :: Int) b <&> \b' -> (a,b',c,d,e)
_2 k ~(a,b,c,d,e) = indexed k 1 b <&> \b' -> (a,b',c,d,e)
{-# INLINE _2 #-}

instance Field2 (a,b,c,d,e,f) (a,b',c,d,e,f) b b' where
_2 k ~(a,b,c,d,e,f) = indexed k (1 :: Int) b <&> \b' -> (a,b',c,d,e,f)
_2 k ~(a,b,c,d,e,f) = indexed k 1 b <&> \b' -> (a,b',c,d,e,f)
{-# INLINE _2 #-}

instance Field2 (a,b,c,d,e,f,g) (a,b',c,d,e,f,g) b b' where
_2 k ~(a,b,c,d,e,f,g) = indexed k (1 :: Int) b <&> \b' -> (a,b',c,d,e,f,g)
_2 k ~(a,b,c,d,e,f,g) = indexed k 1 b <&> \b' -> (a,b',c,d,e,f,g)
{-# INLINE _2 #-}

instance Field2 (a,b,c,d,e,f,g,h) (a,b',c,d,e,f,g,h) b b' where
_2 k ~(a,b,c,d,e,f,g,h) = indexed k (1 :: Int) b <&> \b' -> (a,b',c,d,e,f,g,h)
_2 k ~(a,b,c,d,e,f,g,h) = indexed k 1 b <&> \b' -> (a,b',c,d,e,f,g,h)
{-# INLINE _2 #-}

instance Field2 (a,b,c,d,e,f,g,h,i) (a,b',c,d,e,f,g,h,i) b b' where
_2 k ~(a,b,c,d,e,f,g,h,i) = indexed k (1 :: Int) b <&> \b' -> (a,b',c,d,e,f,g,h,i)
_2 k ~(a,b,c,d,e,f,g,h,i) = indexed k 1 b <&> \b' -> (a,b',c,d,e,f,g,h,i)
{-# INLINE _2 #-}

-- | Provides access to the 3rd field of a tuple.
Expand All @@ -174,31 +175,31 @@ class Field3 s t a b | s -> a, t -> b, s b -> t, t a -> s where
_3 :: IndexedLens Int s t a b

instance Field3 (a,b,c) (a,b,c') c c' where
_3 k ~(a,b,c) = indexed k (2 :: Int) c <&> \c' -> (a,b,c')
_3 k ~(a,b,c) = indexed k 2 c <&> \c' -> (a,b,c')
{-# INLINE _3 #-}

instance Field3 (a,b,c,d) (a,b,c',d) c c' where
_3 k ~(a,b,c,d) = indexed k (2 :: Int) c <&> \c' -> (a,b,c',d)
_3 k ~(a,b,c,d) = indexed k 2 c <&> \c' -> (a,b,c',d)
{-# INLINE _3 #-}

instance Field3 (a,b,c,d,e) (a,b,c',d,e) c c' where
_3 k ~(a,b,c,d,e) = indexed k (2 :: Int) c <&> \c' -> (a,b,c',d,e)
_3 k ~(a,b,c,d,e) = indexed k 2 c <&> \c' -> (a,b,c',d,e)
{-# INLINE _3 #-}

instance Field3 (a,b,c,d,e,f) (a,b,c',d,e,f) c c' where
_3 k ~(a,b,c,d,e,f) = indexed k (2 :: Int) c <&> \c' -> (a,b,c',d,e,f)
_3 k ~(a,b,c,d,e,f) = indexed k 2 c <&> \c' -> (a,b,c',d,e,f)
{-# INLINE _3 #-}

instance Field3 (a,b,c,d,e,f,g) (a,b,c',d,e,f,g) c c' where
_3 k ~(a,b,c,d,e,f,g) = indexed k (2 :: Int) c <&> \c' -> (a,b,c',d,e,f,g)
_3 k ~(a,b,c,d,e,f,g) = indexed k 2 c <&> \c' -> (a,b,c',d,e,f,g)
{-# INLINE _3 #-}

instance Field3 (a,b,c,d,e,f,g,h) (a,b,c',d,e,f,g,h) c c' where
_3 k ~(a,b,c,d,e,f,g,h) = indexed k (2 :: Int) c <&> \c' -> (a,b,c',d,e,f,g,h)
_3 k ~(a,b,c,d,e,f,g,h) = indexed k 2 c <&> \c' -> (a,b,c',d,e,f,g,h)
{-# INLINE _3 #-}

instance Field3 (a,b,c,d,e,f,g,h,i) (a,b,c',d,e,f,g,h,i) c c' where
_3 k ~(a,b,c,d,e,f,g,h,i) = indexed k (2 :: Int) c <&> \c' -> (a,b,c',d,e,f,g,h,i)
_3 k ~(a,b,c,d,e,f,g,h,i) = indexed k 2 c <&> \c' -> (a,b,c',d,e,f,g,h,i)
{-# INLINE _3 #-}

-- | Provide access to the 4th field of a tuple.
Expand All @@ -207,27 +208,27 @@ class Field4 s t a b | s -> a, t -> b, s b -> t, t a -> s where
_4 :: IndexedLens Int s t a b

instance Field4 (a,b,c,d) (a,b,c,d') d d' where
_4 k ~(a,b,c,d) = indexed k (3 :: Int) d <&> \d' -> (a,b,c,d')
_4 k ~(a,b,c,d) = indexed k 3 d <&> \d' -> (a,b,c,d')
{-# INLINE _4 #-}

instance Field4 (a,b,c,d,e) (a,b,c,d',e) d d' where
_4 k ~(a,b,c,d,e) = indexed k (3 :: Int) d <&> \d' -> (a,b,c,d',e)
_4 k ~(a,b,c,d,e) = indexed k 3 d <&> \d' -> (a,b,c,d',e)
{-# INLINE _4 #-}

instance Field4 (a,b,c,d,e,f) (a,b,c,d',e,f) d d' where
_4 k ~(a,b,c,d,e,f) = indexed k (3 :: Int) d <&> \d' -> (a,b,c,d',e,f)
_4 k ~(a,b,c,d,e,f) = indexed k 3 d <&> \d' -> (a,b,c,d',e,f)
{-# INLINE _4 #-}

instance Field4 (a,b,c,d,e,f,g) (a,b,c,d',e,f,g) d d' where
_4 k ~(a,b,c,d,e,f,g) = indexed k (3 :: Int) d <&> \d' -> (a,b,c,d',e,f,g)
_4 k ~(a,b,c,d,e,f,g) = indexed k 3 d <&> \d' -> (a,b,c,d',e,f,g)
{-# INLINE _4 #-}

instance Field4 (a,b,c,d,e,f,g,h) (a,b,c,d',e,f,g,h) d d' where
_4 k ~(a,b,c,d,e,f,g,h) = indexed k (3 :: Int) d <&> \d' -> (a,b,c,d',e,f,g,h)
_4 k ~(a,b,c,d,e,f,g,h) = indexed k 3 d <&> \d' -> (a,b,c,d',e,f,g,h)
{-# INLINE _4 #-}

instance Field4 (a,b,c,d,e,f,g,h,i) (a,b,c,d',e,f,g,h,i) d d' where
_4 k ~(a,b,c,d,e,f,g,h,i) = indexed k (3 :: Int) d <&> \d' -> (a,b,c,d',e,f,g,h,i)
_4 k ~(a,b,c,d,e,f,g,h,i) = indexed k 3 d <&> \d' -> (a,b,c,d',e,f,g,h,i)
{-# INLINE _4 #-}

-- | Provides access to the 5th field of a tuple.
Expand All @@ -236,23 +237,23 @@ class Field5 s t a b | s -> a, t -> b, s b -> t, t a -> s where
_5 :: IndexedLens Int s t a b

instance Field5 (a,b,c,d,e) (a,b,c,d,e') e e' where
_5 k ~(a,b,c,d,e) = indexed k (4 :: Int) e <&> \e' -> (a,b,c,d,e')
_5 k ~(a,b,c,d,e) = indexed k 4 e <&> \e' -> (a,b,c,d,e')
{-# INLINE _5 #-}

instance Field5 (a,b,c,d,e,f) (a,b,c,d,e',f) e e' where
_5 k ~(a,b,c,d,e,f) = indexed k (4 :: Int) e <&> \e' -> (a,b,c,d,e',f)
_5 k ~(a,b,c,d,e,f) = indexed k 4 e <&> \e' -> (a,b,c,d,e',f)
{-# INLINE _5 #-}

instance Field5 (a,b,c,d,e,f,g) (a,b,c,d,e',f,g) e e' where
_5 k ~(a,b,c,d,e,f,g) = indexed k (4 :: Int) e <&> \e' -> (a,b,c,d,e',f,g)
_5 k ~(a,b,c,d,e,f,g) = indexed k 4 e <&> \e' -> (a,b,c,d,e',f,g)
{-# INLINE _5 #-}

instance Field5 (a,b,c,d,e,f,g,h) (a,b,c,d,e',f,g,h) e e' where
_5 k ~(a,b,c,d,e,f,g,h) = indexed k (4 :: Int) e <&> \e' -> (a,b,c,d,e',f,g,h)
_5 k ~(a,b,c,d,e,f,g,h) = indexed k 4 e <&> \e' -> (a,b,c,d,e',f,g,h)
{-# INLINE _5 #-}

instance Field5 (a,b,c,d,e,f,g,h,i) (a,b,c,d,e',f,g,h,i) e e' where
_5 k ~(a,b,c,d,e,f,g,h,i) = indexed k (4 :: Int) e <&> \e' -> (a,b,c,d,e',f,g,h,i)
_5 k ~(a,b,c,d,e,f,g,h,i) = indexed k 4 e <&> \e' -> (a,b,c,d,e',f,g,h,i)
{-# INLINE _5 #-}

-- | Provides access to the 6th element of a tuple.
Expand All @@ -261,19 +262,19 @@ class Field6 s t a b | s -> a, t -> b, s b -> t, t a -> s where
_6 :: IndexedLens Int s t a b

instance Field6 (a,b,c,d,e,f) (a,b,c,d,e,f') f f' where
_6 k ~(a,b,c,d,e,f) = indexed k (5 :: Int) f <&> \f' -> (a,b,c,d,e,f')
_6 k ~(a,b,c,d,e,f) = indexed k 5 f <&> \f' -> (a,b,c,d,e,f')
{-# INLINE _6 #-}

instance Field6 (a,b,c,d,e,f,g) (a,b,c,d,e,f',g) f f' where
_6 k ~(a,b,c,d,e,f,g) = indexed k (5 :: Int) f <&> \f' -> (a,b,c,d,e,f',g)
_6 k ~(a,b,c,d,e,f,g) = indexed k 5 f <&> \f' -> (a,b,c,d,e,f',g)
{-# INLINE _6 #-}

instance Field6 (a,b,c,d,e,f,g,h) (a,b,c,d,e,f',g,h) f f' where
_6 k ~(a,b,c,d,e,f,g,h) = indexed k (5 :: Int) f <&> \f' -> (a,b,c,d,e,f',g,h)
_6 k ~(a,b,c,d,e,f,g,h) = indexed k 5 f <&> \f' -> (a,b,c,d,e,f',g,h)
{-# INLINE _6 #-}

instance Field6 (a,b,c,d,e,f,g,h,i) (a,b,c,d,e,f',g,h,i) f f' where
_6 k ~(a,b,c,d,e,f,g,h,i) = indexed k (5 :: Int) f <&> \f' -> (a,b,c,d,e,f',g,h,i)
_6 k ~(a,b,c,d,e,f,g,h,i) = indexed k 5 f <&> \f' -> (a,b,c,d,e,f',g,h,i)
{-# INLINE _6 #-}

-- | Provide access to the 7th field of a tuple.
Expand All @@ -282,15 +283,15 @@ class Field7 s t a b | s -> a, t -> b, s b -> t, t a -> s where
_7 :: IndexedLens Int s t a b

instance Field7 (a,b,c,d,e,f,g) (a,b,c,d,e,f,g') g g' where
_7 k ~(a,b,c,d,e,f,g) = indexed k (6 :: Int) g <&> \g' -> (a,b,c,d,e,f,g')
_7 k ~(a,b,c,d,e,f,g) = indexed k 6 g <&> \g' -> (a,b,c,d,e,f,g')
{-# INLINE _7 #-}

instance Field7 (a,b,c,d,e,f,g,h) (a,b,c,d,e,f,g',h) g g' where
_7 k ~(a,b,c,d,e,f,g,h) = indexed k (6 :: Int) g <&> \g' -> (a,b,c,d,e,f,g',h)
_7 k ~(a,b,c,d,e,f,g,h) = indexed k 6 g <&> \g' -> (a,b,c,d,e,f,g',h)
{-# INLINE _7 #-}

instance Field7 (a,b,c,d,e,f,g,h,i) (a,b,c,d,e,f,g',h,i) g g' where
_7 k ~(a,b,c,d,e,f,g,h,i) = indexed k (6 :: Int) g <&> \g' -> (a,b,c,d,e,f,g',h,i)
_7 k ~(a,b,c,d,e,f,g,h,i) = indexed k 6 g <&> \g' -> (a,b,c,d,e,f,g',h,i)
{-# INLINE _7 #-}

-- | Provide access to the 8th field of a tuple.
Expand All @@ -299,11 +300,11 @@ class Field8 s t a b | s -> a, t -> b, s b -> t, t a -> s where
_8 :: IndexedLens Int s t a b

instance Field8 (a,b,c,d,e,f,g,h) (a,b,c,d,e,f,g,h') h h' where
_8 k ~(a,b,c,d,e,f,g,h) = indexed k (7 :: Int) h <&> \h' -> (a,b,c,d,e,f,g,h')
_8 k ~(a,b,c,d,e,f,g,h) = indexed k 7 h <&> \h' -> (a,b,c,d,e,f,g,h')
{-# INLINE _8 #-}

instance Field8 (a,b,c,d,e,f,g,h,i) (a,b,c,d,e,f,g,h',i) h h' where
_8 k ~(a,b,c,d,e,f,g,h,i) = indexed k (7 :: Int) h <&> \h' -> (a,b,c,d,e,f,g,h',i)
_8 k ~(a,b,c,d,e,f,g,h,i) = indexed k 7 h <&> \h' -> (a,b,c,d,e,f,g,h',i)
{-# INLINE _8 #-}

-- | Provides access to the 9th field of a tuple.
Expand All @@ -312,5 +313,5 @@ class Field9 s t a b | s -> a, t -> b, s b -> t, t a -> s where
_9 :: IndexedLens Int s t a b

instance Field9 (a,b,c,d,e,f,g,h,i) (a,b,c,d,e,f,g,h,i') i i' where
_9 k ~(a,b,c,d,e,f,g,h,i) = indexed k (8 :: Int) i <&> \i' -> (a,b,c,d,e,f,g,h,i')
_9 k ~(a,b,c,d,e,f,g,h,i) = indexed k 8 i <&> \i' -> (a,b,c,d,e,f,g,h,i')
{-# INLINE _9 #-}

0 comments on commit b3c7e23

Please sign in to comment.