@@ -403,13 +403,13 @@ class HasDocs layout where
403-- 'toSample': it lets you specify different responses along with
403-- 'toSample': it lets you specify different responses along with
404-- some context (as 'Text') that explains when you're supposed to
404-- some context (as 'Text') that explains when you're supposed to
405-- get the corresponding response.
405-- get the corresponding response.
406−class ToSample a b | a -> b where
406+class ToSample a where
407− toSamples :: Proxy a -> [(Text, b)]
407+ toSamples :: Proxy a -> [(Text, a)]
408− default toSamples :: (Generic a, Generic b, GToSample (Rep a) (Rep b)) => Proxy a -> [(Text, b)]
408+ default toSamples :: (Generic a, GToSample (Rep a)) => Proxy a -> [(Text, a)]
409 toSamples = defaultSamples
409 toSamples = defaultSamples
411-- | Sample input or output (if there is at least one).
411-- | Sample input or output (if there is at least one).
412−toSample :: forall a b. ToSample a b => Proxy a -> Maybe b
412+toSample :: forall a. ToSample a => Proxy a -> Maybe a
413toSample _ = snd <$> listToMaybe (toSamples (Proxy :: Proxy a))
413toSample _ = snd <$> listToMaybe (toSamples (Proxy :: Proxy a))
415-- | No samples.
415-- | No samples.
@@ -425,22 +425,22 @@ samples :: [a] -> [(Text, a)]
425samples = map ("",)
425samples = map ("",)
427-- | Default sample Generic-based inputs/outputs.
427-- | Default sample Generic-based inputs/outputs.
428−defaultSamples :: forall a b. (Generic a, Generic b, GToSample (Rep a) (Rep b)) => Proxy a -> [(Text, b)]
428+defaultSamples :: forall a. (Generic a, GToSample (Rep a)) => Proxy a -> [(Text, a)]
429defaultSamples _ = Omega.runOmega $ second to <$> gtoSamples (Proxy :: Proxy (Rep a))
429defaultSamples _ = Omega.runOmega $ second to <$> gtoSamples (Proxy :: Proxy (Rep a))
431-- | @'ToSample'@ for Generics.
431-- | @'ToSample'@ for Generics.
433-- The use of @'Omega'@ allows for more productive sample generation.
433-- The use of @'Omega'@ allows for more productive sample generation.
434−class GToSample t s where
434+class GToSample t where
435− gtoSamples :: proxy t -> Omega.Omega (Text, s x)
435+ gtoSamples :: proxy t -> Omega.Omega (Text, t x)
437−instance GToSample U1 U1 where
437+instance GToSample U1 where
438 gtoSamples _ = Omega.each (singleSample U1)
438 gtoSamples _ = Omega.each (singleSample U1)
440−instance GToSample V1 V1 where
440+instance GToSample V1 where
441 gtoSamples _ = empty
441 gtoSamples _ = empty
443−instance (GToSample p p', GToSample q q') => GToSample (p :*: q) (p' :*: q') where
443+instance (GToSample p, GToSample q) => GToSample (p :*: q) where
444 gtoSamples _ = render <$> ps <*> qs
444 gtoSamples _ = render <$> ps <*> qs
446 ps = gtoSamples (Proxy :: Proxy p)
446 ps = gtoSamples (Proxy :: Proxy p)
@@ -449,21 +449,18 @@ instance (GToSample p p', GToSample q q') => GToSample (p :*: q) (p' :*: q') whe
449 | T.null ta || T.null tb = (ta <> tb, a :*: b)
449 | T.null ta || T.null tb = (ta <> tb, a :*: b)
450 | otherwise = (ta <> ", " <> tb, a :*: b)
450 | otherwise = (ta <> ", " <> tb, a :*: b)
452−instance (GToSample p p', GToSample q q') => GToSample (p :+: q) (p' :+: q') where
452+instance (GToSample p, GToSample q) => GToSample (p :+: q) where
453 gtoSamples _ = lefts <|> rights
453 gtoSamples _ = lefts <|> rights
455 lefts = second L1 <$> gtoSamples (Proxy :: Proxy p)
455 lefts = second L1 <$> gtoSamples (Proxy :: Proxy p)
456 rights = second R1 <$> gtoSamples (Proxy :: Proxy q)
456 rights = second R1 <$> gtoSamples (Proxy :: Proxy q)
458−instance ToSample a b => GToSample (K1 i a) (K1 i b) where
458+instance ToSample a => GToSample (K1 i a) where
459 gtoSamples _ = second K1 <$> Omega.each (toSamples (Proxy :: Proxy a))
459 gtoSamples _ = second K1 <$> Omega.each (toSamples (Proxy :: Proxy a))
461−instance (GToSample f g) => GToSample (M1 i a f) (M1 i a g) where
461+instance (GToSample f) => GToSample (M1 i a f) where
462 gtoSamples _ = second M1 <$> gtoSamples (Proxy :: Proxy f)
462 gtoSamples _ = second M1 <$> gtoSamples (Proxy :: Proxy f)
464−instance ToSample a b => ToSample (Headers ls a) b where
465− toSamples _ = toSamples (Proxy :: Proxy a)
468class AllHeaderSamples ls where
465class AllHeaderSamples ls where
469 allHeaderToSample :: Proxy ls -> [HTTP.Header]
466 allHeaderToSample :: Proxy ls -> [HTTP.Header]
@@ -471,7 +468,7 @@ class AllHeaderSamples ls where
471instance AllHeaderSamples '[] where
468instance AllHeaderSamples '[] where
472 allHeaderToSample _ = []
469 allHeaderToSample _ = []
474−instance (ToByteString l, AllHeaderSamples ls, ToSample l l, KnownSymbol h)
471+instance (ToByteString l, AllHeaderSamples ls, ToSample l, KnownSymbol h)
475 => AllHeaderSamples (Header h l ': ls) where
472 => AllHeaderSamples (Header h l ': ls) where
476 allHeaderToSample _ = (mkHeader (toSample (Proxy :: Proxy l))) :
473 allHeaderToSample _ = (mkHeader (toSample (Proxy :: Proxy l))) :
477 allHeaderToSample (Proxy :: Proxy ls)
474 allHeaderToSample (Proxy :: Proxy ls)
@@ -481,7 +478,7 @@ instance (ToByteString l, AllHeaderSamples ls, ToSample l l, KnownSymbol h)
482-- | Synthesise a sample value of a type, encoded in the specified media types.
479-- | Synthesise a sample value of a type, encoded in the specified media types.
483sampleByteString
480sampleByteString
484− :: forall ctypes a b. (ToSample a b, IsNonEmpty ctypes, AllMimeRender ctypes b)
481+ :: forall ctypes a. (ToSample a, IsNonEmpty ctypes, AllMimeRender ctypes a)
485 => Proxy ctypes
482 => Proxy ctypes
486 -> Proxy a
483 -> Proxy a
487 -> [(M.MediaType, ByteString)]
484 -> [(M.MediaType, ByteString)]
@@ -491,7 +488,7 @@ sampleByteString ctypes@Proxy Proxy =
491-- | Synthesise a list of sample values of a particular type, encoded in the
488-- | Synthesise a list of sample values of a particular type, encoded in the
492-- specified media types.
489-- specified media types.
493sampleByteStrings
490sampleByteStrings
494− :: forall ctypes a b. (ToSample a b, IsNonEmpty ctypes, AllMimeRender ctypes b)
491+ :: forall ctypes a. (ToSample a, IsNonEmpty ctypes, AllMimeRender ctypes a)
495 => Proxy ctypes
492 => Proxy ctypes
496 -> Proxy a
493 -> Proxy a
497 -> [(Text, M.MediaType, ByteString)]
494 -> [(Text, M.MediaType, ByteString)]
@@ -728,7 +725,7 @@ instance
728#if MIN_VERSION_base(4,8,0)
725#if MIN_VERSION_base(4,8,0)
729 {-# OVERLAPPABLe #-}
726 {-# OVERLAPPABLe #-}
731− (ToSample a b, IsNonEmpty cts, AllMimeRender cts b, SupportedTypes cts)
728+ (ToSample a, IsNonEmpty cts, AllMimeRender cts a, SupportedTypes cts)
732 => HasDocs (Delete cts a) where
729 => HasDocs (Delete cts a) where
733 docsFor Proxy (endpoint, action) DocOptions{..} =
730 docsFor Proxy (endpoint, action) DocOptions{..} =
734 single endpoint' action'
731 single endpoint' action'
@@ -743,7 +740,7 @@ instance
743#if MIN_VERSION_base(4,8,0)
740#if MIN_VERSION_base(4,8,0)
744 {-# OVERLAPPING #-}
741 {-# OVERLAPPING #-}
746− (ToSample a b, IsNonEmpty cts, AllMimeRender cts b, SupportedTypes cts
743+ (ToSample a, IsNonEmpty cts, AllMimeRender cts a, SupportedTypes cts
747 , AllHeaderSamples ls , GetHeaders (HList ls) )
744 , AllHeaderSamples ls , GetHeaders (HList ls) )
748 => HasDocs (Delete cts (Headers ls a)) where
745 => HasDocs (Delete cts (Headers ls a)) where
749 docsFor Proxy (endpoint, action) DocOptions{..} =
746 docsFor Proxy (endpoint, action) DocOptions{..} =
@@ -761,7 +758,7 @@ instance
761#if MIN_VERSION_base(4,8,0)
758#if MIN_VERSION_base(4,8,0)
762 {-# OVERLAPPABLe #-}
759 {-# OVERLAPPABLe #-}
764− (ToSample a b, IsNonEmpty cts, AllMimeRender cts b, SupportedTypes cts)
761+ (ToSample a, IsNonEmpty cts, AllMimeRender cts a, SupportedTypes cts)
765 => HasDocs (Get cts a) where
762 => HasDocs (Get cts a) where
766 docsFor Proxy (endpoint, action) DocOptions{..} =
763 docsFor Proxy (endpoint, action) DocOptions{..} =
767 single endpoint' action'
764 single endpoint' action'
@@ -776,7 +773,7 @@ instance
776#if MIN_VERSION_base(4,8,0)
773#if MIN_VERSION_base(4,8,0)
777 {-# OVERLAPPING #-}
774 {-# OVERLAPPING #-}
779− (ToSample a b, IsNonEmpty cts, AllMimeRender cts b, SupportedTypes cts
776+ (ToSample a, IsNonEmpty cts, AllMimeRender cts a, SupportedTypes cts
780 , AllHeaderSamples ls , GetHeaders (HList ls) )
777 , AllHeaderSamples ls , GetHeaders (HList ls) )
781 => HasDocs (Get cts (Headers ls a)) where
778 => HasDocs (Get cts (Headers ls a)) where
782 docsFor Proxy (endpoint, action) DocOptions{..} =
779 docsFor Proxy (endpoint, action) DocOptions{..} =
@@ -803,7 +800,7 @@ instance
803#if MIN_VERSION_base(4,8,0)
800#if MIN_VERSION_base(4,8,0)
804 {-# OVERLAPPABLE #-}
801 {-# OVERLAPPABLE #-}
806− (ToSample a b, IsNonEmpty cts, AllMimeRender cts b, SupportedTypes cts)
803+ (ToSample a, IsNonEmpty cts, AllMimeRender cts a, SupportedTypes cts)
807 => HasDocs (Post cts a) where
804 => HasDocs (Post cts a) where
808 docsFor Proxy (endpoint, action) DocOptions{..} =
805 docsFor Proxy (endpoint, action) DocOptions{..} =
809 single endpoint' action'
806 single endpoint' action'
@@ -819,7 +816,7 @@ instance
819#if MIN_VERSION_base(4,8,0)
816#if MIN_VERSION_base(4,8,0)
820 {-# OVERLAPPING #-}
817 {-# OVERLAPPING #-}
822− (ToSample a b, IsNonEmpty cts, AllMimeRender cts b, SupportedTypes cts
819+ (ToSample a, IsNonEmpty cts, AllMimeRender cts a, SupportedTypes cts
823 , AllHeaderSamples ls , GetHeaders (HList ls) )
820 , AllHeaderSamples ls , GetHeaders (HList ls) )
824 => HasDocs (Post cts (Headers ls a)) where
821 => HasDocs (Post cts (Headers ls a)) where
825 docsFor Proxy (endpoint, action) DocOptions{..} =
822 docsFor Proxy (endpoint, action) DocOptions{..} =
@@ -838,7 +835,7 @@ instance
838#if MIN_VERSION_base(4,8,0)
835#if MIN_VERSION_base(4,8,0)
839 {-# OVERLAPPABLE #-}
836 {-# OVERLAPPABLE #-}
841− (ToSample a b, IsNonEmpty cts, AllMimeRender cts b, SupportedTypes cts)
838+ (ToSample a, IsNonEmpty cts, AllMimeRender cts a, SupportedTypes cts)
842 => HasDocs (Put cts a) where
839 => HasDocs (Put cts a) where
843 docsFor Proxy (endpoint, action) DocOptions{..} =
840 docsFor Proxy (endpoint, action) DocOptions{..} =
844 single endpoint' action'
841 single endpoint' action'
@@ -854,7 +851,7 @@ instance
854#if MIN_VERSION_base(4,8,0)
851#if MIN_VERSION_base(4,8,0)
855 {-# OVERLAPPING #-}
852 {-# OVERLAPPING #-}
857− (ToSample a b, IsNonEmpty cts, AllMimeRender cts b, SupportedTypes cts
854+ (ToSample a, IsNonEmpty cts, AllMimeRender cts a, SupportedTypes cts
858 , AllHeaderSamples ls , GetHeaders (HList ls) )
855 , AllHeaderSamples ls , GetHeaders (HList ls) )
859 => HasDocs (Put cts (Headers ls a)) where
856 => HasDocs (Put cts (Headers ls a)) where
860 docsFor Proxy (endpoint, action) DocOptions{..} =
857 docsFor Proxy (endpoint, action) DocOptions{..} =
@@ -951,7 +948,7 @@ instance HasDocs Raw where
951-- example data. However, there's no reason to believe that the instances of
948-- example data. However, there's no reason to believe that the instances of
952-- 'AllMimeUnrender' and 'AllMimeRender' actually agree (or to suppose that
949-- 'AllMimeUnrender' and 'AllMimeRender' actually agree (or to suppose that
953-- both are even defined) for any particular type.
950-- both are even defined) for any particular type.
954−instance (ToSample a b, IsNonEmpty cts, AllMimeRender cts b, HasDocs sublayout
951+instance (ToSample a, IsNonEmpty cts, AllMimeRender cts a, HasDocs sublayout
955 , SupportedTypes cts)
952 , SupportedTypes cts)
956 => HasDocs (ReqBody cts a :> sublayout) where
953 => HasDocs (ReqBody cts a :> sublayout) where
@@ -990,32 +987,32 @@ instance HasDocs sublayout => HasDocs (Vault :> sublayout) where
990 docsFor (Proxy :: Proxy sublayout) ep
987 docsFor (Proxy :: Proxy sublayout) ep
992-- ToSample instances for simple types
989-- ToSample instances for simple types
993−instance ToSample () ()
990+instance ToSample ()
994−instance ToSample Bool Bool
991+instance ToSample Bool
995−instance ToSample Ordering Ordering
992+instance ToSample Ordering
997-- polymorphic ToSample instances
994-- polymorphic ToSample instances
998−instance (ToSample a a, ToSample b b) => ToSample (a, b) (a, b)
995+instance (ToSample a, ToSample b) => ToSample (a, b)
999−instance (ToSample a a, ToSample b b, ToSample c c) => ToSample (a, b, c) (a, b, c)
996+instance (ToSample a, ToSample b, ToSample c) => ToSample (a, b, c)
1000−instance (ToSample a a, ToSample b b, ToSample c c, ToSample d d) => ToSample (a, b, c, d) (a, b, c, d)
997+instance (ToSample a, ToSample b, ToSample c, ToSample d) => ToSample (a, b, c, d)
1001−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)
998+instance (ToSample a, ToSample b, ToSample c, ToSample d, ToSample e) => ToSample (a, b, c, d, e)
1002−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)
999+instance (ToSample a, ToSample b, ToSample c, ToSample d, ToSample e, ToSample f) => ToSample (a, b, c, d, e, f)
1003−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)
1000+instance (ToSample a, ToSample b, ToSample c, ToSample d, ToSample e, ToSample f, ToSample g) => ToSample (a, b, c, d, e, f, g)
1005−instance ToSample a a => ToSample (Maybe a) (Maybe a)
1002+instance ToSample a => ToSample (Maybe a)
1006−instance (ToSample a a, ToSample b b) => ToSample (Either a b) (Either a b)
1003+instance (ToSample a, ToSample b) => ToSample (Either a b)
1007−instance ToSample a a => ToSample [a] [a]
1004+instance ToSample a => ToSample [a]
1009-- ToSample instances for Control.Applicative types
1006-- ToSample instances for Control.Applicative types
1010−instance ToSample a a => ToSample (Const a b) (Const a b)
1007+instance ToSample a => ToSample (Const a b)
1011−instance ToSample a a => ToSample (ZipList a) (ZipList a)
1008+instance ToSample a => ToSample (ZipList a)
1013-- ToSample instances for Data.Monoid newtypes
1010-- ToSample instances for Data.Monoid newtypes
1014−instance ToSample All All
1011+instance ToSample All
1015−instance ToSample Any Any
1012+instance ToSample Any
1016−instance ToSample a a => ToSample (Sum a) (Sum a)
1013+instance ToSample a => ToSample (Sum a)
1017−instance ToSample a a => ToSample (Product a) (Product a)
1014+instance ToSample a => ToSample (Product a)
1018−instance ToSample a a => ToSample (First a) (First a)
1015+instance ToSample a => ToSample (First a)
1019−instance ToSample a a => ToSample (Last a) (Last a)
1016+instance ToSample a => ToSample (Last a)
1020−instance ToSample a a => ToSample (Dual a) (Dual a)
1017+instance ToSample a => ToSample (Dual a)