servant-rawm-client (empty) → 1.0.0.0
raw patch · 5 files changed
+169/−0 lines, 5 filesdep +basedep +servant-client-coredep +servant-rawm
Dependencies added: base, servant-client-core, servant-rawm
Files
- CHANGELOG.md +12/−0
- LICENSE +30/−0
- README.md +20/−0
- servant-rawm-client.cabal +43/−0
- src/Servant/RawM/Client.hs +64/−0
+ CHANGELOG.md view
@@ -0,0 +1,12 @@+## 1.0.0.0++* The implementations of the `RawM` endpoint are divided into+ `servant-rawm-client`, `servant-rawm-docs`, and `servant-rawm-server` to+ avoid introducing unnecessary dependencies and reduce the compilation+ overhead. You will need to add either of the implementations to your+ dependencies, and import the corresponding implementation+ (`Servant.RawM.Server`, `Servant.RawM.Client`, or `Servant.RawM.Docs`) for+ the `RawM` endpoint to function correctly.+ [#16](https://github.com/cdepillabout/servant-rawm/pull/16)+ Thanks [@Krasjet](https://github.com/Krasjet)!+
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Dennis Gosnell (c) 2017-2020++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Author name here nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,20 @@+# Servant.RawM.Client++[](http://travis-ci.org/cdepillabout/servant-rawm)+[](https://hackage.haskell.org/package/servant-rawm-client)+[](http://stackage.org/lts/package/servant-rawm-client)+[](http://stackage.org/nightly/package/servant-rawm-client)+++This is the client-side library for+[`servant-rawm`](https://github.com/cdepillabout/servant-rawm).++See the `servant-rawm`+[`README.md`](https://github.com/cdepillabout/servant-rawm) and+[Haddocks](side://hackage.haskell.org/package/servant-rawm)+for a short explanation of how to use this package.++After `servant-rawm` 1.0.0.0, the implementations of the `RawM` endpoint are+divided into `servant-rawm-client`, `servant-rawm-docs`, and+`servant-rawm-server` to avoid introducing unnecessary dependencies and reduce+the compilation overhead.
+ servant-rawm-client.cabal view
@@ -0,0 +1,43 @@+name: servant-rawm-client+version: 1.0.0.0+synopsis: The client implementation of servant-rawm.+description: Please see <https://github.com/cdepillabout/servant-rawm#readme README.md>.+homepage: https://github.com/cdepillabout/servant-rawm+license: BSD3+license-file: LICENSE+author: Dennis Gosnell+maintainer: cdep.illabout@gmail.com+ , nil.krjst@gmail.com+copyright: 2017 Dennis Gosnell+category: Servant+ , Web+build-type: Simple+extra-source-files: CHANGELOG.md+ , README.md+cabal-version: >=1.10++library+ hs-source-dirs: src+ exposed-modules: Servant.RawM.Client+ build-depends: base >= 4.8 && < 5+ , servant-rawm+ , servant-client-core >= 0.16+ default-language: Haskell2010+ ghc-options: -Wall -fwarn-incomplete-uni-patterns -fwarn-incomplete-record-updates -fwarn-monomorphism-restriction++-- TODO: These doctests need to be moved to cabal-doctest, since just using+-- doctest directly is not reliable.+-- test-suite servant-rawm-client-doctest+-- type: exitcode-stdio-1.0+-- main-is: DocTest.hs+-- hs-source-dirs: test+-- build-depends: base+-- , doctest+-- , Glob+-- , servant-client-core+-- default-language: Haskell2010+-- ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N++source-repository head+ type: git+ location: git@github.com:cdepillabout/servant-rawm.git
+ src/Servant/RawM/Client.hs view
@@ -0,0 +1,64 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE InstanceSigs #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE TypeFamilies #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}++{- |+Module : Servant.RawM.Client++Copyright : Dennis Gosnell 2017+License : BSD3++Maintainer : Dennis Gosnell (cdep.illabout@gmail.com)+ Krasjet (nil.krjst@gmail.com)+Stability : experimental+Portability : unknown++This module exports a 'HasClient' instance for 'RawM', which provides the+client implementation for the 'RawM' endpoint.+-}++module Servant.RawM.Client (+ -- * Reexport RawM API+ module Servant.RawM+) where++import Data.Proxy (Proxy (Proxy))+import Servant.Client.Core (Client,+ HasClient (clientWithRoute, hoistClientMonad),+ Request, Response, RunClient, runRequest)+import Servant.RawM++-- | Creates a client route like the following:+--+-- >>> :set -XTypeOperators+-- >>> import Data.Type.Equality ((:~:)(Refl))+-- >>> Refl :: Client m (RawM' a) :~: ((Request -> Request) -> m Response)+-- Refl+--+-- This allows modification of the underlying 'Request' to work for any sort of+-- 'Network.Wai.Application'.+--+-- Check out the+-- <https://github.com/cdepillabout/servant-rawm/tree/master/example example> in+-- the source code repository that shows a more in-depth server, client, and+-- documentation.+instance RunClient m => HasClient m (RawM' serverType) where+ type Client m (RawM' serverType) = (Request -> Request) -> m Response++ clientWithRoute+ :: Proxy m+ -> Proxy (RawM' serverType)+ -> Request+ -> Client m (RawM' serverType)+ clientWithRoute Proxy Proxy req reqFunc = runRequest $ reqFunc req++ hoistClientMonad+ :: Proxy m+ -> Proxy (RawM' serverType)+ -> (forall x. mon x -> mon' x)+ -> Client mon (RawM' serverType)+ -> Client mon' (RawM' serverType)+ hoistClientMonad Proxy Proxy f cl = f . cl