on master help sign in
Replace boileplate ToSample instances for tuples with empty ones

We just use default Generics implementation for tuples now.

commit75999b8211f0addde5384d633a70f8e18b02e505 authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateSat 19 Sep 2015, 01:19 (11 years ago) parent80f235b
1 file changed+7−149
servant-docs/src/Servant/Docs/Internal.hs+7−149
servant-docs/src/Servant/Docs/Internal.hs+7−149
@@ -964,152 +964,10 @@ instance HasDocs sublayout => HasDocs (Vault :> sublayout) where
964964
965965-- polymorphic 'ToSample' instances
966966
967−instance ( ToSample a a
968− , ToSample b b
969− ) => ToSample (a, b) (a, b) where
970− toSample _ = (,)
971− <$> toSample (Proxy :: Proxy a)
972− <*> toSample (Proxy :: Proxy b)
973− toSamples _ = render
974− <$> toSamples (Proxy :: Proxy a)
975− <*> toSamples (Proxy :: Proxy b)
976− where render (ta, va) (tb, vb)
977− = ("(" <> ta <>
978− ", " <> tb <>
979− ")"
980− , (va, vb))
981−
982−instance ( ToSample a a
983− , ToSample b b
984− , ToSample c c
985− ) => ToSample (a, b, c) (a, b, c) where
986− toSample _ = (,,)
987− <$> toSample (Proxy :: Proxy a)
988− <*> toSample (Proxy :: Proxy b)
989− <*> toSample (Proxy :: Proxy c)
990− toSamples _ = render
991− <$> toSamples (Proxy :: Proxy a)
992− <*> toSamples (Proxy :: Proxy b)
993− <*> toSamples (Proxy :: Proxy c)
994− where render (ta, va) (tb, vb) (tc, vc)
995− = ("(" <> ta <>
996− ", " <> tb <>
997− ", " <> tc <>
998− ")"
999− , (va, vb, vc))
1000−
1001−instance ( ToSample a a
1002− , ToSample b b
1003− , ToSample c c
1004− , ToSample d d
1005− ) => ToSample (a, b, c, d) (a, b, c, d) where
1006− toSample _ = (,,,)
1007− <$> toSample (Proxy :: Proxy a)
1008− <*> toSample (Proxy :: Proxy b)
1009− <*> toSample (Proxy :: Proxy c)
1010− <*> toSample (Proxy :: Proxy d)
1011− toSamples _ = render
1012− <$> toSamples (Proxy :: Proxy a)
1013− <*> toSamples (Proxy :: Proxy b)
1014− <*> toSamples (Proxy :: Proxy c)
1015− <*> toSamples (Proxy :: Proxy d)
1016− where render (ta, va) (tb, vb) (tc, vc) (td, vd)
1017− = ("(" <> ta <>
1018− ", " <> tb <>
1019− ", " <> tc <>
1020− ", " <> td <>
1021− ")"
1022− , (va, vb, vc, vd))
1023−
1024−instance ( ToSample a a
1025− , ToSample b b
1026− , ToSample c c
1027− , ToSample d d
1028− , ToSample e e
1029− ) => ToSample (a, b, c, d, e) (a, b, c, d, e) where
1030− toSample _ = (,,,,)
1031− <$> toSample (Proxy :: Proxy a)
1032− <*> toSample (Proxy :: Proxy b)
1033− <*> toSample (Proxy :: Proxy c)
1034− <*> toSample (Proxy :: Proxy d)
1035− <*> toSample (Proxy :: Proxy e)
1036− toSamples _ = render
1037− <$> toSamples (Proxy :: Proxy a)
1038− <*> toSamples (Proxy :: Proxy b)
1039− <*> toSamples (Proxy :: Proxy c)
1040− <*> toSamples (Proxy :: Proxy d)
1041− <*> toSamples (Proxy :: Proxy e)
1042− where render (ta, va) (tb, vb) (tc, vc) (td, vd) (te, ve)
1043− = ("(" <> ta <>
1044− ", " <> tb <>
1045− ", " <> tc <>
1046− ", " <> td <>
1047− ", " <> te <>
1048− ")"
1049− , (va, vb, vc, vd, ve))
1050−
1051−instance ( ToSample a a
1052− , ToSample b b
1053− , ToSample c c
1054− , ToSample d d
1055− , ToSample e e
1056− , ToSample f f
1057− ) => ToSample (a, b, c, d, e, f) (a, b, c, d, e, f) where
1058− toSample _ = (,,,,,)
1059− <$> toSample (Proxy :: Proxy a)
1060− <*> toSample (Proxy :: Proxy b)
1061− <*> toSample (Proxy :: Proxy c)
1062− <*> toSample (Proxy :: Proxy d)
1063− <*> toSample (Proxy :: Proxy e)
1064− <*> toSample (Proxy :: Proxy f)
1065− toSamples _ = render
1066− <$> toSamples (Proxy :: Proxy a)
1067− <*> toSamples (Proxy :: Proxy b)
1068− <*> toSamples (Proxy :: Proxy c)
1069− <*> toSamples (Proxy :: Proxy d)
1070− <*> toSamples (Proxy :: Proxy e)
1071− <*> toSamples (Proxy :: Proxy f)
1072− where render (ta, va) (tb, vb) (tc, vc) (td, vd) (te, ve) (tf, vf)
1073− = ("(" <> ta <>
1074− ", " <> tb <>
1075− ", " <> tc <>
1076− ", " <> td <>
1077− ", " <> te <>
1078− ", " <> tf <>
1079− ")"
1080− , (va, vb, vc, vd, ve, vf))
1081−
1082−instance ( ToSample a a
1083− , ToSample b b
1084− , ToSample c c
1085− , ToSample d d
1086− , ToSample e e
1087− , ToSample f f
1088− , ToSample g g
1089− ) => ToSample (a, b, c, d, e, f, g) (a, b, c, d, e, f, g) where
1090− toSample _ = (,,,,,,)
1091− <$> toSample (Proxy :: Proxy a)
1092− <*> toSample (Proxy :: Proxy b)
1093− <*> toSample (Proxy :: Proxy c)
1094− <*> toSample (Proxy :: Proxy d)
1095− <*> toSample (Proxy :: Proxy e)
1096− <*> toSample (Proxy :: Proxy f)
1097− <*> toSample (Proxy :: Proxy g)
1098− toSamples _ = render
1099− <$> toSamples (Proxy :: Proxy a)
1100− <*> toSamples (Proxy :: Proxy b)
1101− <*> toSamples (Proxy :: Proxy c)
1102− <*> toSamples (Proxy :: Proxy d)
1103− <*> toSamples (Proxy :: Proxy e)
1104− <*> toSamples (Proxy :: Proxy f)
1105− <*> toSamples (Proxy :: Proxy g)
1106− where render (ta, va) (tb, vb) (tc, vc) (td, vd) (te, ve) (tf, vf) (tg, vg)
1107− = ("(" <> ta <>
1108− ", " <> tb <>
1109− ", " <> tc <>
1110− ", " <> td <>
1111− ", " <> te <>
1112− ", " <> tf <>
1113− ", " <> tg <>
1114− ")"
1115− , (va, vb, vc, vd, ve, vf, vg))
967+instance (ToSample a a, ToSample b b) => ToSample (a, b) (a, b)
968+instance (ToSample a a, ToSample b b, ToSample c c) => ToSample (a, b, c) (a, b, c)
969+instance (ToSample a a, ToSample b b, ToSample c c, ToSample d d) => ToSample (a, b, c, d) (a, b, c, d)
970+instance (ToSample a a, ToSample b b, ToSample c c, ToSample d d, ToSample e e) => ToSample (a, b, c, d, e) (a, b, c, d, e)
971+instance (ToSample a a, ToSample b b, ToSample c c, ToSample d d, ToSample e e, ToSample f f) => ToSample (a, b, c, d, e, f) (a, b, c, d, e, f)
972+instance (ToSample a a, ToSample b b, ToSample c c, ToSample d d, ToSample e e, ToSample f f, ToSample g g) => ToSample (a, b, c, d, e, f, g) (a, b, c, d, e, f, g)
973+