Merge pull request #5 from zerobuzz/2015-01-06-explicit-import-lists

Explicit import lists
This commit is contained in:
Alp Mestanogullari 2015-01-06 18:32:19 +01:00
commit 5a6d864ebe
12 changed files with 79 additions and 56 deletions

View file

@ -37,16 +37,16 @@ module Servant.API (
module Servant.Utils.Links, module Servant.Utils.Links,
) where ) where
import Servant.API.Alternative import Servant.API.Alternative ( (:<|>)(..) )
import Servant.API.Capture import Servant.API.Capture ( Capture )
import Servant.API.Delete import Servant.API.Delete ( Delete )
import Servant.API.Get import Servant.API.Get ( Get )
import Servant.API.Header import Servant.API.Header ( Header )
import Servant.API.Post import Servant.API.Post ( Post )
import Servant.API.Put import Servant.API.Put ( Put )
import Servant.API.QueryParam import Servant.API.QueryParam ( QueryFlag, QueryParams, QueryParam )
import Servant.API.Raw import Servant.API.Raw ( Raw )
import Servant.API.ReqBody import Servant.API.ReqBody ( ReqBody )
import Servant.API.Sub import Servant.API.Sub ( (:>)(..) )
import Servant.QQ (sitemap) import Servant.QQ ( sitemap )
import Servant.Utils.Links (mkLink) import Servant.Utils.Links ( mkLink )

View file

@ -1,7 +1,7 @@
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
module Servant.API.Delete where module Servant.API.Delete where
import Data.Typeable import Data.Typeable ( Typeable )
-- | Combinator for DELETE requests. -- | Combinator for DELETE requests.
-- --

View file

@ -1,7 +1,7 @@
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
module Servant.API.Get where module Servant.API.Get where
import Data.Typeable import Data.Typeable ( Typeable )
-- | Endpoint for simple GET requests. Serves the result as JSON. -- | Endpoint for simple GET requests. Serves the result as JSON.
-- --

View file

@ -1,8 +1,6 @@
{-# LANGUAGE PolyKinds #-} {-# LANGUAGE PolyKinds #-}
module Servant.API.Header where module Servant.API.Header where
import GHC.TypeLits
-- | Extract the given header's value as a value of type @a@. -- | Extract the given header's value as a value of type @a@.
-- --
-- Example: -- Example:

View file

@ -1,7 +1,7 @@
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
module Servant.API.Post where module Servant.API.Post where
import Data.Typeable import Data.Typeable ( Typeable )
-- | Endpoint for POST requests. The type variable represents the type of the -- | Endpoint for POST requests. The type variable represents the type of the
-- response body (not the request body, use 'Servant.API.ReqBody.ReqBody' for -- response body (not the request body, use 'Servant.API.ReqBody.ReqBody' for

View file

@ -1,7 +1,7 @@
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
module Servant.API.Put where module Servant.API.Put where
import Data.Typeable import Data.Typeable ( Typeable )
-- | Endpoint for PUT requests, usually used to update a ressource. -- | Endpoint for PUT requests, usually used to update a ressource.
-- The type @a@ is the type of the response body that's returned. -- The type @a@ is the type of the response body that's returned.

View file

@ -2,8 +2,7 @@
{-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeOperators #-}
module Servant.API.Sub where module Servant.API.Sub where
import Data.Proxy import Data.Proxy ( Proxy )
import GHC.TypeLits
-- | The contained API (second argument) can be found under @("/" ++ path)@ -- | The contained API (second argument) can be found under @("/" ++ path)@
-- (path being the first argument). -- (path being the first argument).

View file

@ -6,11 +6,11 @@ module Servant.Common.Text
, ToText(..) , ToText(..)
) where ) where
import Data.String.Conversions import Data.String.Conversions ( cs )
import Data.Int import Data.Int ( Int8, Int16, Int32, Int64 )
import Data.Text import Data.Text ( Text )
import Data.Text.Read import Data.Text.Read ( rational, signed, decimal, Reader )
import Data.Word import Data.Word ( Word, Word8, Word16, Word32, Word64 )
-- | For getting values from url captures and query string parameters -- | For getting values from url captures and query string parameters
class FromText a where class FromText a where

View file

@ -28,21 +28,39 @@
-- Note the @/@ before a @QueryParam@! -- Note the @/@ before a @QueryParam@!
module Servant.QQ (sitemap) where module Servant.QQ (sitemap) where
import Control.Monad (void) import Control.Monad ( void )
import Control.Applicative hiding (many, (<|>), optional) import Control.Applicative ( (<$>) )
import Language.Haskell.TH.Quote import Language.Haskell.TH.Quote ( QuasiQuoter(..) )
import Language.Haskell.TH import Language.Haskell.TH
( mkName, Type(AppT, ConT, LitT), TyLit(StrTyLit) )
import Text.ParserCombinators.Parsec import Text.ParserCombinators.Parsec
( try,
import Servant.API.Capture Parser,
import Servant.API.Get manyTill,
import Servant.API.Post endBy,
import Servant.API.Put sepBy1,
import Servant.API.Delete optional,
import Servant.API.QueryParam optionMaybe,
import Servant.API.ReqBody string,
import Servant.API.Sub anyChar,
import Servant.API.Alternative char,
spaces,
noneOf,
parse,
skipMany,
many,
lookAhead,
(<|>),
(<?>) )
import Servant.API.Capture ( Capture )
import Servant.API.Get ( Get )
import Servant.API.Post ( Post )
import Servant.API.Put ( Put )
import Servant.API.Delete ( Delete )
import Servant.API.QueryParam ( QueryParam )
import Servant.API.ReqBody ( ReqBody )
import Servant.API.Sub ( (:>) )
import Servant.API.Alternative ( (:<|>) )
-- | Finally-tagless encoding for our DSL. -- | Finally-tagless encoding for our DSL.
-- Keeping 'repr'' and 'repr' distinct when writing functions with an -- Keeping 'repr'' and 'repr' distinct when writing functions with an
@ -195,4 +213,3 @@ sitemap = QuasiQuoter { quoteExp = undefined
Right st -> return st Right st -> return st
, quoteDec = undefined , quoteDec = undefined
} }

View file

@ -48,18 +48,18 @@ module Servant.Utils.Links (
, IsLink , IsLink
)where )where
import Data.Proxy import Data.Proxy ( Proxy(..) )
import GHC.TypeLits import GHC.TypeLits ( KnownSymbol, Symbol, symbolVal )
import Servant.API.Capture import Servant.API.Capture ( Capture )
import Servant.API.ReqBody import Servant.API.ReqBody ( ReqBody )
import Servant.API.QueryParam import Servant.API.QueryParam ( QueryParam )
import Servant.API.Get import Servant.API.Get ( Get )
import Servant.API.Post import Servant.API.Post ( Post )
import Servant.API.Put import Servant.API.Put ( Put )
import Servant.API.Delete import Servant.API.Delete ( Delete )
import Servant.API.Sub import Servant.API.Sub ( type (:>) )
import Servant.API.Alternative import Servant.API.Alternative ( type (:<|>) )
type family Or a b where type family Or a b where
@ -123,4 +123,3 @@ instance VLinkHelper (Get x) where
instance VLinkHelper (Post x) where instance VLinkHelper (Post x) where
vlh _ = "" vlh _ = ""

View file

@ -9,9 +9,18 @@
{-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE UndecidableInstances #-}
module Servant.QQSpec where module Servant.QQSpec where
import Test.Hspec import Test.Hspec ( Expectation, Spec, shouldBe, it, describe )
import Servant.API import Servant.API
( (:<|>),
ReqBody,
QueryParam,
Put,
Get,
Post,
Capture,
(:>),
sitemap )
-------------------------------------------------------------------------- --------------------------------------------------------------------------
-- Types for testing -- Types for testing

View file

@ -3,11 +3,13 @@
{-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeOperators #-}
module Servant.Utils.LinksSpec where module Servant.Utils.LinksSpec where
import Test.Hspec import Test.Hspec ( Spec, it, describe )
import Servant.API import Servant.API
( type (:<|>), ReqBody, QueryParam, Get, Post, Capture, type (:>) )
import Servant.QQSpec ( (~>) ) import Servant.QQSpec ( (~>) )
import Servant.Utils.Links (IsElem, IsLink) import Servant.Utils.Links ( IsElem, IsLink )
type TestApi = type TestApi =
"hello" :> Capture "name" String :> QueryParam "capital" Bool :> Get Bool "hello" :> Capture "name" String :> QueryParam "capital" Bool :> Get Bool
@ -49,4 +51,3 @@ isLink = describe "IsLink" $ do
it "is False of anything with captures" $ do it "is False of anything with captures" $ do
reflected (Proxy::Proxy (IsLink NotALink)) ~> False reflected (Proxy::Proxy (IsLink NotALink)) ~> False
reflected (Proxy::Proxy (IsLink NotALink2)) ~> False reflected (Proxy::Proxy (IsLink NotALink2)) ~> False