From 7e0ad51b621e365473975cc06d3d987b6ed2e071 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Wed, 17 Jan 2018 03:19:14 -0800 Subject: [PATCH] Use (a :: *) on phantom type variables for kinder type checking #887 --- servant/src/Servant/API/Capture.hs | 4 ++-- servant/src/Servant/API/QueryParam.hs | 4 ++-- servant/src/Servant/API/ReqBody.hs | 2 +- servant/src/Servant/API/Stream.hs | 2 +- servant/src/Servant/API/Sub.hs | 2 +- servant/src/Servant/API/Verbs.hs | 2 +- servant/test/Servant/Utils/LinksSpec.hs | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/servant/src/Servant/API/Capture.hs b/servant/src/Servant/API/Capture.hs index 7ee7972a..3db3cdd8 100644 --- a/servant/src/Servant/API/Capture.hs +++ b/servant/src/Servant/API/Capture.hs @@ -12,7 +12,7 @@ import GHC.TypeLits (Symbol) -- -- >>> -- GET /books/:isbn -- >>> type MyApi = "books" :> Capture "isbn" Text :> Get '[JSON] Book -data Capture (sym :: Symbol) a +data Capture (sym :: Symbol) (a :: *) deriving (Typeable) @@ -23,7 +23,7 @@ data Capture (sym :: Symbol) a -- -- >>> -- GET /src/* -- >>> type MyAPI = "src" :> CaptureAll "segments" Text :> Get '[JSON] SourceFile -data CaptureAll (sym :: Symbol) a +data CaptureAll (sym :: Symbol) (a :: *) deriving (Typeable) -- $setup diff --git a/servant/src/Servant/API/QueryParam.hs b/servant/src/Servant/API/QueryParam.hs index ca913e17..c05e9206 100644 --- a/servant/src/Servant/API/QueryParam.hs +++ b/servant/src/Servant/API/QueryParam.hs @@ -14,7 +14,7 @@ import GHC.TypeLits (Symbol) -- -- >>> -- /books?author= -- >>> type MyApi = "books" :> QueryParam "author" Text :> Get '[JSON] [Book] -data QueryParam (sym :: Symbol) a +data QueryParam (sym :: Symbol) (a :: *) deriving Typeable -- | Lookup the values associated to the @sym@ query string parameter @@ -28,7 +28,7 @@ data QueryParam (sym :: Symbol) a -- -- >>> -- /books?authors[]=&authors[]=&... -- >>> type MyApi = "books" :> QueryParams "authors" Text :> Get '[JSON] [Book] -data QueryParams (sym :: Symbol) a +data QueryParams (sym :: Symbol) (a :: *) deriving Typeable -- | Lookup a potentially value-less query string parameter diff --git a/servant/src/Servant/API/ReqBody.hs b/servant/src/Servant/API/ReqBody.hs index abfec02b..36393601 100644 --- a/servant/src/Servant/API/ReqBody.hs +++ b/servant/src/Servant/API/ReqBody.hs @@ -11,7 +11,7 @@ import Data.Typeable (Typeable) -- -- >>> -- POST /books -- >>> type MyApi = "books" :> ReqBody '[JSON] Book :> Post '[JSON] Book -data ReqBody (contentTypes :: [*]) a +data ReqBody (contentTypes :: [*]) (a :: *) deriving (Typeable) -- $setup diff --git a/servant/src/Servant/API/Stream.hs b/servant/src/Servant/API/Stream.hs index 073e0ce1..bb971c4f 100644 --- a/servant/src/Servant/API/Stream.hs +++ b/servant/src/Servant/API/Stream.hs @@ -23,7 +23,7 @@ import Control.Arrow (first) import Network.HTTP.Types.Method (StdMethod (..)) -- | A Stream endpoint for a given method emits a stream of encoded values at a given Content-Type, delimited by a framing strategy. Steam endpoints always return response code 200 on success. Type synonyms are provided for standard methods. -data Stream (method :: k1) (framing :: *) (contentType :: *) a +data Stream (method :: k1) (framing :: *) (contentType :: *) (a :: *) deriving (Typeable, Generic) type StreamGet = Stream 'GET diff --git a/servant/src/Servant/API/Sub.hs b/servant/src/Servant/API/Sub.hs index 152293e4..45beac46 100644 --- a/servant/src/Servant/API/Sub.hs +++ b/servant/src/Servant/API/Sub.hs @@ -14,7 +14,7 @@ import Data.Typeable (Typeable) -- >>> -- GET /hello/world -- >>> -- returning a JSON encoded World value -- >>> type MyApi = "hello" :> "world" :> Get '[JSON] World -data (path :: k) :> a +data (path :: k) :> (a :: *) deriving (Typeable) infixr 4 :> diff --git a/servant/src/Servant/API/Verbs.hs b/servant/src/Servant/API/Verbs.hs index 1b898ea6..d1e1d6eb 100644 --- a/servant/src/Servant/API/Verbs.hs +++ b/servant/src/Servant/API/Verbs.hs @@ -23,7 +23,7 @@ import Network.HTTP.Types.Method (Method, StdMethod (..), -- provided, but you are free to define your own: -- -- >>> type Post204 contentTypes a = Verb 'POST 204 contentTypes a -data Verb (method :: k1) (statusCode :: Nat) (contentTypes :: [*]) a +data Verb (method :: k1) (statusCode :: Nat) (contentTypes :: [*]) (a :: *) deriving (Typeable, Generic) -- * 200 responses diff --git a/servant/test/Servant/Utils/LinksSpec.hs b/servant/test/Servant/Utils/LinksSpec.hs index 29f3c1df..7215c0b7 100644 --- a/servant/test/Servant/Utils/LinksSpec.hs +++ b/servant/test/Servant/Utils/LinksSpec.hs @@ -24,7 +24,7 @@ type TestApi = -- All of the verbs :<|> "get" :> Get '[JSON] NoContent :<|> "put" :> Put '[JSON] NoContent - :<|> "post" :> ReqBody '[JSON] 'True :> Post '[JSON] NoContent + :<|> "post" :> ReqBody '[JSON] Bool :> Post '[JSON] NoContent :<|> "delete" :> Header "ponies" String :> Delete '[JSON] NoContent :<|> "raw" :> Raw :<|> NoEndpoint @@ -124,6 +124,6 @@ type WrongPath = "getTypo" :> Get '[JSON] NoContent type WrongReturnType = "get" :> Get '[JSON] Bool type WrongContentType = "get" :> Get '[OctetStream] NoContent type WrongMethod = "get" :> Post '[JSON] NoContent -type NotALink = "hello" :> ReqBody '[JSON] 'True :> Get '[JSON] Bool +type NotALink = "hello" :> ReqBody '[JSON] Bool :> Get '[JSON] Bool type AllGood = "get" :> Get '[JSON] NoContent type NoEndpoint = "empty" :> EmptyAPI