git.iko.soy/typeable/servant
on master help sign in
Merge pull request #5 from zerobuzz/2015-01-06-explicit-import-lists
5a6d864Alp Mestanogullari
src/Servant/API.hs+13−13
@@ -37,16 +37,16 @@ module Servant.API (
37 module Servant.Utils.Links,
37 module Servant.Utils.Links,
38 ) where
38 ) where
39
39
40−import Servant.API.Alternative
40+import Servant.API.Alternative ( (:<|>)(..) )
41−import Servant.API.Capture
41+import Servant.API.Capture ( Capture )
42−import Servant.API.Delete
42+import Servant.API.Delete ( Delete )
43−import Servant.API.Get
43+import Servant.API.Get ( Get )
44−import Servant.API.Header
44+import Servant.API.Header ( Header )
45−import Servant.API.Post
45+import Servant.API.Post ( Post )
46−import Servant.API.Put
46+import Servant.API.Put ( Put )
47−import Servant.API.QueryParam
47+import Servant.API.QueryParam ( QueryFlag, QueryParams, QueryParam )
48−import Servant.API.Raw
48+import Servant.API.Raw ( Raw )
49−import Servant.API.ReqBody
49+import Servant.API.ReqBody ( ReqBody )
50−import Servant.API.Sub
50+import Servant.API.Sub ( (:>)(..) )
51−import Servant.QQ (sitemap)
51+import Servant.QQ ( sitemap )
52−import Servant.Utils.Links (mkLink)
52+import Servant.Utils.Links ( mkLink )
src/Servant/API/Delete.hs+1−1
@@ -1,7 +1,7 @@
1{-# LANGUAGE DeriveDataTypeable #-}
1{-# LANGUAGE DeriveDataTypeable #-}
2module Servant.API.Delete where
2module Servant.API.Delete where
3
3
4−import Data.Typeable
4+import Data.Typeable ( Typeable )
5
5
6-- | Combinator for DELETE requests.
6-- | Combinator for DELETE requests.
7--
7--
src/Servant/API/Get.hs+1−1
@@ -1,7 +1,7 @@
1{-# LANGUAGE DeriveDataTypeable #-}
1{-# LANGUAGE DeriveDataTypeable #-}
2module Servant.API.Get where
2module Servant.API.Get where
3
3
4−import Data.Typeable
4+import Data.Typeable ( Typeable )
5
5
6-- | Endpoint for simple GET requests. Serves the result as JSON.
6-- | Endpoint for simple GET requests. Serves the result as JSON.
7--
7--
src/Servant/API/Header.hs−2
@@ -1,8 +1,6 @@
1{-# LANGUAGE PolyKinds #-}
1{-# LANGUAGE PolyKinds #-}
2module Servant.API.Header where
2module Servant.API.Header where
3
3
4−import GHC.TypeLits
5−
6-- | Extract the given header's value as a value of type @a@.
4-- | Extract the given header's value as a value of type @a@.
7--
5--
8-- Example:
6-- Example:
src/Servant/API/Post.hs+1−1
@@ -1,7 +1,7 @@
1{-# LANGUAGE DeriveDataTypeable #-}
1{-# LANGUAGE DeriveDataTypeable #-}
2module Servant.API.Post where
2module Servant.API.Post where
3
3
4−import Data.Typeable
4+import Data.Typeable ( Typeable )
5
5
6-- | Endpoint for POST requests. The type variable represents the type of the
6-- | Endpoint for POST requests. The type variable represents the type of the
7-- response body (not the request body, use 'Servant.API.ReqBody.ReqBody' for
7-- response body (not the request body, use 'Servant.API.ReqBody.ReqBody' for
src/Servant/API/Put.hs+1−1
@@ -1,7 +1,7 @@
1{-# LANGUAGE DeriveDataTypeable #-}
1{-# LANGUAGE DeriveDataTypeable #-}
2module Servant.API.Put where
2module Servant.API.Put where
3
3
4−import Data.Typeable
4+import Data.Typeable ( Typeable )
5
5
6-- | Endpoint for PUT requests, usually used to update a ressource.
6-- | Endpoint for PUT requests, usually used to update a ressource.
7-- The type @a@ is the type of the response body that's returned.
7-- The type @a@ is the type of the response body that's returned.
src/Servant/API/Sub.hs+1−2
@@ -2,8 +2,7 @@
2{-# LANGUAGE TypeOperators #-}
2{-# LANGUAGE TypeOperators #-}
3module Servant.API.Sub where
3module Servant.API.Sub where
4
4
5−import Data.Proxy
5+import Data.Proxy ( Proxy )
6−import GHC.TypeLits
7
6
8-- | The contained API (second argument) can be found under @("/" ++ path)@
7-- | The contained API (second argument) can be found under @("/" ++ path)@
9-- (path being the first argument).
8-- (path being the first argument).
src/Servant/Common/Text.hs+5−5
@@ -6,11 +6,11 @@ module Servant.Common.Text
6 , ToText(..)
6 , ToText(..)
7 ) where
7 ) where
8
8
9−import Data.String.Conversions
9+import Data.String.Conversions ( cs )
10−import Data.Int
10+import Data.Int ( Int8, Int16, Int32, Int64 )
11−import Data.Text
11+import Data.Text ( Text )
12−import Data.Text.Read
12+import Data.Text.Read ( rational, signed, decimal, Reader )
13−import Data.Word
13+import Data.Word ( Word, Word8, Word16, Word32, Word64 )
14
14
15-- | For getting values from url captures and query string parameters
15-- | For getting values from url captures and query string parameters
16class FromText a where
16class FromText a where
src/Servant/QQ.hs+31−14
@@ -28,21 +28,39 @@
28-- Note the @/@ before a @QueryParam@!
28-- Note the @/@ before a @QueryParam@!
29module Servant.QQ (sitemap) where
29module Servant.QQ (sitemap) where
30
30
31−import Control.Monad (void)
31+import Control.Monad ( void )
32−import Control.Applicative hiding (many, (<|>), optional)
32+import Control.Applicative ( (<$>) )
33−import Language.Haskell.TH.Quote
33+import Language.Haskell.TH.Quote ( QuasiQuoter(..) )
34import Language.Haskell.TH
34import Language.Haskell.TH
35+ ( mkName, Type(AppT, ConT, LitT), TyLit(StrTyLit) )
35import Text.ParserCombinators.Parsec
36import Text.ParserCombinators.Parsec
36−
37+ ( try,
38+ Parser,
39+ manyTill,
40+ endBy,
41+ sepBy1,
42+ optional,
43+ optionMaybe,
44+ string,
45+ anyChar,
46+ char,
47+ spaces,
48+ noneOf,
49+ parse,
50+ skipMany,
51+ many,
52+ lookAhead,
53+ (<|>),
54+ (<?>) )
37−import Servant.API.Capture
55+import Servant.API.Capture ( Capture )
38−import Servant.API.Get
56+import Servant.API.Get ( Get )
39−import Servant.API.Post
57+import Servant.API.Post ( Post )
40−import Servant.API.Put
58+import Servant.API.Put ( Put )
41−import Servant.API.Delete
59+import Servant.API.Delete ( Delete )
42−import Servant.API.QueryParam
60+import Servant.API.QueryParam ( QueryParam )
43−import Servant.API.ReqBody
61+import Servant.API.ReqBody ( ReqBody )
44−import Servant.API.Sub
62+import Servant.API.Sub ( (:>) )
45−import Servant.API.Alternative
63+import Servant.API.Alternative ( (:<|>) )
46
64
47-- | Finally-tagless encoding for our DSL.
65-- | Finally-tagless encoding for our DSL.
48-- Keeping 'repr'' and 'repr' distinct when writing functions with an
66-- Keeping 'repr'' and 'repr' distinct when writing functions with an
@@ -195,4 +213,3 @@ sitemap = QuasiQuoter { quoteExp = undefined
195 Right st -> return st
213 Right st -> return st
196 , quoteDec = undefined
214 , quoteDec = undefined
197 }
215 }
198−
src/Servant/Utils/Links.hs+11−12
@@ -48,18 +48,18 @@ module Servant.Utils.Links (
48 , IsLink
48 , IsLink
49 )where
49 )where
50
50
51−import Data.Proxy
51+import Data.Proxy ( Proxy(..) )
52−import GHC.TypeLits
52+import GHC.TypeLits ( KnownSymbol, Symbol, symbolVal )
53
53
54−import Servant.API.Capture
54+import Servant.API.Capture ( Capture )
55−import Servant.API.ReqBody
55+import Servant.API.ReqBody ( ReqBody )
56−import Servant.API.QueryParam
56+import Servant.API.QueryParam ( QueryParam )
57−import Servant.API.Get
57+import Servant.API.Get ( Get )
58−import Servant.API.Post
58+import Servant.API.Post ( Post )
59−import Servant.API.Put
59+import Servant.API.Put ( Put )
60−import Servant.API.Delete
60+import Servant.API.Delete ( Delete )
61−import Servant.API.Sub
61+import Servant.API.Sub ( type (:>) )
62−import Servant.API.Alternative
62+import Servant.API.Alternative ( type (:<|>) )
63
63
64
64
65type family Or a b where
65type family Or a b where
@@ -123,4 +123,3 @@ instance VLinkHelper (Get x) where
123
123
124instance VLinkHelper (Post x) where
124instance VLinkHelper (Post x) where
125 vlh _ = ""
125 vlh _ = ""
126−
test/Servant/QQSpec.hs+10−1
@@ -9,9 +9,18 @@
9{-# LANGUAGE UndecidableInstances #-}
9{-# LANGUAGE UndecidableInstances #-}
10module Servant.QQSpec where
10module Servant.QQSpec where
11
11
12−import Test.Hspec
12+import Test.Hspec ( Expectation, Spec, shouldBe, it, describe )
13
13
14import Servant.API
14import Servant.API
15+ ( (:<|>),
16+ ReqBody,
17+ QueryParam,
18+ Put,
19+ Get,
20+ Post,
21+ Capture,
22+ (:>),
23+ sitemap )
15
24
16--------------------------------------------------------------------------
25--------------------------------------------------------------------------
17-- Types for testing
26-- Types for testing
test/Servant/Utils/LinksSpec.hs+4−3
@@ -3,11 +3,13 @@
3{-# LANGUAGE TypeOperators #-}
3{-# LANGUAGE TypeOperators #-}
4module Servant.Utils.LinksSpec where
4module Servant.Utils.LinksSpec where
5
5
6−import Test.Hspec
6+import Test.Hspec ( Spec, it, describe )
7
7
8import Servant.API
8import Servant.API
9+ ( type (:<|>), ReqBody, QueryParam, Get, Post, Capture, type (:>) )
9import Servant.QQSpec ( (~>) )
10import Servant.QQSpec ( (~>) )
10−import Servant.Utils.Links (IsElem, IsLink)
11+import Servant.Utils.Links ( IsElem, IsLink )
12+
11
13
12type TestApi =
14type TestApi =
13 "hello" :> Capture "name" String :> QueryParam "capital" Bool :> Get Bool
15 "hello" :> Capture "name" String :> QueryParam "capital" Bool :> Get Bool
@@ -49,4 +51,3 @@ isLink = describe "IsLink" $ do
49 it "is False of anything with captures" $ do
51 it "is False of anything with captures" $ do
50 reflected (Proxy::Proxy (IsLink NotALink)) ~> False
52 reflected (Proxy::Proxy (IsLink NotALink)) ~> False
51 reflected (Proxy::Proxy (IsLink NotALink2)) ~> False
53 reflected (Proxy::Proxy (IsLink NotALink2)) ~> False
52−