Skip to content
This repository
Browse code

TFs->FDs

  • Loading branch information...
commit a16e0b1dc23caffe5a13bf796d516bfece11fd4b 1 parent eba5f14
Edward Kmett authored August 10, 2012
2  docs
... ...
@@ -1 +1 @@
1  
-Subproject commit 8c06ba29fb22cdaee1a0492ba582a1c6a81469a7
  1
+Subproject commit 6be22467a1c0f049d3a4f4219336432161490e10
428  src/Control/Lens/Type.hs
... ...
@@ -1,10 +1,9 @@
1 1
 {-# LANGUAGE CPP #-}
2 2
 {-# LANGUAGE Rank2Types #-}
3  
-{-# LANGUAGE TypeFamilies #-}
4  
-{-# LANGUAGE FlexibleContexts #-}
5  
-{-# LANGUAGE FlexibleInstances #-}
6 3
 {-# LANGUAGE LiberalTypeSynonyms #-}
7 4
 {-# LANGUAGE MultiParamTypeClasses #-}
  5
+{-# LANGUAGE FunctionalDependencies #-}
  6
+{-# LANGUAGE FlexibleInstances #-}
8 7
 
9 8
 #ifndef MIN_VERSION_mtl
10 9
 #define MIN_VERSION_mtl(x,y,z) 1
@@ -60,7 +59,15 @@ module Control.Lens.Type
60 59
 
61 60
   -- * Common Lenses
62 61
   -- ** Tuples
63  
-  , Tuple1(..), Tuple2(..), Tuple3(..), Tuple4(..), Tuple5(..), Tuple6(..), Tuple7(..), Tuple8(..), Tuple9(..)
  62
+  , Field1(..)
  63
+  , Field2(..)
  64
+  , Field3(..)
  65
+  , Field4(..)
  66
+  , Field5(..)
  67
+  , Field6(..)
  68
+  , Field7(..)
  69
+  , Field8(..)
  70
+  , Field9(..)
64 71
   -- ** Functions
65 72
   , resultAt
66 73
 
@@ -84,11 +91,6 @@ module Control.Lens.Type
84 91
   , SimpleLensLike
85 92
   , SimpleOverloaded
86 93
 
87  
-  -- * Tuple Fields
88  
-  , Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field9
89  
-
90  
-  -- * Tuple Field Substitutions
91  
-  , Subst1, Subst2, Subst3, Subst4, Subst5, Subst6, Subst7, Subst8, Subst9
92 94
   ) where
93 95
 
94 96
 import Control.Applicative              as Applicative
@@ -553,52 +555,8 @@ l <&&= b = l <%= (&& b)
553 555
 l <<>= r = l <%= (`mappend` r)
554 556
 {-# INLINE (<<>=) #-}
555 557
 
556  
--- | Access the 1st field of a tuple
557  
---
558  
--- @
559  
--- type instance Field1 (a,b) = a
560  
--- type instance Field1 (a,b,c) = a
561  
--- type instance Field1 (a,b,c,d) = a
562  
--- type instance Field1 (a,b,c,d,e) = a
563  
--- type instance Field1 (a,b,c,d,e,f) = a
564  
--- type instance Field1 (a,b,c,d,e,f,g) = a
565  
--- type instance Field1 (a,b,c,d,e,f,g,h) = a
566  
--- type instance Field1 (a,b,c,d,e,f,g,h,i) = a
567  
--- @
568  
-type family Field1 a
569  
-type instance Field1 (a,b) = a
570  
-type instance Field1 (a,b,c) = a
571  
-type instance Field1 (a,b,c,d) = a
572  
-type instance Field1 (a,b,c,d,e) = a
573  
-type instance Field1 (a,b,c,d,e,f) = a
574  
-type instance Field1 (a,b,c,d,e,f,g) = a
575  
-type instance Field1 (a,b,c,d,e,f,g,h) = a
576  
-type instance Field1 (a,b,c,d,e,f,g,h,i) = a
577  
-
578  
--- | Change the type of the 1st field in a tuple
579  
---
580  
--- @
581  
--- type instance Subst1 (a,b) a' = (a',b)
582  
--- type instance Subst1 (a,b,c) a' = (a',b,c)
583  
--- type instance Subst1 (a,b,c,d) a' = (a',b,c,d)
584  
--- type instance Subst1 (a,b,c,d,e) a' = (a',b,c,d,e)
585  
--- type instance Subst1 (a,b,c,d,e,f) a' = (a',b,c,d,e,f)
586  
--- type instance Subst1 (a,b,c,d,e,f,g) a' = (a',b,c,d,e,f,g)
587  
--- type instance Subst1 (a,b,c,d,e,f,g,h) a' = (a',b,c,d,e,f,g,h)
588  
--- type instance Subst1 (a,b,c,d,e,f,g,h,i) a' = (a',b,c,d,e,f,g,h,i)
589  
--- @
590  
-type family Subst1 a b
591  
-type instance Subst1 (a,b) a' = (a',b)
592  
-type instance Subst1 (a,b,c) a' = (a',b,c)
593  
-type instance Subst1 (a,b,c,d) a' = (a',b,c,d)
594  
-type instance Subst1 (a,b,c,d,e) a' = (a',b,c,d,e)
595  
-type instance Subst1 (a,b,c,d,e,f) a' = (a',b,c,d,e,f)
596  
-type instance Subst1 (a,b,c,d,e,f,g) a' = (a',b,c,d,e,f,g)
597  
-type instance Subst1 (a,b,c,d,e,f,g,h) a' = (a',b,c,d,e,f,g,h)
598  
-type instance Subst1 (a,b,c,d,e,f,g,h,i) a' = (a',b,c,d,e,f,g,h,i)
599  
-
600 558
 -- | Provides access to 1st field of a tuple.
601  
-class (Subst1 a (Field1 b) ~ b, Subst1 b (Field1 a) ~ a) => Tuple1 a b where
  559
+class Field1 a b c d | a -> c, b -> d, a d -> b, b c -> a where
602 560
   -- | Access the 1st field of a tuple (and possibly change its type).
603 561
   --
604 562
   -- >>> import Control.Lens
@@ -620,86 +578,42 @@ class (Subst1 a (Field1 b) ~ b, Subst1 b (Field1 a) ~ a) => Tuple1 a b where
620 578
   -- ...
621 579
   -- _1 :: 'Lens' (a,c,d,e,f,g,h,i) (a',b,c,d,e,f,g,h,i) a a'
622 580
   -- @
623  
-  _1 :: Lens a b (Field1 a) (Field1 b)
  581
+  _1 :: Lens a b c d
624 582
 
625  
-instance Tuple1 (a,b) (a',b) where
  583
+instance Field1 (a,b) (a',b) a a' where
626 584
   _1 k (a,b) = (\a' -> (a',b)) <$> k a
627 585
   {-# INLINE _1 #-}
628 586
 
629  
-instance Tuple1 (a,b,c) (a',b,c) where
  587
+instance Field1 (a,b,c) (a',b,c) a a' where
630 588
   _1 k (a,b,c) = (\a' -> (a',b,c)) <$> k a
631 589
   {-# INLINE _1 #-}
632 590
 
633  
-instance Tuple1 (a,b,c,d) (a',b,c,d) where
  591
+instance Field1 (a,b,c,d) (a',b,c,d) a a' where
634 592
   _1 k (a,b,c,d) = (\a' -> (a',b,c,d)) <$> k a
635 593
   {-# INLINE _1 #-}
636 594
 
637  
-instance Tuple1 (a,b,c,d,e) (a',b,c,d,e) where
  595
+instance Field1 (a,b,c,d,e) (a',b,c,d,e) a a' where
638 596
   _1 k (a,b,c,d,e) = (\a' -> (a',b,c,d,e)) <$> k a
639 597
   {-# INLINE _1 #-}
640 598
 
641  
-instance Tuple1 (a,b,c,d,e,f) (a',b,c,d,e,f) where
  599
+instance Field1 (a,b,c,d,e,f) (a',b,c,d,e,f) a a' where
642 600
   _1 k (a,b,c,d,e,f) = (\a' -> (a',b,c,d,e,f)) <$> k a
643 601
   {-# INLINE _1 #-}
644 602
 
645  
-instance Tuple1 (a,b,c,d,e,f,g) (a',b,c,d,e,f,g) where
  603
+instance Field1 (a,b,c,d,e,f,g) (a',b,c,d,e,f,g) a a' where
646 604
   _1 k (a,b,c,d,e,f,g) = (\a' -> (a',b,c,d,e,f,g)) <$> k a
647 605
   {-# INLINE _1 #-}
648 606
 
649  
-instance Tuple1 (a,b,c,d,e,f,g,h) (a',b,c,d,e,f,g,h) where
  607
+instance Field1 (a,b,c,d,e,f,g,h) (a',b,c,d,e,f,g,h) a a' where
650 608
   _1 k (a,b,c,d,e,f,g,h) = (\a' -> (a',b,c,d,e,f,g,h)) <$> k a
651 609
   {-# INLINE _1 #-}
652 610
 
653  
-instance Tuple1 (a,b,c,d,e,f,g,h,i) (a',b,c,d,e,f,g,h,i) where
  611
+instance Field1 (a,b,c,d,e,f,g,h,i) (a',b,c,d,e,f,g,h,i) a a' where
654 612
   _1 k (a,b,c,d,e,f,g,h,i) = (\a' -> (a',b,c,d,e,f,g,h,i)) <$> k a
655 613
   {-# INLINE _1 #-}
656 614
 
657  
--- | Extract the type of the 2nd field in a tuple
658  
---
659  
--- @
660  
--- type instance Field2 (a,b) = b
661  
--- type instance Field2 (a,b,c) = b
662  
--- type instance Field2 (a,b,c,d) = b
663  
--- type instance Field2 (a,b,c,d,e) = b
664  
--- type instance Field2 (a,b,c,d,e,f) = b
665  
--- type instance Field2 (a,b,c,d,e,f,g) = b
666  
--- type instance Field2 (a,b,c,d,e,f,g,h) = b
667  
--- type instance Field2 (a,b,c,d,e,f,g,h,i) = b
668  
--- @
669  
-type family Field2 a
670  
-type instance Field2 (a,b) = b
671  
-type instance Field2 (a,b,c) = b
672  
-type instance Field2 (a,b,c,d) = b
673  
-type instance Field2 (a,b,c,d,e) = b
674  
-type instance Field2 (a,b,c,d,e,f) = b
675  
-type instance Field2 (a,b,c,d,e,f,g) = b
676  
-type instance Field2 (a,b,c,d,e,f,g,h) = b
677  
-type instance Field2 (a,b,c,d,e,f,g,h,i) = b
678  
-
679  
--- | Change the type of the 2nd field in a tuple
680  
---
681  
--- @
682  
--- type instance Subst2 (a,b) b' = (a,b')
683  
--- type instance Subst2 (a,b,c) b' = (a,b',c)
684  
--- type instance Subst2 (a,b,c,d) b' = (a,b',c,d)
685  
--- type instance Subst2 (a,b,c,d,e) b' = (a,b',c,d,e)
686  
--- type instance Subst2 (a,b,c,d,e,f) b' = (a,b',c,d,e,f)
687  
--- type instance Subst2 (a,b,c,d,e,f,g) b' = (a,b',c,d,e,f,g)
688  
--- type instance Subst2 (a,b,c,d,e,f,g,h) b' = (a,b',c,d,e,f,g,h)
689  
--- type instance Subst2 (a,b,c,d,e,f,g,h,i) b' = (a,b',c,d,e,f,g,h,i)
690  
--- @
691  
-type family Subst2 a b
692  
-type instance Subst2 (a,b) b' = (a,b')
693  
-type instance Subst2 (a,b,c) b' = (a,b',c)
694  
-type instance Subst2 (a,b,c,d) b' = (a,b',c,d)
695  
-type instance Subst2 (a,b,c,d,e) b' = (a,b',c,d,e)
696  
-type instance Subst2 (a,b,c,d,e,f) b' = (a,b',c,d,e,f)
697  
-type instance Subst2 (a,b,c,d,e,f,g) b' = (a,b',c,d,e,f,g)
698  
-type instance Subst2 (a,b,c,d,e,f,g,h) b' = (a,b',c,d,e,f,g,h)
699  
-type instance Subst2 (a,b,c,d,e,f,g,h,i) b' = (a,b',c,d,e,f,g,h,i)
700  
-
701 615
 -- | Provides access to the 2nd field of a tuple
702  
-class (Subst2 a (Field2 b) ~ b, Subst2 b (Field2 a) ~ a, Tuple1 a a, Tuple1 b b) => Tuple2 a b where
  616
+class Field2 a b c d | a -> c, b -> d, a d -> b, b c -> a where
703 617
   -- | Access the 2nd field of a tuple
704 618
   --
705 619
   -- >>> import Control.Lens
@@ -711,379 +625,183 @@ class (Subst2 a (Field2 b) ~ b, Subst2 b (Field2 a) ~ a, Tuple1 a a, Tuple1 b b)
711 625
   -- 'Data.Traversable.traverse' '.' '_2' :: ('Applicative' f, 'Data.Traversable.Traversable' t) => (a -> f b) -> t (c, a) -> f (t (c, b))
712 626
   -- 'Control.Lens.Fold.foldMapOf' ('Data.Traversable.traverse' '.' '_2') :: ('Data.Traversable.Traversable' t, 'Data.Monoid.Monoid' m) => (c -> m) -> t (b, c) -> m
713 627
   -- @
714  
-  _2 :: Lens a b (Field2 a) (Field2 b)
  628
+  _2 :: Lens a b c d
715 629
 
716  
-instance Tuple2 (a,b) (a,b') where
  630
+instance Field2 (a,b) (a,b') b b' where
717 631
   _2 k (a,b) = (\b' -> (a,b')) <$> k b
718 632
   {-# INLINE _2 #-}
719 633
 
720  
-instance Tuple2 (a,b,c) (a,b',c) where
  634
+instance Field2 (a,b,c) (a,b',c) b b' where
721 635
   _2 k (a,b,c) = (\b' -> (a,b',c)) <$> k b
722 636
   {-# INLINE _2 #-}
723 637
 
724  
-instance Tuple2 (a,b,c,d) (a,b',c,d) where
  638
+instance Field2 (a,b,c,d) (a,b',c,d) b b' where
725 639
   _2 k (a,b,c,d) = (\b' -> (a,b',c,d)) <$> k b
726 640
   {-# INLINE _2 #-}
727 641
 
728  
-instance Tuple2 (a,b,c,d,e) (a,b',c,d,e) where
  642
+instance Field2 (a,b,c,d,e) (a,b',c,d,e) b b' where
729 643
   _2 k (a,b,c,d,e) = (\b' -> (a,b',c,d,e)) <$> k b
730 644
   {-# INLINE _2 #-}
731 645
 
732  
-instance Tuple2 (a,b,c,d,e,f) (a,b',c,d,e,f) where
  646
+instance Field2 (a,b,c,d,e,f) (a,b',c,d,e,f) b b' where
733 647
   _2 k (a,b,c,d,e,f) = (\b' -> (a,b',c,d,e,f)) <$> k b
734 648
   {-# INLINE _2 #-}
735 649
 
736  
-instance Tuple2 (a,b,c,d,e,f,g) (a,b',c,d,e,f,g) where
  650
+instance Field2 (a,b,c,d,e,f,g) (a,b',c,d,e,f,g) b b' where
737 651
   _2 k (a,b,c,d,e,f,g) = (\b' -> (a,b',c,d,e,f,g)) <$> k b
738 652
   {-# INLINE _2 #-}
739 653
 
740  
-instance Tuple2 (a,b,c,d,e,f,g,h) (a,b',c,d,e,f,g,h) where
  654
+instance Field2 (a,b,c,d,e,f,g,h) (a,b',c,d,e,f,g,h) b b' where
741 655
   _2 k (a,b,c,d,e,f,g,h) = (\b' -> (a,b',c,d,e,f,g,h)) <$> k b
742 656
   {-# INLINE _2 #-}
743 657
 
744  
-instance Tuple2 (a,b,c,d,e,f,g,h,i) (a,b',c,d,e,f,g,h,i) where
  658
+instance Field2 (a,b,c,d,e,f,g,h,i) (a,b',c,d,e,f,g,h,i) b b' where
745 659
   _2 k (a,b,c,d,e,f,g,h,i) = (\b' -> (a,b',c,d,e,f,g,h,i)) <$> k b
746 660
   {-# INLINE _2 #-}
747 661
 
748  
--- | Extract the type of the 3rd field of a tuple
749  
---
750  
--- @
751  
--- type instance Field3 (a,b,c) = c
752  
--- type instance Field3 (a,b,c,d) = c
753  
--- type instance Field3 (a,b,c,d,e) = c
754  
--- type instance Field3 (a,b,c,d,e,f) = c
755  
--- type instance Field3 (a,b,c,d,e,f,g) = c
756  
--- type instance Field3 (a,b,c,d,e,f,g,h) = c
757  
--- type instance Field3 (a,b,c,d,e,f,g,h,i) = c
758  
--- @
759  
-type family Field3 a
760  
-type instance Field3 (a,b,c) = c
761  
-type instance Field3 (a,b,c,d) = c
762  
-type instance Field3 (a,b,c,d,e) = c
763  
-type instance Field3 (a,b,c,d,e,f) = c
764  
-type instance Field3 (a,b,c,d,e,f,g) = c
765  
-type instance Field3 (a,b,c,d,e,f,g,h) = c
766  
-type instance Field3 (a,b,c,d,e,f,g,h,i) = c
767  
-
768  
--- | Change the type of the 3rd field of a tuple
769  
---
770  
--- @
771  
--- type instance Subst3 (a,b,c) c' = (a,b,c')
772  
--- type instance Subst3 (a,b,c,d) c' = (a,b,c',d)
773  
--- type instance Subst3 (a,b,c,d,e) c' = (a,b,c',d,e)
774  
--- type instance Subst3 (a,b,c,d,e,f) c' = (a,b,c',d,e,f)
775  
--- type instance Subst3 (a,b,c,d,e,f,g) c' = (a,b,c',d,e,f,g)
776  
--- type instance Subst3 (a,b,c,d,e,f,g,h) c' = (a,b,c',d,e,f,g,h)
777  
--- type instance Subst3 (a,b,c,d,e,f,g,h,i) c' = (a,b,c',d,e,f,g,h,i)
778  
--- @
779  
-type family Subst3 a b
780  
-type instance Subst3 (a,b,c) c' = (a,b,c')
781  
-type instance Subst3 (a,b,c,d) c' = (a,b,c',d)
782  
-type instance Subst3 (a,b,c,d,e) c' = (a,b,c',d,e)
783  
-type instance Subst3 (a,b,c,d,e,f) c' = (a,b,c',d,e,f)
784  
-type instance Subst3 (a,b,c,d,e,f,g) c' = (a,b,c',d,e,f,g)
785  
-type instance Subst3 (a,b,c,d,e,f,g,h) c' = (a,b,c',d,e,f,g,h)
786  
-type instance Subst3 (a,b,c,d,e,f,g,h,i) c' = (a,b,c',d,e,f,g,h,i)
787  
-
788 662
 -- | Provides access to the 3rd field of a tuple
789  
-class (Subst3 a (Field3 b) ~ b, Subst3 b (Field3 a) ~ a, Tuple2 a a, Tuple2 b b) => Tuple3 a b where
  663
+class Field3 a b c d | a -> c, b -> d, a d -> b, b c -> a where
790 664
   -- | Access the 3rd field of a tuple
791  
-  _3 :: Lens a b (Field3 a) (Field3 b)
  665
+  _3 :: Lens a b c d
792 666
 
793  
-instance Tuple3 (a,b,c) (a,b,c') where
  667
+instance Field3 (a,b,c) (a,b,c') c c' where
794 668
   _3 k (a,b,c) = (\c' -> (a,b,c')) <$> k c
795 669
   {-# INLINE _3 #-}
796 670
 
797  
-instance Tuple3 (a,b,c,d) (a,b,c',d) where
  671
+instance Field3 (a,b,c,d) (a,b,c',d) c c' where
798 672
   _3 k (a,b,c,d) = (\c' -> (a,b,c',d)) <$> k c
799 673
   {-# INLINE _3 #-}
800 674
 
801  
-instance Tuple3 (a,b,c,d,e) (a,b,c',d,e) where
  675
+instance Field3 (a,b,c,d,e) (a,b,c',d,e) c c' where
802 676
   _3 k (a,b,c,d,e) = (\c' -> (a,b,c',d,e)) <$> k c
803 677
   {-# INLINE _3 #-}
804 678
 
805  
-instance Tuple3 (a,b,c,d,e,f) (a,b,c',d,e,f) where
  679
+instance Field3 (a,b,c,d,e,f) (a,b,c',d,e,f) c c' where
806 680
   _3 k (a,b,c,d,e,f) = (\c' -> (a,b,c',d,e,f)) <$> k c
807 681
   {-# INLINE _3 #-}
808 682
 
809  
-instance Tuple3 (a,b,c,d,e,f,g) (a,b,c',d,e,f,g) where
  683
+instance Field3 (a,b,c,d,e,f,g) (a,b,c',d,e,f,g) c c' where
810 684
   _3 k (a,b,c,d,e,f,g) = (\c' -> (a,b,c',d,e,f,g)) <$> k c
811 685
   {-# INLINE _3 #-}
812 686
 
813  
-instance Tuple3 (a,b,c,d,e,f,g,h) (a,b,c',d,e,f,g,h) where
  687
+instance Field3 (a,b,c,d,e,f,g,h) (a,b,c',d,e,f,g,h) c c' where
814 688
   _3 k (a,b,c,d,e,f,g,h) = (\c' -> (a,b,c',d,e,f,g,h)) <$> k c
815 689
   {-# INLINE _3 #-}
816 690
 
817  
-instance Tuple3 (a,b,c,d,e,f,g,h,i) (a,b,c',d,e,f,g,h,i) where
  691
+instance Field3 (a,b,c,d,e,f,g,h,i) (a,b,c',d,e,f,g,h,i) c c' where
818 692
   _3 k (a,b,c,d,e,f,g,h,i) = (\c' -> (a,b,c',d,e,f,g,h,i)) <$> k c
819 693
   {-# INLINE _3 #-}
820 694
 
821  
--- | Extract the type of the 4th field of a tuple.
822  
---
823  
--- @
824  
--- type instance Field4 (a,b,c,d) = d
825  
--- type instance Field4 (a,b,c,d,e) = d
826  
--- type instance Field4 (a,b,c,d,e,f) = d
827  
--- type instance Field4 (a,b,c,d,e,f,g) = d
828  
--- type instance Field4 (a,b,c,d,e,f,g,h) = d
829  
--- type instance Field4 (a,b,c,d,e,f,g,h,i) = d
830  
--- @
831  
-type family Field4 a
832  
-type instance Field4 (a,b,c,d) = d
833  
-type instance Field4 (a,b,c,d,e) = d
834  
-type instance Field4 (a,b,c,d,e,f) = d
835  
-type instance Field4 (a,b,c,d,e,f,g) = d
836  
-type instance Field4 (a,b,c,d,e,f,g,h) = d
837  
-type instance Field4 (a,b,c,d,e,f,g,h,i) = d
838  
-
839  
--- | Change the type of the 4th field of a tuple
840  
---
841  
--- @
842  
--- type instance Subst4 (a,b,c,d) d' = (a,b,c,d')
843  
--- type instance Subst4 (a,b,c,d,e) d' = (a,b,c,d',e)
844  
--- type instance Subst4 (a,b,c,d,e,f) d' = (a,b,c,d',e,f)
845  
--- type instance Subst4 (a,b,c,d,e,f,g) d' = (a,b,c,d',e,f,g)
846  
--- type instance Subst4 (a,b,c,d,e,f,g,h) d' = (a,b,c,d',e,f,g,h)
847  
--- type instance Subst4 (a,b,c,d,e,f,g,h,i) d' = (a,b,c,d',e,f,g,h,i)
848  
--- @
849  
-type family Subst4 a b
850  
-type instance Subst4 (a,b,c,d) d' = (a,b,c,d')
851  
-type instance Subst4 (a,b,c,d,e) d' = (a,b,c,d',e)
852  
-type instance Subst4 (a,b,c,d,e,f) d' = (a,b,c,d',e,f)
853  
-type instance Subst4 (a,b,c,d,e,f,g) d' = (a,b,c,d',e,f,g)
854  
-type instance Subst4 (a,b,c,d,e,f,g,h) d' = (a,b,c,d',e,f,g,h)
855  
-type instance Subst4 (a,b,c,d,e,f,g,h,i) d' = (a,b,c,d',e,f,g,h,i)
856  
-
857 695
 -- | Provide access to the 4th field of a tuple
858  
-class (Subst4 a (Field4 b) ~ b, Subst4 b (Field4 a) ~ a, Tuple3 a a, Tuple3 b b) => Tuple4 a b where
  696
+class Field4 a b c d | a -> c, b -> d, a d -> b, b c -> a where
859 697
   -- | Access the 4th field of a tuple
860  
-  _4 :: Lens a b (Field4 a) (Field4 b)
  698
+  _4 :: Lens a b c d
861 699
 
862  
-instance Tuple4 (a,b,c,d) (a,b,c,d') where
  700
+instance Field4 (a,b,c,d) (a,b,c,d') d d' where
863 701
   _4 k (a,b,c,d) = (\d' -> (a,b,c,d')) <$> k d
864 702
   {-# INLINE _4 #-}
865 703
 
866  
-instance Tuple4 (a,b,c,d,e) (a,b,c,d',e) where
  704
+instance Field4 (a,b,c,d,e) (a,b,c,d',e) d d' where
867 705
   _4 k (a,b,c,d,e) = (\d' -> (a,b,c,d',e)) <$> k d
868 706
   {-# INLINE _4 #-}
869 707
 
870  
-instance Tuple4 (a,b,c,d,e,f) (a,b,c,d',e,f) where
  708
+instance Field4 (a,b,c,d,e,f) (a,b,c,d',e,f) d d' where
871 709
   _4 k (a,b,c,d,e,f) = (\d' -> (a,b,c,d',e,f)) <$> k d
872 710
   {-# INLINE _4 #-}
873 711
 
874  
-instance Tuple4 (a,b,c,d,e,f,g) (a,b,c,d',e,f,g) where
  712
+instance Field4 (a,b,c,d,e,f,g) (a,b,c,d',e,f,g) d d' where
875 713
   _4 k (a,b,c,d,e,f,g) = (\d' -> (a,b,c,d',e,f,g)) <$> k d
876 714
   {-# INLINE _4 #-}
877 715
 
878  
-instance Tuple4 (a,b,c,d,e,f,g,h) (a,b,c,d',e,f,g,h) where
  716
+instance Field4 (a,b,c,d,e,f,g,h) (a,b,c,d',e,f,g,h) d d' where
879 717
   _4 k (a,b,c,d,e,f,g,h) = (\d' -> (a,b,c,d',e,f,g,h)) <$> k d
880 718
   {-# INLINE _4 #-}
881 719
 
882  
-instance Tuple4 (a,b,c,d,e,f,g,h,i) (a,b,c,d',e,f,g,h,i) where
  720
+instance Field4 (a,b,c,d,e,f,g,h,i) (a,b,c,d',e,f,g,h,i) d d' where
883 721
   _4 k (a,b,c,d,e,f,g,h,i) = (\d' -> (a,b,c,d',e,f,g,h,i)) <$> k d
884 722
   {-# INLINE _4 #-}
885 723
 
886  
--- | Extract the type of the 5th field of a tuple.
887  
---
888  
--- @
889  
--- type instance Field5 (a,b,c,d,e) = e
890  
--- type instance Field5 (a,b,c,d,e,f) = e
891  
--- type instance Field5 (a,b,c,d,e,f,g) = e
892  
--- type instance Field5 (a,b,c,d,e,f,g,h) = e
893  
--- type instance Field5 (a,b,c,d,e,f,g,h,i) = e
894  
--- @
895  
-type family Field5 a
896  
-type instance Field5 (a,b,c,d,e) = e
897  
-type instance Field5 (a,b,c,d,e,f) = e
898  
-type instance Field5 (a,b,c,d,e,f,g) = e
899  
-type instance Field5 (a,b,c,d,e,f,g,h) = e
900  
-type instance Field5 (a,b,c,d,e,f,g,h,i) = e
901  
-
902  
--- | Change the type of the 5th field of a tuple.
903  
---
904  
--- @
905  
--- type instance Subst5 (a,b,c,d,e) e' = (a,b,c,d,e')
906  
--- type instance Subst5 (a,b,c,d,e,f) e' = (a,b,c,d,e',f)
907  
--- type instance Subst5 (a,b,c,d,e,f,g) e' = (a,b,c,d,e',f,g)
908  
--- type instance Subst5 (a,b,c,d,e,f,g,h) e' = (a,b,c,d,e',f,g,h)
909  
--- type instance Subst5 (a,b,c,d,e,f,g,h,i) e' = (a,b,c,d,e',f,g,h,i)
910  
--- @
911  
-type family Subst5 a b
912  
-type instance Subst5 (a,b,c,d,e) e' = (a,b,c,d,e')
913  
-type instance Subst5 (a,b,c,d,e,f) e' = (a,b,c,d,e',f)
914  
-type instance Subst5 (a,b,c,d,e,f,g) e' = (a,b,c,d,e',f,g)
915  
-type instance Subst5 (a,b,c,d,e,f,g,h) e' = (a,b,c,d,e',f,g,h)
916  
-type instance Subst5 (a,b,c,d,e,f,g,h,i) e' = (a,b,c,d,e',f,g,h,i)
917  
-
918 724
 -- | Provides access to the 5th field of a tuple
919  
-class (Subst5 a (Field5 b) ~ b, Subst5 b (Field5 a) ~ a, Tuple4 a a, Tuple4 b b) => Tuple5 a b where
  725
+class Field5 a b c d | a -> c, b -> d, a d -> b, b c -> a where
920 726
   -- | Access the 5th field of a tuple
921  
-  _5 :: Lens a b (Field5 a) (Field5 b)
  727
+  _5 :: Lens a b c d
922 728
 
923  
-instance Tuple5 (a,b,c,d,e) (a,b,c,d,e') where
  729
+instance Field5 (a,b,c,d,e) (a,b,c,d,e') e e' where
924 730
   _5 k (a,b,c,d,e) = (\e' -> (a,b,c,d,e')) <$> k e
925 731
   {-# INLINE _5 #-}
926 732
 
927  
-instance Tuple5 (a,b,c,d,e,f) (a,b,c,d,e',f) where
  733
+instance Field5 (a,b,c,d,e,f) (a,b,c,d,e',f) e e' where
928 734
   _5 k (a,b,c,d,e,f) = (\e' -> (a,b,c,d,e',f)) <$> k e
929 735
   {-# INLINE _5 #-}
930 736
 
931  
-instance Tuple5 (a,b,c,d,e,f,g) (a,b,c,d,e',f,g) where
  737
+instance Field5 (a,b,c,d,e,f,g) (a,b,c,d,e',f,g) e e' where
932 738
   _5 k (a,b,c,d,e,f,g) = (\e' -> (a,b,c,d,e',f,g)) <$> k e
933 739
   {-# INLINE _5 #-}
934 740
 
935  
-instance Tuple5 (a,b,c,d,e,f,g,h) (a,b,c,d,e',f,g,h) where
  741
+instance Field5 (a,b,c,d,e,f,g,h) (a,b,c,d,e',f,g,h) e e' where
936 742
   _5 k (a,b,c,d,e,f,g,h) = (\e' -> (a,b,c,d,e',f,g,h)) <$> k e
937 743
   {-# INLINE _5 #-}
938 744
 
939  
-instance Tuple5 (a,b,c,d,e,f,g,h,i) (a,b,c,d,e',f,g,h,i) where
  745
+instance Field5 (a,b,c,d,e,f,g,h,i) (a,b,c,d,e',f,g,h,i) e e' where
940 746
   _5 k (a,b,c,d,e,f,g,h,i) = (\e' -> (a,b,c,d,e',f,g,h,i)) <$> k e
941 747
   {-# INLINE _5 #-}
942 748
 
943  
--- | Extract the type of the 6th field of a tuple.
944  
---
945  
--- @
946  
--- type instance Field6 (a,b,c,d,e,f) = f
947  
--- type instance Field6 (a,b,c,d,e,f,g) = f
948  
--- type instance Field6 (a,b,c,d,e,f,g,h) = f
949  
--- type instance Field6 (a,b,c,d,e,f,g,h,i) = f
950  
--- @
951  
-type family Field6 a
952  
-type instance Field6 (a,b,c,d,e,f) = f
953  
-type instance Field6 (a,b,c,d,e,f,g) = f
954  
-type instance Field6 (a,b,c,d,e,f,g,h) = f
955  
-type instance Field6 (a,b,c,d,e,f,g,h,i) = f
956  
-
957  
--- | Change the type of the 6th field of a tuple.
958  
---
959  
--- @
960  
--- type instance Subst6 (a,b,c,d,e,f) f' = (a,b,c,d,e,f')
961  
--- type instance Subst6 (a,b,c,d,e,f,g) f' = (a,b,c,d,e,f',g)
962  
--- type instance Subst6 (a,b,c,d,e,f,g,h) f' = (a,b,c,d,e,f',g,h)
963  
--- type instance Subst6 (a,b,c,d,e,f,g,h,i) f' = (a,b,c,d,e,f',g,h,i)
964  
--- @
965  
-type family Subst6 a b
966  
-type instance Subst6 (a,b,c,d,e,f) f' = (a,b,c,d,e,f')
967  
-type instance Subst6 (a,b,c,d,e,f,g) f' = (a,b,c,d,e,f',g)
968  
-type instance Subst6 (a,b,c,d,e,f,g,h) f' = (a,b,c,d,e,f',g,h)
969  
-type instance Subst6 (a,b,c,d,e,f,g,h,i) f' = (a,b,c,d,e,f',g,h,i)
970  
-
971 749
 -- | Provides access to the 6th element of a tuple
972  
-class (Subst6 a (Field6 b) ~ b, Subst6 b (Field6 a) ~ a, Tuple5 a a, Tuple5 b b) => Tuple6 a b where
  750
+class Field6 a b c d | a -> c, b -> d, a d -> b, b c -> a where
973 751
   -- | Access the 6th field of a tuple
974  
-  _6 :: Lens a b (Field6 a) (Field6 b)
  752
+  _6 :: Lens a b c d
975 753
 
976  
-instance Tuple6 (a,b,c,d,e,f) (a,b,c,d,e,f') where
  754
+instance Field6 (a,b,c,d,e,f) (a,b,c,d,e,f') f f' where
977 755
   _6 k (a,b,c,d,e,f) = (\f' -> (a,b,c,d,e,f')) <$> k f
978 756
   {-# INLINE _6 #-}
979 757
 
980  
-instance Tuple6 (a,b,c,d,e,f,g) (a,b,c,d,e,f',g) where
  758
+instance Field6 (a,b,c,d,e,f,g) (a,b,c,d,e,f',g) f f' where
981 759
   _6 k (a,b,c,d,e,f,g) = (\f' -> (a,b,c,d,e,f',g)) <$> k f
982 760
   {-# INLINE _6 #-}
983 761
 
984  
-instance Tuple6 (a,b,c,d,e,f,g,h) (a,b,c,d,e,f',g,h) where
  762
+instance Field6 (a,b,c,d,e,f,g,h) (a,b,c,d,e,f',g,h) f f' where
985 763
   _6 k (a,b,c,d,e,f,g,h) = (\f' -> (a,b,c,d,e,f',g,h)) <$> k f
986 764
   {-# INLINE _6 #-}
987 765
 
988  
-instance Tuple6 (a,b,c,d,e,f,g,h,i) (a,b,c,d,e,f',g,h,i) where
  766
+instance Field6 (a,b,c,d,e,f,g,h,i) (a,b,c,d,e,f',g,h,i) f f' where
989 767
   _6 k (a,b,c,d,e,f,g,h,i) = (\f' -> (a,b,c,d,e,f',g,h,i)) <$> k f
990 768
   {-# INLINE _6 #-}
991 769
 
992  
--- | Extract the type of the 7th field of a tuple
993  
---
994  
--- @
995  
--- type instance Field7 (a,b,c,d,e,f,g) = g
996  
--- type instance Field7 (a,b,c,d,e,f,g,h) = g
997  
--- type instance Field7 (a,b,c,d,e,f,g,h,i) = g
998  
--- @
999  
-type family Field7 a
1000  
-type instance Field7 (a,b,c,d,e,f,g) = g
1001  
-type instance Field7 (a,b,c,d,e,f,g,h) = g
1002  
-type instance Field7 (a,b,c,d,e,f,g,h,i) = g
1003  
-
1004  
--- | Change the type of the 7th field of a tuple
1005  
---
1006  
--- @
1007  
--- type instance Subst7 (a,b,c,d,e,f,g) g' = (a,b,c,d,e,f,g')
1008  
--- type instance Subst7 (a,b,c,d,e,f,g,h) g' = (a,b,c,d,e,f,g',h)
1009  
--- type instance Subst7 (a,b,c,d,e,f,g,h,i) g' = (a,b,c,d,e,f,g',h,i)
1010  
--- @
1011  
-type family Subst7 a b
1012  
-type instance Subst7 (a,b,c,d,e,f,g) g' = (a,b,c,d,e,f,g')
1013  
-type instance Subst7 (a,b,c,d,e,f,g,h) g' = (a,b,c,d,e,f,g',h)
1014  
-type instance Subst7 (a,b,c,d,e,f,g,h,i) g' = (a,b,c,d,e,f,g',h,i)
1015  
-
1016 770
 -- | Provide access to the 7th field of a tuple
1017  
-class (Subst7 a (Field7 b) ~ b, Subst7 b (Field7 a) ~ a, Tuple6 a a, Tuple6 b b) => Tuple7 a b where
  771
+class Field7 a b c d | a -> c, b -> d, a d -> b, b c -> a where
1018 772
   -- | Access the 7th field of a tuple
1019  
-  _7 :: Lens a b (Field7 a) (Field7 b)
  773
+  _7 :: Lens a b c d
1020 774
 
1021  
-instance Tuple7 (a,b,c,d,e,f,g) (a,b,c,d,e,f,g') where
  775
+instance Field7 (a,b,c,d,e,f,g) (a,b,c,d,e,f,g') g g' where
1022 776
   _7 k (a,b,c,d,e,f,g) = (\g' -> (a,b,c,d,e,f,g')) <$> k g
1023 777
   {-# INLINE _7 #-}
1024 778
 
1025  
-instance Tuple7 (a,b,c,d,e,f,g,h) (a,b,c,d,e,f,g',h) where
  779
+instance Field7 (a,b,c,d,e,f,g,h) (a,b,c,d,e,f,g',h) g g' where
1026 780
   _7 k (a,b,c,d,e,f,g,h) = (\g' -> (a,b,c,d,e,f,g',h)) <$> k g
1027 781
   {-# INLINE _7 #-}
1028 782
 
1029  
-instance Tuple7 (a,b,c,d,e,f,g,h,i) (a,b,c,d,e,f,g',h,i) where
  783
+instance Field7 (a,b,c,d,e,f,g,h,i) (a,b,c,d,e,f,g',h,i) g g' where
1030 784
   _7 k (a,b,c,d,e,f,g,h,i) = (\g' -> (a,b,c,d,e,f,g',h,i)) <$> k g
1031 785
   {-# INLINE _7 #-}
1032 786
 
1033  
--- | Extract the type of the 8th field of a tuple
1034  
---
1035  
--- @
1036  
--- type instance Field8 (a,b,c,d,e,f,g,h) = h
1037  
--- type instance Field8 (a,b,c,d,e,f,g,h,i) = h
1038  
--- @
1039  
-type family Field8 a
1040  
-type instance Field8 (a,b,c,d,e,f,g,h) = h
1041  
-type instance Field8 (a,b,c,d,e,f,g,h,i) = h
1042  
-
1043  
--- | Change the type of the 8th field of a tuple
1044  
---
1045  
--- @
1046  
--- type instance Subst8 (a,b,c,d,e,f,g,h) h' = (a,b,c,d,e,f,g,h')
1047  
--- type instance Subst8 (a,b,c,d,e,f,g,h,i) h' = (a,b,c,d,e,f,g,h',i)
1048  
--- @
1049  
-type family Subst8 a b
1050  
-type instance Subst8 (a,b,c,d,e,f,g,h) h' = (a,b,c,d,e,f,g,h')
1051  
-type instance Subst8 (a,b,c,d,e,f,g,h,i) h' = (a,b,c,d,e,f,g,h',i)
1052  
-
1053 787
 -- | Provide access to the 8th field of a tuple
1054  
-class (Subst8 a (Field8 b) ~ b, Subst8 b (Field8 a) ~ a, Tuple7 a a, Tuple7 b b) => Tuple8 a b where
  788
+class Field8 a b c d | a -> c, b -> d, a d -> b, b c -> a where
1055 789
   -- | Access the 8th field of a tuple
1056  
-  _8 :: Lens a b (Field8 a) (Field8 b)
  790
+  _8 :: Lens a b c d
1057 791
 
1058  
-instance Tuple8 (a,b,c,d,e,f,g,h) (a,b,c,d,e,f,g,h') where
  792
+instance Field8 (a,b,c,d,e,f,g,h) (a,b,c,d,e,f,g,h') h h' where
1059 793
   _8 k (a,b,c,d,e,f,g,h) = (\h' -> (a,b,c,d,e,f,g,h')) <$> k h
1060 794
   {-# INLINE _8 #-}
1061 795
 
1062  
-instance Tuple8 (a,b,c,d,e,f,g,h,i) (a,b,c,d,e,f,g,h',i) where
  796
+instance Field8 (a,b,c,d,e,f,g,h,i) (a,b,c,d,e,f,g,h',i) h h' where
1063 797
   _8 k (a,b,c,d,e,f,g,h,i) = (\h' -> (a,b,c,d,e,f,g,h',i)) <$> k h
1064 798
   {-# INLINE _8 #-}
1065 799
 
1066  
--- | Extract the type of the 9th field of the tuple
1067  
---
1068  
--- @
1069  
--- type instance Field9 (a,b,c,d,e,f,g,h,i) = i
1070  
--- @
1071  
-type family Field9 a
1072  
-type instance Field9 (a,b,c,d,e,f,g,h,i) = i
1073  
-
1074  
--- | Change the type of the 9th field of a tuple
1075  
---
1076  
--- @
1077  
--- type instance Subst9 (a,b,c,d,e,f,g,h,i) i' = (a,b,c,d,e,f,g,h,i')
1078  
--- @
1079  
-type family Subst9 a b
1080  
-type instance Subst9 (a,b,c,d,e,f,g,h,i) i' = (a,b,c,d,e,f,g,h,i')
1081  
-
1082 800
 -- | Provides access to the 9th field of a tuple
1083  
-class (Subst9 a (Field9 b) ~ b, Subst9 b (Field9 a) ~ a, Tuple8 a a, Tuple8 b b) => Tuple9 a b where
  801
+class Field9 a b c d | a -> c, b -> d, a d -> b, b c -> a where
1084 802
   -- | Access the 9th field of a tuple
1085  
-  _9 :: Lens a b (Field9 a) (Field9 b)
  803
+  _9 :: Lens a b c d
1086 804
 
1087  
-instance Tuple9 (a,b,c,d,e,f,g,h,i) (a,b,c,d,e,f,g,h,i') where
  805
+instance Field9 (a,b,c,d,e,f,g,h,i) (a,b,c,d,e,f,g,h,i') i i' where
1088 806
   _9 k (a,b,c,d,e,f,g,h,i) = (\i' -> (a,b,c,d,e,f,g,h,i')) <$> k i
1089 807
   {-# INLINE _9 #-}

0 notes on commit a16e0b1

Please sign in to comment.
Something went wrong with that request. Please try again.