-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Derive a mock server for free from your servant API types
--   
--   Derive a mock server for free from your servant API types
--   
--   See the <tt>Servant.Mock</tt> module for the documentation and an
--   example.
@package servant-mock
@version 0.8.4


-- | Automatically derive a mock webserver that implements some API type,
--   just from the said API type's definition.
--   
--   Using this module couldn't be simpler. Given some API type, like:
--   
--   <pre>
--   type API = "user" :&gt; Get '[JSON] User
--   </pre>
--   
--   that describes your web application, all you have to do is define a
--   <a>Proxy</a> to it:
--   
--   <pre>
--   myAPI :: Proxy API
--   myAPI = Proxy
--   </pre>
--   
--   and call <a>mock</a>, which has the following type:
--   
--   <pre>
--   <a>mock</a> :: <a>HasMock</a> api context =&gt; <a>Proxy</a> api -&gt; <a>Proxy</a> context -&gt; <a>Server</a> api
--   </pre>
--   
--   What this says is, given some API type <tt>api</tt> that it knows it
--   can "mock", <a>mock</a> hands you an implementation of the API type.
--   It does so by having each request handler generate a random value of
--   the appropriate type (<tt>User</tt> in our case). All you need for
--   this to work is to provide <a>Arbitrary</a> instances for the data
--   types returned as response bodies, hence appearing next to
--   <a>Delete</a>, <a>Get</a>, <a>Patch</a>, <a>Post</a> and <a>Put</a>.
--   
--   To put this all to work and run the mock server, just call
--   <a>serve</a> on the result of <a>mock</a> to get an <a>Application</a>
--   that you can then run with warp.
--   
--   <pre>
--   main :: IO ()
--   main = Network.Wai.Handler.Warp.run 8080 $
--     <a>serve</a> myAPI (<a>mock</a> myAPI Proxy)
--   </pre>
module Servant.Mock

-- | <a>HasMock</a> defines an interpretation of API types than turns them
--   into random-response-generating request handlers, hence providing an
--   instance for all the combinators of the core <i>servant</i> library.
class HasServer api context => HasMock api context

-- | Calling this method creates request handlers of the right type to
--   implement the API described by <tt>api</tt> that just generate random
--   response values of the right type. E.g:
--   
--   <pre>
--   type API = "user" :&gt; Get '[JSON] User
--         :<a>|</a> "book" :&gt; Get '[JSON] Book
--   
--   api :: Proxy API
--   api = Proxy
--   
--   -- let's say we will start with the frontend,
--   -- and hence need a placeholder server
--   server :: Server API
--   server = mock api Proxy
--   
--   </pre>
--   
--   What happens here is that <tt><a>Server</a> API</tt> actually "means"
--   2 request handlers, of the following types:
--   
--   <pre>
--   getUser :: Handler User
--   getBook :: Handler Book
--   
--   </pre>
--   
--   So under the hood, <a>mock</a> uses the <a>IO</a> bit to generate
--   random values of type <tt>User</tt> and <tt>Book</tt> every time these
--   endpoints are requested.
mock :: HasMock api context => Proxy api -> Proxy context -> Server api
instance (Servant.Mock.HasMock a context, Servant.Mock.HasMock b context) => Servant.Mock.HasMock (a Servant.API.Alternative.:<|> b) context
instance (GHC.TypeLits.KnownSymbol path, Servant.Mock.HasMock rest context) => Servant.Mock.HasMock (path Servant.API.Sub.:> rest) context
instance (GHC.TypeLits.KnownSymbol s, Web.Internal.HttpApiData.FromHttpApiData a, Servant.Mock.HasMock rest context) => Servant.Mock.HasMock (Servant.API.Capture.Capture' mods s a Servant.API.Sub.:> rest) context
instance (GHC.TypeLits.KnownSymbol s, Web.Internal.HttpApiData.FromHttpApiData a, Servant.Mock.HasMock rest context) => Servant.Mock.HasMock (Servant.API.Capture.CaptureAll s a Servant.API.Sub.:> rest) context
instance (Servant.API.ContentTypes.AllCTUnrender ctypes a, Servant.Mock.HasMock rest context, Data.Singletons.Bool.SBoolI (Servant.API.Modifiers.FoldLenient mods)) => Servant.Mock.HasMock (Servant.API.ReqBody.ReqBody' mods ctypes a Servant.API.Sub.:> rest) context
instance Servant.Mock.HasMock rest context => Servant.Mock.HasMock (Servant.API.RemoteHost.RemoteHost Servant.API.Sub.:> rest) context
instance Servant.Mock.HasMock rest context => Servant.Mock.HasMock (Servant.API.IsSecure.IsSecure Servant.API.Sub.:> rest) context
instance Servant.Mock.HasMock rest context => Servant.Mock.HasMock (Data.Vault.Lazy.Vault Servant.API.Sub.:> rest) context
instance Servant.Mock.HasMock rest context => Servant.Mock.HasMock (Network.HTTP.Types.Version.HttpVersion Servant.API.Sub.:> rest) context
instance (GHC.TypeLits.KnownSymbol s, Web.Internal.HttpApiData.FromHttpApiData a, Servant.Mock.HasMock rest context, Data.Singletons.Bool.SBoolI (Servant.API.Modifiers.FoldRequired mods), Data.Singletons.Bool.SBoolI (Servant.API.Modifiers.FoldLenient mods)) => Servant.Mock.HasMock (Servant.API.QueryParam.QueryParam' mods s a Servant.API.Sub.:> rest) context
instance (GHC.TypeLits.KnownSymbol s, Web.Internal.HttpApiData.FromHttpApiData a, Servant.Mock.HasMock rest context) => Servant.Mock.HasMock (Servant.API.QueryParam.QueryParams s a Servant.API.Sub.:> rest) context
instance (GHC.TypeLits.KnownSymbol s, Servant.Mock.HasMock rest context) => Servant.Mock.HasMock (Servant.API.QueryParam.QueryFlag s Servant.API.Sub.:> rest) context
instance (GHC.TypeLits.KnownSymbol h, Web.Internal.HttpApiData.FromHttpApiData a, Servant.Mock.HasMock rest context, Data.Singletons.Bool.SBoolI (Servant.API.Modifiers.FoldRequired mods), Data.Singletons.Bool.SBoolI (Servant.API.Modifiers.FoldLenient mods)) => Servant.Mock.HasMock (Servant.API.Header.Header' mods h a Servant.API.Sub.:> rest) context
instance forall k1 a (status :: GHC.Types.Nat) (method :: k1) (ctypes :: [*]) (context :: [*]). (Test.QuickCheck.Arbitrary.Arbitrary a, GHC.TypeNats.KnownNat status, Servant.API.Verbs.ReflectMethod method, Servant.API.ContentTypes.AllCTRender ctypes a) => Servant.Mock.HasMock (Servant.API.Verbs.Verb method status ctypes a) context
instance forall k1 (headerTypes :: [*]) a (status :: GHC.Types.Nat) (method :: k1) (ctypes :: [*]) (context :: [*]). (Servant.API.ResponseHeaders.GetHeaders (Servant.API.ResponseHeaders.Headers headerTypes a), Test.QuickCheck.Arbitrary.Arbitrary (Servant.API.ResponseHeaders.HList headerTypes), Test.QuickCheck.Arbitrary.Arbitrary a, GHC.TypeNats.KnownNat status, Servant.API.Verbs.ReflectMethod method, Servant.API.ContentTypes.AllCTRender ctypes a) => Servant.Mock.HasMock (Servant.API.Verbs.Verb method status ctypes (Servant.API.ResponseHeaders.Headers headerTypes a)) context
instance Servant.Mock.HasMock Servant.API.Raw.Raw context
instance Servant.Mock.HasMock Servant.API.Empty.EmptyAPI context
instance Servant.Mock.HasMock api context => Servant.Mock.HasMock (Servant.API.Description.Summary d Servant.API.Sub.:> api) context
instance Servant.Mock.HasMock api context => Servant.Mock.HasMock (Servant.API.Description.Description d Servant.API.Sub.:> api) context
instance (Servant.Server.Internal.Context.HasContextEntry context (Servant.Server.Internal.Context.NamedContext name subContext), Servant.Mock.HasMock rest subContext) => Servant.Mock.HasMock (Servant.API.WithNamedContext.WithNamedContext name subContext rest) context
instance (Test.QuickCheck.Arbitrary.Arbitrary (Servant.API.ResponseHeaders.HList ls), Test.QuickCheck.Arbitrary.Arbitrary a) => Test.QuickCheck.Arbitrary.Arbitrary (Servant.API.ResponseHeaders.Headers ls a)
instance Test.QuickCheck.Arbitrary.Arbitrary (Servant.API.ResponseHeaders.HList '[])
instance (Test.QuickCheck.Arbitrary.Arbitrary a, Test.QuickCheck.Arbitrary.Arbitrary (Servant.API.ResponseHeaders.HList hs)) => Test.QuickCheck.Arbitrary.Arbitrary (Servant.API.ResponseHeaders.HList (Servant.API.Header.Header h a : hs))
instance Test.QuickCheck.Arbitrary.Arbitrary Servant.API.ContentTypes.NoContent
