git.iko.soy/typeable/servant
on master help sign in
ReqBody content types.

And general cleanup.

commita1e1de91a9bc9a391c81f25cf1a379511254ebb6 authorJulian K. Arni <jkarni@gmail.com> dateTue 13 Jan 2015, 20:38 (12 years ago) parent98e02ea
8 files changed+34−15
servant.cabal+16−3 src/Servant/API.hs+2−1 src/Servant/API/ContentTypes.hs+1 src/Servant/API/Raw.hs+3−1 src/Servant/API/ReqBody.hs+3−2 src/Servant/QQ.hs+2−2 src/Servant/Utils/Links.hs+5−3 test/Servant/Utils/LinksSpec.hs+2−3
servant.cabal+16−3
@@ -47,13 +47,26 @@ library
4747 base >=4.7 && <5
4848 , bytestring == 0.10.*
4949 , http-types == 0.8.*
50− , text >= 1
51− , template-haskell
50+ , text >= 1 && < 2
51+ , template-haskell >= 2.7 && < 2.10
5252 , parsec >= 3.1
53− , string-conversions >= 0.3
53+ , string-conversions >= 0.3 && < 0.4
5454 , network-uri >= 2.6
5555 hs-source-dirs: src
5656 default-language: Haskell2010
57+ extensions: DataKinds
58+ , DeriveDataTypeable
59+ , FunctionalDependencies
60+ , KindSignatures
61+ , MultiParamTypeClasses
62+ , PolyKinds
63+ , QuasiQuotes
64+ , ScopedTypeVariables
65+ , TemplateHaskell
66+ , TypeFamilies
67+ , TypeOperators
68+ , UndecidableInstances
69+ , FlexibleInstances
5770 ghc-options: -Wall
5871
5972test-suite spec
src/Servant/API.hs+2−1
@@ -46,7 +46,8 @@ module Servant.API (
4646
4747import Servant.API.Alternative ( (:<|>)(..) )
4848import Servant.API.Capture ( Capture )
49−import Servant.API.ContentTypes ( HTML, XML, JSON, JavaScript, CSS, PlainText )
49+import Servant.API.ContentTypes ( HTML, XML, JSON, JavaScript, CSS
50+ , PlainText, OctetStream )
5051import Servant.API.Delete ( Delete )
5152import Servant.API.Get ( Get )
5253import Servant.API.Header ( Header )
src/Servant/API/ContentTypes.hs+1
@@ -10,3 +10,4 @@ data JSON deriving Typeable
1010data JavaScript deriving Typeable
1111data CSS deriving Typeable
1212data PlainText deriving Typeable
13+data OctetStream deriving Typeable
src/Servant/API/Raw.hs+3−1
@@ -1,5 +1,7 @@
1+{-# LANGUAGE DeriveDataTypeable #-}
12module Servant.API.Raw where
23
4+import Data.Typeable (Typeable)
35-- | Endpoint for plugging in your own Wai 'Application's.
46--
57-- The given 'Application' will get the request as received by the server, potentially with
@@ -9,4 +11,4 @@ module Servant.API.Raw where
911-- this can also be used with 'Servant.Utils.StaticFiles.serveDirectory' to serve
1012-- static files stored in a particular directory on your filesystem, or to serve
1113-- your API's documentation with 'Servant.Utils.StaticFiles.serveDocumentation'.
12−data Raw
14+data Raw deriving Typeable
src/Servant/API/ReqBody.hs+3−2
@@ -1,3 +1,4 @@
1+{-# LANGUAGE DataKinds #-}
12{-# LANGUAGE PolyKinds #-}
23module Servant.API.ReqBody where
34
@@ -6,5 +7,5 @@ module Servant.API.ReqBody where
67-- Example:
78--
89-- > -- POST /books
9−-- > type MyApi = "books" :> ReqBody Book :> Post Book
10−data ReqBody a
10+-- > type MyApi = "books" :> ReqBody '[JSON] Book :> Post Book
11+data ReqBody (ls::[*]) a
src/Servant/QQ.hs+2−2
@@ -1,7 +1,7 @@
1−{-# LANGUAGE MultiParamTypeClasses #-}
2−{-# LANGUAGE FunctionalDependencies #-}
31{-# LANGUAGE DataKinds #-}
42{-# LANGUAGE FlexibleInstances #-}
3+{-# LANGUAGE FunctionalDependencies #-}
4+{-# LANGUAGE MultiParamTypeClasses #-}
55{-# LANGUAGE ScopedTypeVariables #-}
66{-# LANGUAGE TemplateHaskell #-}
77{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
src/Servant/Utils/Links.hs+5−3
@@ -2,10 +2,11 @@
22{-# LANGUAGE ConstraintKinds #-}
33{-# LANGUAGE DataKinds #-}
44{-# LANGUAGE FlexibleInstances #-}
5−{-# LANGUAGE TypeFamilies #-}
6−{-# LANGUAGE TypeOperators #-}
75{-# LANGUAGE FunctionalDependencies #-}
6+{-# LANGUAGE PolyKinds #-}
87{-# LANGUAGE ScopedTypeVariables #-}
8+{-# LANGUAGE TypeFamilies #-}
9+{-# LANGUAGE TypeOperators #-}
910{-# LANGUAGE UndecidableInstances #-}
1011
1112-- | Type safe generation of internal links.
@@ -155,7 +156,8 @@ type family IsElem endpoint api :: Constraint where
155156 IsElem e (sa :<|> sb) = Or (IsElem e sa) (IsElem e sb)
156157 IsElem (e :> sa) (e :> sb) = IsElem sa sb
157158 IsElem sa (Header x :> sb) = IsElem sa sb
158− IsElem sa (ReqBody x :> sb) = IsElem sa sb
159+ IsElem sa (ReqBody y x :> sb) = IsElem sa sb
160+ IsElem (e :> sa) (Capture x y :> sb) = IsElem sa sb
159161 IsElem sa (QueryParam x y :> sb) = IsElem sa sb
160162 IsElem sa (QueryParams x y :> sb) = IsElem sa sb
161163 IsElem sa (QueryFlag x :> sb) = IsElem sa sb
test/Servant/Utils/LinksSpec.hs+2−3
@@ -12,7 +12,6 @@ import Servant.API ( type (:<|>), ReqBody, QueryParam, MatrixParam, MatrixParams
1212 , MatrixFlag, Get, Post, Capture, type (:>) , HTML , JSON, XML )
1313import Servant.QQSpec ( (~>) )
1414import Servant.Utils.Links ( IsElem, IsLink )
15−<<<<<<< HEAD
1615
1716type TestApi =
1817 -- Capture and query/matrix params
@@ -28,7 +27,7 @@ type TestApi =
2827 -- All of the verbs
2928 :<|> "get" :> Get '[JSON] ()
3029 :<|> "put" :> Put '[JSON] ()
31− :<|> "post" :> ReqBody 'True :> Post '[JSON] ()
30+ :<|> "post" :> ReqBody '[JSON] 'True :> Post '[JSON] ()
3231 :<|> "delete" :> Header "ponies" :> Delete
3332 :<|> "raw" :> Raw
3433
@@ -44,7 +43,7 @@ type BadTestLink' = "hello" :> "hi" :> Get '[HTML] Bool
4443type BadTestLink'2 = "greet" :> Get '[HTML] Bool
4544
4645type NotALink = "hello" :> Capture "x" Bool :> Get '[JSON] Bool
47−type NotALink2 = "hello" :> ReqBody 'True :> Get '[JSON] Bool
46+type NotALink2 = "hello" :> ReqBody '[JSON] 'True :> Get '[JSON] Bool
4847
4948apiLink :: (IsElem endpoint TestApi, HasLink endpoint)
5049 => Proxy endpoint -> MkLink endpoint