on master help sign in
Add some missing comments in Servant.Docs.Internal
commit714e740098ba1cbdb4b9fad55173e27b410c9bec authorNickolay Kudasov <nickolay.kudasov@gmail.com> dateMon 21 Sep 2015, 11:58 (11 years ago) parent98af812
1 file changed+7−5
servant-docs/src/Servant/Docs/Internal.hs+7−5
servant-docs/src/Servant/Docs/Internal.hs+7−5
@@ -387,6 +387,7 @@ class ToSample a b | a -> b where
387387 default toSamples :: (Generic a, Generic b, GToSample (Rep a) (Rep b)) => Proxy a -> [(Text, b)]
388388 toSamples = defaultSamples
389389
390+-- | Sample input or output (if there is at least one).
390391toSample :: forall a b. ToSample a b => Proxy a -> Maybe b
391392toSample _ = snd <$> listToMaybe (toSamples (Proxy :: Proxy a))
392393
@@ -398,9 +399,13 @@ noSamples = empty
398399singleSample :: a -> [(Text, a)]
399400singleSample x = [("", x)]
400401
402+-- | Default sample Generic-based inputs/outputs.
401403defaultSamples :: forall a b. (Generic a, Generic b, GToSample (Rep a) (Rep b)) => Proxy a -> [(Text, b)]
402404defaultSamples _ = Omega.runOmega $ second to <$> gtoSamples (Proxy :: Proxy (Rep a))
403405
406+-- | @'ToSample'@ for Generics.
407+--
408+-- The use of @'Omega'@ allows for more productive sample generation.
404409class GToSample t s where
405410 gtoSamples :: proxy t -> Omega.Omega (Text, s x)
406411
@@ -959,14 +964,12 @@ instance HasDocs sublayout => HasDocs (Vault :> sublayout) where
959964 docsFor Proxy ep =
960965 docsFor (Proxy :: Proxy sublayout) ep
961966
962−-- 'ToSample' instances for simple types
963−
967+-- ToSample instances for simple types
964968instance ToSample () ()
965969instance ToSample Bool Bool
966970instance ToSample Ordering Ordering
967971
968−-- polymorphic 'ToSample' instances
969−
972+-- polymorphic ToSample instances
970973instance (ToSample a a, ToSample b b) => ToSample (a, b) (a, b)
971974instance (ToSample a a, ToSample b b, ToSample c c) => ToSample (a, b, c) (a, b, c)
972975instance (ToSample a a, ToSample b b, ToSample c c, ToSample d d) => ToSample (a, b, c, d) (a, b, c, d)
@@ -977,4 +980,3 @@ instance (ToSample a a, ToSample b b, ToSample c c, ToSample d d, ToSample e e,
977980instance ToSample a a => ToSample (Maybe a) (Maybe a)
978981instance (ToSample a a, ToSample b b) => ToSample (Either a b) (Either a b)
979982instance ToSample a a => ToSample [a] [a]
980−