From 99d1402a06fb729bc199732e1784324299018324 Mon Sep 17 00:00:00 2001 From: Matthias Fischmann Date: Wed, 16 Sep 2015 12:43:50 +0200 Subject: [PATCH] ToSample instances for longer tuples (up to 7). --- servant-docs/src/Servant/Docs/Internal.hs | 66 +++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/servant-docs/src/Servant/Docs/Internal.hs b/servant-docs/src/Servant/Docs/Internal.hs index 728a3b7c..e502ea61 100644 --- a/servant-docs/src/Servant/Docs/Internal.hs +++ b/servant-docs/src/Servant/Docs/Internal.hs @@ -1006,3 +1006,69 @@ instance ( ToSample a a ", " <> te <> ")" , (va, vb, vc, vd, ve)) + +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) where + toSample _ = (,,,,,) + <$> toSample (Proxy :: Proxy a) + <*> toSample (Proxy :: Proxy b) + <*> toSample (Proxy :: Proxy c) + <*> toSample (Proxy :: Proxy d) + <*> toSample (Proxy :: Proxy e) + <*> toSample (Proxy :: Proxy f) + toSamples _ = render + <$> toSamples (Proxy :: Proxy a) + <*> toSamples (Proxy :: Proxy b) + <*> toSamples (Proxy :: Proxy c) + <*> toSamples (Proxy :: Proxy d) + <*> toSamples (Proxy :: Proxy e) + <*> toSamples (Proxy :: Proxy f) + where render (ta, va) (tb, vb) (tc, vc) (td, vd) (te, ve) (tf, vf) + = ("(" <> ta <> + ", " <> tb <> + ", " <> tc <> + ", " <> td <> + ", " <> te <> + ", " <> tf <> + ")" + , (va, vb, vc, vd, ve, vf)) + +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) where + toSample _ = (,,,,,,) + <$> toSample (Proxy :: Proxy a) + <*> toSample (Proxy :: Proxy b) + <*> toSample (Proxy :: Proxy c) + <*> toSample (Proxy :: Proxy d) + <*> toSample (Proxy :: Proxy e) + <*> toSample (Proxy :: Proxy f) + <*> toSample (Proxy :: Proxy g) + toSamples _ = render + <$> toSamples (Proxy :: Proxy a) + <*> toSamples (Proxy :: Proxy b) + <*> toSamples (Proxy :: Proxy c) + <*> toSamples (Proxy :: Proxy d) + <*> toSamples (Proxy :: Proxy e) + <*> toSamples (Proxy :: Proxy f) + <*> toSamples (Proxy :: Proxy g) + where render (ta, va) (tb, vb) (tc, vc) (td, vd) (te, ve) (tf, vf) (tg, vg) + = ("(" <> ta <> + ", " <> tb <> + ", " <> tc <> + ", " <> td <> + ", " <> te <> + ", " <> tf <> + ", " <> tg <> + ")" + , (va, vb, vc, vd, ve, vf, vg))