From 165022a5548b02f4de937cf5f6ae773ca1cf3127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Hahn?= Date: Fri, 7 Nov 2014 18:57:41 +0800 Subject: [PATCH] module refactoring: putting some things in Servant.Common --- example/greet.hs | 2 +- servant.cabal | 6 +++--- src/Servant.hs | 8 ++++---- src/Servant/API/Capture.hs | 4 ++-- src/Servant/API/Delete.hs | 4 ++-- src/Servant/API/Get.hs | 4 ++-- src/Servant/API/Post.hs | 4 ++-- src/Servant/API/Put.hs | 4 ++-- src/Servant/API/QueryParam.hs | 4 ++-- src/Servant/API/ReqBody.hs | 2 +- src/Servant/API/Sub.hs | 2 +- src/Servant/Client.hs | 2 +- src/Servant/{Utils => Common}/BaseUrl.hs | 2 +- src/Servant/{Utils => Common}/Req.hs | 4 ++-- src/Servant/{Utils => Common}/Text.hs | 2 +- test/Servant/ClientSpec.hs | 2 +- test/Servant/{Client => Common}/BaseUrlSpec.hs | 4 ++-- 17 files changed, 30 insertions(+), 30 deletions(-) rename src/Servant/{Utils => Common}/BaseUrl.hs (97%) rename src/Servant/{Utils => Common}/Req.hs (98%) rename src/Servant/{Utils => Common}/Text.hs (98%) rename test/Servant/{Client => Common}/BaseUrlSpec.hs (96%) diff --git a/example/greet.hs b/example/greet.hs index 09a95abc..c2c9976f 100644 --- a/example/greet.hs +++ b/example/greet.hs @@ -22,7 +22,7 @@ import Servant.API import Servant.Client import Servant.Docs import Servant.Server -import Servant.Utils.BaseUrl +import Servant.Common.BaseUrl -- * Example diff --git a/servant.cabal b/servant.cabal index aaf2ee91..abab45c2 100644 --- a/servant.cabal +++ b/servant.cabal @@ -26,13 +26,13 @@ library Servant.API.ReqBody Servant.API.Sub Servant.Client + Servant.Common.BaseUrl + Servant.Common.Req + Servant.Common.Text Servant.Docs Servant.Server Servant.Utils.ApiQuasiQuoting - Servant.Utils.BaseUrl Servant.Utils.Links - Servant.Utils.Req - Servant.Utils.Text build-depends: base >=4.7 && <5 , either diff --git a/src/Servant.hs b/src/Servant.hs index cc614531..f4c5b6c6 100644 --- a/src/Servant.hs +++ b/src/Servant.hs @@ -7,16 +7,16 @@ module Servant ( module Servant.Server, -- | For accessing servant APIs as API clients. module Servant.Client, - module Servant.Utils.BaseUrl, + module Servant.Common.BaseUrl, -- | For generating documentation for servant APIs. module Servant.Docs, -- | Helper module - module Servant.Utils.Text, + module Servant.Common.Text, ) where import Servant.API import Servant.Client +import Servant.Common.BaseUrl +import Servant.Common.Text import Servant.Docs import Servant.Server -import Servant.Utils.BaseUrl -import Servant.Utils.Text diff --git a/src/Servant/API/Capture.hs b/src/Servant/API/Capture.hs index a0cc17fd..2c694985 100644 --- a/src/Servant/API/Capture.hs +++ b/src/Servant/API/Capture.hs @@ -12,10 +12,10 @@ import GHC.TypeLits import Network.Wai import Servant.API.Sub import Servant.Client +import Servant.Common.Req +import Servant.Common.Text import Servant.Docs import Servant.Server -import Servant.Utils.Req -import Servant.Utils.Text -- * Captures data Capture sym a diff --git a/src/Servant/API/Delete.hs b/src/Servant/API/Delete.hs index c5c26587..80b78e44 100644 --- a/src/Servant/API/Delete.hs +++ b/src/Servant/API/Delete.hs @@ -11,10 +11,10 @@ import Data.Typeable import Network.HTTP.Types import Network.Wai import Servant.Client +import Servant.Common.BaseUrl +import Servant.Common.Req import Servant.Docs import Servant.Server -import Servant.Utils.BaseUrl -import Servant.Utils.Req -- | Endpoint for DELETE requests. data Delete diff --git a/src/Servant/API/Get.hs b/src/Servant/API/Get.hs index 383f4522..4114b07e 100644 --- a/src/Servant/API/Get.hs +++ b/src/Servant/API/Get.hs @@ -12,10 +12,10 @@ import Data.Typeable import Network.HTTP.Types import Network.Wai import Servant.Client +import Servant.Common.BaseUrl +import Servant.Common.Req import Servant.Docs import Servant.Server -import Servant.Utils.BaseUrl -import Servant.Utils.Req -- | Endpoint for simple GET requests. The server doesn't receive any arguments -- and serves the contained type as JSON. diff --git a/src/Servant/API/Post.hs b/src/Servant/API/Post.hs index 08effb53..d8909e5b 100644 --- a/src/Servant/API/Post.hs +++ b/src/Servant/API/Post.hs @@ -12,10 +12,10 @@ import Data.Typeable import Network.HTTP.Types import Network.Wai import Servant.Client +import Servant.Common.BaseUrl +import Servant.Common.Req import Servant.Docs import Servant.Server -import Servant.Utils.BaseUrl -import Servant.Utils.Req -- | Endpoint for POST requests. The type variable represents the type of the -- response body (not the request body, use 'Servant.API.RQBody.RQBody' for diff --git a/src/Servant/API/Put.hs b/src/Servant/API/Put.hs index 2a5fe485..012debe2 100644 --- a/src/Servant/API/Put.hs +++ b/src/Servant/API/Put.hs @@ -12,10 +12,10 @@ import Data.Typeable import Network.HTTP.Types import Network.Wai import Servant.Client +import Servant.Common.BaseUrl +import Servant.Common.Req import Servant.Docs import Servant.Server -import Servant.Utils.BaseUrl -import Servant.Utils.Req -- | Endpoint for PUT requests. data Put a diff --git a/src/Servant/API/QueryParam.hs b/src/Servant/API/QueryParam.hs index f4a6882b..965cd489 100644 --- a/src/Servant/API/QueryParam.hs +++ b/src/Servant/API/QueryParam.hs @@ -16,10 +16,10 @@ import Network.HTTP.Types import Network.Wai import Servant.API.Sub import Servant.Client +import Servant.Common.Req +import Servant.Common.Text import Servant.Docs import Servant.Server -import Servant.Utils.Req -import Servant.Utils.Text -- * Single query string parameter lookup diff --git a/src/Servant/API/ReqBody.hs b/src/Servant/API/ReqBody.hs index b63152ab..b185b675 100644 --- a/src/Servant/API/ReqBody.hs +++ b/src/Servant/API/ReqBody.hs @@ -11,9 +11,9 @@ import Data.Proxy import Network.Wai import Servant.API.Sub import Servant.Client +import Servant.Common.Req import Servant.Docs import Servant.Server -import Servant.Utils.Req -- * Request Body support data ReqBody a diff --git a/src/Servant/API/Sub.hs b/src/Servant/API/Sub.hs index 581c5fdf..c3eb68a4 100644 --- a/src/Servant/API/Sub.hs +++ b/src/Servant/API/Sub.hs @@ -9,9 +9,9 @@ import Data.String.Conversions import GHC.TypeLits import Network.Wai import Servant.Client +import Servant.Common.Req import Servant.Docs import Servant.Server -import Servant.Utils.Req -- | The contained API (second argument) can be found under @("/" ++ path)@ -- (path being the first argument). diff --git a/src/Servant/Client.hs b/src/Servant/Client.hs index a1a912c1..599a77cc 100644 --- a/src/Servant/Client.hs +++ b/src/Servant/Client.hs @@ -4,7 +4,7 @@ module Servant.Client where import Data.Proxy -import Servant.Utils.Req +import Servant.Common.Req -- * Accessing APIs as a Client diff --git a/src/Servant/Utils/BaseUrl.hs b/src/Servant/Common/BaseUrl.hs similarity index 97% rename from src/Servant/Utils/BaseUrl.hs rename to src/Servant/Common/BaseUrl.hs index 200e00f3..8740303c 100644 --- a/src/Servant/Utils/BaseUrl.hs +++ b/src/Servant/Common/BaseUrl.hs @@ -1,6 +1,6 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE ViewPatterns #-} -module Servant.Utils.BaseUrl where +module Servant.Common.BaseUrl where import Data.List import GHC.Generics diff --git a/src/Servant/Utils/Req.hs b/src/Servant/Common/Req.hs similarity index 98% rename from src/Servant/Utils/Req.hs rename to src/Servant/Common/Req.hs index 8b24880c..bff9c393 100644 --- a/src/Servant/Utils/Req.hs +++ b/src/Servant/Common/Req.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} -module Servant.Utils.Req where +module Servant.Common.Req where import Control.Applicative import Control.Concurrent @@ -19,7 +19,7 @@ import Data.Text import Network.HTTP.Client import Network.HTTP.Types import Network.URI -import Servant.Utils.BaseUrl +import Servant.Common.BaseUrl import System.IO.Unsafe import qualified Network.HTTP.Client as Client diff --git a/src/Servant/Utils/Text.hs b/src/Servant/Common/Text.hs similarity index 98% rename from src/Servant/Utils/Text.hs rename to src/Servant/Common/Text.hs index 907eb0a3..a26de651 100644 --- a/src/Servant/Utils/Text.hs +++ b/src/Servant/Common/Text.hs @@ -1,7 +1,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TypeSynonymInstances #-} -module Servant.Utils.Text where +module Servant.Common.Text where import Data.String.Conversions import Data.Int diff --git a/test/Servant/ClientSpec.hs b/test/Servant/ClientSpec.hs index fbd034d6..2744b6ed 100644 --- a/test/Servant/ClientSpec.hs +++ b/test/Servant/ClientSpec.hs @@ -22,7 +22,7 @@ import Test.QuickCheck import Servant.API import Servant.Client import Servant.Server -import Servant.Utils.BaseUrl +import Servant.Common.BaseUrl import Servant.ServerSpec diff --git a/test/Servant/Client/BaseUrlSpec.hs b/test/Servant/Common/BaseUrlSpec.hs similarity index 96% rename from test/Servant/Client/BaseUrlSpec.hs rename to test/Servant/Common/BaseUrlSpec.hs index d8773084..5eef61dc 100644 --- a/test/Servant/Client/BaseUrlSpec.hs +++ b/test/Servant/Common/BaseUrlSpec.hs @@ -1,12 +1,12 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} -module Servant.Client.BaseUrlSpec where +module Servant.Common.BaseUrlSpec where import Control.Applicative import Control.DeepSeq import Test.Hspec import Test.QuickCheck -import Servant.Utils.BaseUrl +import Servant.Common.BaseUrl spec :: Spec spec = do