@@ -27,7 +27,6 @@ import Control.Arrow
27import Control.Lens
27import Control.Lens
28 (makeLenses, mapped, over, traversed, view, (%~), (&), (.~),
28 (makeLenses, mapped, over, traversed, view, (%~), (&), (.~),
29 (<>~), (^.), (|>))
29 (<>~), (^.), (|>))
30−import qualified Control.Monad.Omega as Omega
31import qualified Data.ByteString.Char8 as BSC
30import qualified Data.ByteString.Char8 as BSC
32import Data.ByteString.Lazy.Char8
31import Data.ByteString.Lazy.Char8
33 (ByteString)
32 (ByteString)
@@ -65,6 +64,8 @@ import Servant.API
65import Servant.API.ContentTypes
64import Servant.API.ContentTypes
66import Servant.API.TypeLevel
65import Servant.API.TypeLevel
67+import qualified Data.Universe.Helpers as U
68import qualified Data.HashMap.Strict as HM
69import qualified Data.HashMap.Strict as HM
69import qualified Data.Text as T
70import qualified Data.Text as T
70import qualified Network.HTTP.Media as M
71import qualified Network.HTTP.Media as M
@@ -479,22 +480,22 @@ samples = map ("",)
480-- | Default sample Generic-based inputs/outputs.
481-- | Default sample Generic-based inputs/outputs.
481defaultSamples :: forall a. (Generic a, GToSample (Rep a)) => Proxy a -> [(Text, a)]
482defaultSamples :: forall a. (Generic a, GToSample (Rep a)) => Proxy a -> [(Text, a)]
482−defaultSamples _ = Omega.runOmega $ second to <$> gtoSamples (Proxy :: Proxy (Rep a))
483+defaultSamples _ = second to <$> gtoSamples (Proxy :: Proxy (Rep a))
484-- | @'ToSample'@ for Generics.
485-- | @'ToSample'@ for Generics.
486−-- The use of @'Omega'@ allows for more productive sample generation.
487+-- Note: we use combinators from "Universe.Data.Helpers" for more productive sample generation.
487class GToSample t where
488class GToSample t where
488− gtoSamples :: proxy t -> Omega.Omega (Text, t x)
489+ gtoSamples :: proxy t -> [(Text, t x)]
490instance GToSample U1 where
491instance GToSample U1 where
491− gtoSamples _ = Omega.each (singleSample U1)
492+ gtoSamples _ = singleSample U1
493instance GToSample V1 where
494instance GToSample V1 where
494 gtoSamples _ = empty
495 gtoSamples _ = empty
496instance (GToSample p, GToSample q) => GToSample (p :*: q) where
497instance (GToSample p, GToSample q) => GToSample (p :*: q) where
497− gtoSamples _ = render <$> ps <*> qs
498+ gtoSamples _ = U.cartesianProduct render ps qs
499 ps = gtoSamples (Proxy :: Proxy p)
500 ps = gtoSamples (Proxy :: Proxy p)
500 qs = gtoSamples (Proxy :: Proxy q)
501 qs = gtoSamples (Proxy :: Proxy q)
@@ -503,13 +504,13 @@ instance (GToSample p, GToSample q) => GToSample (p :*: q) where
503 | otherwise = (ta <> ", " <> tb, a :*: b)
504 | otherwise = (ta <> ", " <> tb, a :*: b)
505instance (GToSample p, GToSample q) => GToSample (p :+: q) where
506instance (GToSample p, GToSample q) => GToSample (p :+: q) where
506− gtoSamples _ = lefts <|> rights
507+ gtoSamples _ = lefts U.+++ rights
508 lefts = second L1 <$> gtoSamples (Proxy :: Proxy p)
509 lefts = second L1 <$> gtoSamples (Proxy :: Proxy p)
509 rights = second R1 <$> gtoSamples (Proxy :: Proxy q)
510 rights = second R1 <$> gtoSamples (Proxy :: Proxy q)
511instance ToSample a => GToSample (K1 i a) where
512instance ToSample a => GToSample (K1 i a) where
512− gtoSamples _ = second K1 <$> Omega.each (toSamples (Proxy :: Proxy a))
513+ gtoSamples _ = second K1 <$> toSamples (Proxy :: Proxy a)
514instance (GToSample f) => GToSample (M1 i a f) where
515instance (GToSample f) => GToSample (M1 i a f) where
515 gtoSamples _ = second M1 <$> gtoSamples (Proxy :: Proxy f)
516 gtoSamples _ = second M1 <$> gtoSamples (Proxy :: Proxy f)