Apply stylish-haskell on all modules

This commit is contained in:
Oleg Grenrus 2018-06-29 22:08:26 +03:00
parent e3c91ec579
commit f9bcc15d0b
42 changed files with 567 additions and 431 deletions

View file

@ -13,5 +13,5 @@ module Servant.Client
, module Servant.Client.Core.Reexport , module Servant.Client.Core.Reexport
) where ) where
import Servant.Client.Core.Reexport import Servant.Client.Core.Reexport
import Servant.Client.Internal.HttpClient import Servant.Client.Internal.HttpClient

View file

@ -11,34 +11,49 @@
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
module Servant.Client.Internal.HttpClient where module Servant.Client.Internal.HttpClient where
import Prelude () import Prelude ()
import Prelude.Compat import Prelude.Compat
import Control.Concurrent.STM.TVar import Control.Concurrent.STM.TVar
import Control.Exception import Control.Exception
import Control.Monad import Control.Monad
import Control.Monad.Base (MonadBase (..)) import Control.Monad.Base
import Control.Monad.Catch (MonadCatch, MonadThrow) (MonadBase (..))
import Control.Monad.Error.Class (MonadError (..)) import Control.Monad.Catch
(MonadCatch, MonadThrow)
import Control.Monad.Error.Class
(MonadError (..))
import Control.Monad.Reader import Control.Monad.Reader
import Control.Monad.STM (atomically) import Control.Monad.STM
import Control.Monad.Trans.Control (MonadBaseControl (..)) (atomically)
import Control.Monad.Trans.Control
(MonadBaseControl (..))
import Control.Monad.Trans.Except import Control.Monad.Trans.Except
import Data.ByteString.Builder (toLazyByteString) import Data.ByteString.Builder
(toLazyByteString)
import qualified Data.ByteString.Lazy as BSL import qualified Data.ByteString.Lazy as BSL
import Data.Foldable (toList, for_) import Data.Foldable
import Data.Functor.Alt (Alt (..)) (for_, toList)
import Data.Maybe (maybeToList) import Data.Functor.Alt
import Data.Semigroup ((<>)) (Alt (..))
import Data.Proxy (Proxy (..)) import Data.Maybe
import Data.Sequence (fromList) (maybeToList)
import Data.String (fromString) import Data.Proxy
(Proxy (..))
import Data.Semigroup
((<>))
import Data.Sequence
(fromList)
import Data.String
(fromString)
import qualified Data.Text as T import qualified Data.Text as T
import Data.Time.Clock (getCurrentTime) import Data.Time.Clock
(getCurrentTime)
import GHC.Generics import GHC.Generics
import Network.HTTP.Media (renderHeader) import Network.HTTP.Media
import Network.HTTP.Types (hContentType, renderQuery, (renderHeader)
statusCode) import Network.HTTP.Types
(hContentType, renderQuery, statusCode)
import Servant.Client.Core import Servant.Client.Core
import qualified Network.HTTP.Client as Client import qualified Network.HTTP.Client as Client

View file

@ -26,56 +26,53 @@
#include "overlapping-compat.h" #include "overlapping-compat.h"
module Servant.ClientSpec (spec, Person(..), startWaiApp, endWaiApp) where module Servant.ClientSpec (spec, Person(..), startWaiApp, endWaiApp) where
import Prelude () import Prelude ()
import Prelude.Compat import Prelude.Compat
import Control.Arrow (left) import Control.Arrow
import Control.Concurrent (ThreadId, forkIO, (left)
killThread) import Control.Concurrent
import Control.Exception (bracket) (ThreadId, forkIO, killThread)
import Control.Monad.Error.Class (throwError) import Control.Exception
(bracket)
import Control.Monad.Error.Class
(throwError)
import Data.Aeson import Data.Aeson
import Data.Char (chr, isPrint) import Data.Char
import Data.Foldable (forM_) (chr, isPrint)
import Data.Semigroup ((<>)) import Data.Foldable
import Data.Monoid () (forM_)
import Data.Monoid ()
import Data.Proxy import Data.Proxy
import Data.Semigroup
((<>))
import qualified Generics.SOP as SOP import qualified Generics.SOP as SOP
import GHC.Generics (Generic) import GHC.Generics
(Generic)
import qualified Network.HTTP.Client as C import qualified Network.HTTP.Client as C
import qualified Network.HTTP.Types as HTTP import qualified Network.HTTP.Types as HTTP
import Network.Socket import Network.Socket
import qualified Network.Wai as Wai import qualified Network.Wai as Wai
import Network.Wai.Handler.Warp import Network.Wai.Handler.Warp
import System.IO.Unsafe (unsafePerformIO) import System.IO.Unsafe
(unsafePerformIO)
import Test.Hspec import Test.Hspec
import Test.Hspec.QuickCheck import Test.Hspec.QuickCheck
import Test.HUnit import Test.HUnit
import Test.QuickCheck import Test.QuickCheck
import Web.FormUrlEncoded (FromForm, ToForm) import Web.FormUrlEncoded
(FromForm, ToForm)
import Servant.API ((:<|>) ((:<|>)), import Servant.API
(:>), AuthProtect, ((:<|>) ((:<|>)), (:>), AuthProtect, BasicAuth,
BasicAuth, BasicAuthData (..), Capture, CaptureAll, Delete,
BasicAuthData (..), DeleteNoContent, EmptyAPI, FormUrlEncoded, Get, Header,
Capture, Headers, JSON, NoContent (NoContent), Post, Put, QueryFlag,
CaptureAll, Delete, QueryParam, QueryParams, Raw, ReqBody, addHeader, getHeaders)
DeleteNoContent,
EmptyAPI, addHeader,
FormUrlEncoded,
Get, Header,
Headers, JSON,
NoContent (NoContent),
Post, Put, Raw,
QueryFlag,
QueryParam,
QueryParams,
ReqBody,
getHeaders)
import Servant.API.Internal.Test.ComprehensiveAPI import Servant.API.Internal.Test.ComprehensiveAPI
import Servant.Client import Servant.Client
import qualified Servant.Client.Core.Internal.Request as Req import qualified Servant.Client.Core.Internal.Auth as Auth
import qualified Servant.Client.Core.Internal.Auth as Auth import qualified Servant.Client.Core.Internal.Request as Req
import Servant.Server import Servant.Server
import Servant.Server.Experimental.Auth import Servant.Server.Experimental.Auth

View file

@ -26,31 +26,36 @@
#include "overlapping-compat.h" #include "overlapping-compat.h"
module Servant.StreamSpec (spec) where module Servant.StreamSpec (spec) where
import Control.Monad (replicateM_, void) import Control.Monad
(replicateM_, void)
import qualified Data.ByteString as BS import qualified Data.ByteString as BS
import Data.Proxy import Data.Proxy
import qualified Network.HTTP.Client as C import qualified Network.HTTP.Client as C
import Prelude () import Prelude ()
import Prelude.Compat import Prelude.Compat
import System.IO (IOMode (ReadMode), withFile) import System.IO
import System.IO.Unsafe (unsafePerformIO) (IOMode (ReadMode), withFile)
import System.IO.Unsafe
(unsafePerformIO)
import Test.Hspec import Test.Hspec
import Test.QuickCheck import Test.QuickCheck
import Servant.API ((:<|>) ((:<|>)), (:>), JSON, import Servant.API
NetstringFraming, NewlineFraming, ((:<|>) ((:<|>)), (:>), JSON, NetstringFraming,
OctetStream, ResultStream (..), NewlineFraming, NoFraming, OctetStream, ResultStream (..),
StreamGenerator (..), StreamGet, StreamGenerator (..), StreamGet)
NoFraming)
import Servant.Client import Servant.Client
import Servant.ClientSpec (Person (..)) import Servant.ClientSpec
(Person (..))
import qualified Servant.ClientSpec as CS import qualified Servant.ClientSpec as CS
import Servant.Server import Servant.Server
#if MIN_VERSION_base(4,10,0) #if MIN_VERSION_base(4,10,0)
import GHC.Stats (gcdetails_mem_in_use_bytes, gc, getRTSStats) import GHC.Stats
(gc, gcdetails_mem_in_use_bytes, getRTSStats)
#else #else
import GHC.Stats (currentBytesUsed, getGCStats) import GHC.Stats
(currentBytesUsed, getGCStats)
#endif #endif
spec :: Spec spec :: Spec

View file

@ -5,14 +5,15 @@
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -fno-warn-orphans #-}
import Control.Lens import Control.Lens
import Data.Aeson import Data.Aeson
import Data.Proxy import Data.Proxy
import Data.String.Conversions import Data.String.Conversions
import Data.Text (Text) import Data.Text
import GHC.Generics (Text)
import Servant.API import GHC.Generics
import Servant.Docs import Servant.API
import Servant.Docs
-- * Example -- * Example

View file

@ -56,5 +56,5 @@ module Servant.Docs
, single , single
) where ) where
import Servant.Docs.Internal import Servant.Docs.Internal
import Servant.Docs.Internal.Pretty import Servant.Docs.Internal.Pretty

View file

@ -20,33 +20,45 @@
#include "overlapping-compat.h" #include "overlapping-compat.h"
module Servant.Docs.Internal where module Servant.Docs.Internal where
import Prelude () import Prelude ()
import Prelude.Compat import Prelude.Compat
import Control.Applicative import Control.Applicative
import Control.Arrow (second) import Control.Arrow
import Control.Lens (makeLenses, mapped, over, (second)
traversed, view, (%~), (&), (.~), import Control.Lens
(<>~), (^.), (|>)) (makeLenses, mapped, over, traversed, view, (%~), (&), (.~),
(<>~), (^.), (|>))
import qualified Control.Monad.Omega as Omega import qualified Control.Monad.Omega as Omega
import qualified Data.ByteString.Char8 as BSC import qualified Data.ByteString.Char8 as BSC
import Data.ByteString.Lazy.Char8 (ByteString) import Data.ByteString.Lazy.Char8
(ByteString)
import qualified Data.CaseInsensitive as CI import qualified Data.CaseInsensitive as CI
import Data.Foldable (fold) import Data.Foldable
import Data.Hashable (Hashable) (fold)
import Data.HashMap.Strict (HashMap) import Data.Hashable
import Data.List.Compat (intercalate, intersperse, sort) (Hashable)
import Data.List.NonEmpty (NonEmpty ((:|)), groupWith) import Data.HashMap.Strict
(HashMap)
import Data.List.Compat
(intercalate, intersperse, sort)
import Data.List.NonEmpty
(NonEmpty ((:|)), groupWith)
import qualified Data.List.NonEmpty as NE import qualified Data.List.NonEmpty as NE
import Data.Maybe import Data.Maybe
import Data.Monoid (All (..), Any (..), Dual (..), import Data.Monoid
First (..), Last (..), (All (..), Any (..), Dual (..), First (..), Last (..),
Product (..), Sum (..)) Product (..), Sum (..))
import Data.Ord (comparing) import Data.Ord
import Data.Proxy (Proxy (Proxy)) (comparing)
import Data.Semigroup (Semigroup (..)) import Data.Proxy
import Data.String.Conversions (cs) (Proxy (Proxy))
import Data.Text (Text, unpack) import Data.Semigroup
(Semigroup (..))
import Data.String.Conversions
(cs)
import Data.Text
(Text, unpack)
import GHC.Generics import GHC.Generics
import GHC.TypeLits import GHC.TypeLits
import Servant.API import Servant.API

View file

@ -4,16 +4,20 @@
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PolyKinds #-} {-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module Servant.Docs.Internal.Pretty where module Servant.Docs.Internal.Pretty where
import Data.Aeson (ToJSON(..)) import Data.Aeson
import Data.Aeson.Encode.Pretty (encodePretty) (ToJSON (..))
import Data.Proxy (Proxy(Proxy)) import Data.Aeson.Encode.Pretty
import Network.HTTP.Media ((//)) (encodePretty)
import Servant.API import Data.Proxy
(Proxy (Proxy))
import Network.HTTP.Media
((//))
import Servant.API
-- | PrettyJSON content type. -- | PrettyJSON content type.
data PrettyJSON data PrettyJSON

View file

@ -20,7 +20,8 @@ import Control.Lens
import Data.Aeson import Data.Aeson
import Data.Monoid import Data.Monoid
import Data.Proxy import Data.Proxy
import Data.String.Conversions (cs) import Data.String.Conversions
(cs)
import GHC.Generics import GHC.Generics
import Test.Hspec import Test.Hspec

View file

@ -1,2 +1,2 @@
import Distribution.Simple import Distribution.Simple
main = defaultMain main = defaultMain

View file

@ -51,6 +51,6 @@ module Servant.Foreign
, module Servant.Foreign.Inflections , module Servant.Foreign.Inflections
) where ) where
import Servant.API import Servant.API
import Servant.Foreign.Internal import Servant.Foreign.Inflections
import Servant.Foreign.Inflections import Servant.Foreign.Internal

View file

@ -10,11 +10,14 @@ module Servant.Foreign.Inflections
) where ) where
import Control.Lens hiding (cons) import Control.Lens hiding
import qualified Data.Char as C (cons)
import qualified Data.Char as C
import Data.Monoid import Data.Monoid
import Data.Text hiding (map) import Data.Text hiding
import Prelude hiding (head, tail) (map)
import Prelude hiding
(head, tail)
import Servant.Foreign.Internal import Servant.Foreign.Internal
concatCaseL :: Getter FunctionName Text concatCaseL :: Getter FunctionName Text

View file

@ -1,42 +1,47 @@
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PolyKinds #-} {-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE UndecidableInstances #-}
#if !MIN_VERSION_base(4,8,0) #if !MIN_VERSION_base(4,8,0)
{-# LANGUAGE NullaryTypeClasses #-} {-# LANGUAGE NullaryTypeClasses #-}
#endif #endif
-- | Generalizes all the data needed to make code generation work with -- | Generalizes all the data needed to make code generation work with
-- arbitrary programming languages. -- arbitrary programming languages.
module Servant.Foreign.Internal where module Servant.Foreign.Internal where
import Prelude () import Prelude ()
import Prelude.Compat import Prelude.Compat
import Control.Lens (makePrisms, makeLenses, Getter, (&), (<>~), (%~), import Control.Lens
(.~)) (Getter, makeLenses, makePrisms, (%~), (&), (.~), (<>~))
import Data.Data (Data) import Data.Data
(Data)
import Data.Proxy import Data.Proxy
import Data.Semigroup (Semigroup) import Data.Semigroup
(Semigroup)
import Data.String import Data.String
import Data.Text import Data.Text
import Data.Typeable (Typeable) import Data.Text.Encoding
import Data.Text.Encoding (decodeUtf8) (decodeUtf8)
import Data.Typeable
(Typeable)
import GHC.TypeLits import GHC.TypeLits
import qualified Network.HTTP.Types as HTTP import qualified Network.HTTP.Types as HTTP
import Servant.API import Servant.API
import Servant.API.Modifiers
(RequiredArgument)
import Servant.API.TypeLevel import Servant.API.TypeLevel
import Servant.API.Modifiers (RequiredArgument)
newtype FunctionName = FunctionName { unFunctionName :: [Text] } newtype FunctionName = FunctionName { unFunctionName :: [Text] }
deriving (Data, Show, Eq, Semigroup, Monoid, Typeable) deriving (Data, Show, Eq, Semigroup, Monoid, Typeable)

View file

@ -1,14 +1,14 @@
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PolyKinds #-} {-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeOperators #-}
#if __GLASGOW_HASKELL__ < 709 #if __GLASGOW_HASKELL__ < 709
{-# OPTIONS_GHC -fcontext-stack=41 #-} {-# OPTIONS_GHC -fcontext-stack=41 #-}
#endif #endif
@ -16,12 +16,13 @@
module Servant.ForeignSpec where module Servant.ForeignSpec where
import Data.Monoid ((<>)) import Data.Monoid
import Data.Proxy ((<>))
import Servant.Foreign import Data.Proxy
import Servant.API.Internal.Test.ComprehensiveAPI import Servant.API.Internal.Test.ComprehensiveAPI
import Servant.Foreign
import Test.Hspec import Test.Hspec
spec :: Spec spec :: Spec

View file

@ -13,9 +13,10 @@ module Servant (
throwError throwError
) where ) where
import Control.Monad.Error.Class (throwError) import Control.Monad.Error.Class
(throwError)
import Data.Proxy import Data.Proxy
import Servant.API import Servant.API
import Servant.Server
import Servant.Links import Servant.Links
import Servant.Server
import Servant.Utils.StaticFiles import Servant.Utils.StaticFiles

View file

@ -1,8 +1,8 @@
{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-} {-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
-- | This module lets you implement 'Server's for defined APIs. You'll -- | This module lets you implement 'Server's for defined APIs. You'll
-- most likely just need 'serve'. -- most likely just need 'serve'.
@ -92,10 +92,14 @@ module Servant.Server
) where ) where
import Data.Proxy (Proxy (..)) import Data.Proxy
import Data.Tagged (Tagged (..)) (Proxy (..))
import Data.Text (Text) import Data.Tagged
import Network.Wai (Application) (Tagged (..))
import Data.Text
(Text)
import Network.Wai
(Application)
import Servant.Server.Internal import Servant.Server.Internal

View file

@ -1,33 +1,37 @@
{-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-} {-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE UndecidableInstances #-}
module Servant.Server.Experimental.Auth where module Servant.Server.Experimental.Auth where
import Control.Monad.Trans (liftIO) import Control.Monad.Trans
import Data.Proxy (Proxy (Proxy)) (liftIO)
import Data.Typeable (Typeable) import Data.Proxy
import GHC.Generics (Generic) (Proxy (Proxy))
import Network.Wai (Request) import Data.Typeable
(Typeable)
import GHC.Generics
(Generic)
import Network.Wai
(Request)
import Servant ((:>)) import Servant
((:>))
import Servant.API.Experimental.Auth import Servant.API.Experimental.Auth
import Servant.Server.Internal (HasContextEntry, import Servant.Server.Internal
HasServer (..), (HasContextEntry, HasServer (..), getContextEntry)
getContextEntry) import Servant.Server.Internal.Handler
import Servant.Server.Internal.RoutingApplication (addAuthCheck, (Handler, runHandler)
delayedFailFatal, import Servant.Server.Internal.RoutingApplication
DelayedIO, (DelayedIO, addAuthCheck, delayedFailFatal, withRequest)
withRequest)
import Servant.Server.Internal.Handler (Handler, runHandler)
-- * General Auth -- * General Auth

View file

@ -1,27 +1,23 @@
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PolyKinds #-} {-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-} {-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-} {-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE UndecidableInstances #-}
#if MIN_VERSION_base(4,9,0) && __GLASGOW_HASKELL__ >= 802 #if MIN_VERSION_base(4,9,0) && __GLASGOW_HASKELL__ >= 802
#define HAS_TYPE_ERROR #define HAS_TYPE_ERROR
#endif #endif
#ifdef HAS_TYPE_ERROR
{-# LANGUAGE UndecidableInstances #-}
#endif
#include "overlapping-compat.h" #include "overlapping-compat.h"
module Servant.Server.Internal module Servant.Server.Internal
@ -34,72 +30,74 @@ module Servant.Server.Internal
, module Servant.Server.Internal.ServantErr , module Servant.Server.Internal.ServantErr
) where ) where
import Control.Monad (join, when) import Control.Monad
import Control.Monad.Trans (liftIO) (join, when)
import Control.Monad.Trans.Resource (runResourceT) import Control.Monad.Trans
import qualified Data.ByteString as B (liftIO)
import qualified Data.ByteString.Builder as BB import Control.Monad.Trans.Resource
import qualified Data.ByteString.Char8 as BC8 (runResourceT)
import qualified Data.ByteString.Lazy as BL import qualified Data.ByteString as B
import Data.Maybe (fromMaybe, mapMaybe, import qualified Data.ByteString.Builder as BB
isNothing, maybeToList) import qualified Data.ByteString.Char8 as BC8
import Data.Either (partitionEithers) import qualified Data.ByteString.Lazy as BL
import Data.Semigroup ((<>)) import Data.Either
import Data.String (IsString (..)) (partitionEithers)
import Data.String.Conversions (cs) import Data.Maybe
import Data.Tagged (Tagged(..), retag, untag) (fromMaybe, isNothing, mapMaybe, maybeToList)
import qualified Data.Text as T import Data.Semigroup
((<>))
import Data.String
(IsString (..))
import Data.String.Conversions
(cs)
import Data.Tagged
(Tagged (..), retag, untag)
import qualified Data.Text as T
import Data.Typeable import Data.Typeable
import GHC.TypeLits (KnownNat, KnownSymbol, natVal, import GHC.TypeLits
symbolVal) (KnownNat, KnownSymbol, natVal, symbolVal)
import Network.HTTP.Types hiding (Header, ResponseHeaders) import qualified Network.HTTP.Media as NHM
import qualified Network.HTTP.Media as NHM import Network.HTTP.Types hiding
import Network.Socket (SockAddr) (Header, ResponseHeaders)
import Network.Wai (Application, Request, import Network.Socket
httpVersion, isSecure, (SockAddr)
lazyRequestBody, import Network.Wai
rawQueryString, remoteHost, (Application, Request, httpVersion, isSecure, lazyRequestBody,
requestHeaders, requestMethod, rawQueryString, remoteHost, requestHeaders, requestMethod,
responseLBS, responseStream, responseLBS, responseStream, vault)
vault) import Prelude ()
import Prelude ()
import Prelude.Compat import Prelude.Compat
import Web.HttpApiData (FromHttpApiData, parseHeader, import Servant.API
parseQueryParam, ((:<|>) (..), (:>), Accept (..), BasicAuth,
parseUrlPieceMaybe, BoundaryStrategy (..), Capture', CaptureAll, Description,
parseUrlPieces) EmptyAPI, FramingRender (..), Header', If, IsSecure (..),
import Servant.API ((:<|>) (..), (:>), BasicAuth, Capture', QueryFlag, QueryParam', QueryParams, Raw,
CaptureAll, Verb, EmptyAPI, ReflectMethod (reflectMethod), RemoteHost, ReqBody',
ReflectMethod(reflectMethod), SBool (..), SBoolI (..), Stream, StreamGenerator (..),
IsSecure(..), Header', QueryFlag, Summary, ToStreamGenerator (..), Vault, Verb,
QueryParam', QueryParams, Raw, WithNamedContext)
RemoteHost, ReqBody', Vault, import Servant.API.ContentTypes
WithNamedContext, (AcceptHeader (..), AllCTRender (..), AllCTUnrender (..),
Description, Summary, AllMime, MimeRender (..), canHandleAcceptH)
Accept(..), import Servant.API.Modifiers
FramingRender(..), Stream, (FoldLenient, FoldRequired, RequestArgument,
StreamGenerator(..), ToStreamGenerator(..), unfoldRequestArgument)
BoundaryStrategy(..), import Servant.API.ResponseHeaders
If, SBool (..), SBoolI (..)) (GetHeaders, Headers, getHeaders, getResponse)
import Servant.API.Modifiers (unfoldRequestArgument, RequestArgument, FoldRequired, FoldLenient) import Web.HttpApiData
import Servant.API.ContentTypes (AcceptHeader (..), (FromHttpApiData, parseHeader, parseQueryParam,
AllCTRender (..), parseUrlPieceMaybe, parseUrlPieces)
AllCTUnrender (..),
AllMime,
MimeRender(..),
canHandleAcceptH)
import Servant.API.ResponseHeaders (GetHeaders, Headers, getHeaders,
getResponse)
import Servant.Server.Internal.Context
import Servant.Server.Internal.BasicAuth import Servant.Server.Internal.BasicAuth
import Servant.Server.Internal.Context
import Servant.Server.Internal.Handler import Servant.Server.Internal.Handler
import Servant.Server.Internal.Router import Servant.Server.Internal.Router
import Servant.Server.Internal.RoutingApplication import Servant.Server.Internal.RoutingApplication
import Servant.Server.Internal.ServantErr import Servant.Server.Internal.ServantErr
#ifdef HAS_TYPE_ERROR #ifdef HAS_TYPE_ERROR
import GHC.TypeLits (TypeError, ErrorMessage (..)) import GHC.TypeLits
(ErrorMessage (..), TypeError)
#endif #endif
class HasServer api context where class HasServer api context where

View file

@ -1,22 +1,31 @@
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
module Servant.Server.Internal.BasicAuth where module Servant.Server.Internal.BasicAuth where
import Control.Monad (guard) import Control.Monad
import Control.Monad.Trans (liftIO) (guard)
import qualified Data.ByteString as BS import Control.Monad.Trans
import Data.ByteString.Base64 (decodeLenient) (liftIO)
import Data.Monoid ((<>)) import qualified Data.ByteString as BS
import Data.Typeable (Typeable) import Data.ByteString.Base64
import Data.Word8 (isSpace, toLower, _colon) (decodeLenient)
import Data.Monoid
((<>))
import Data.Typeable
(Typeable)
import Data.Word8
(isSpace, toLower, _colon)
import GHC.Generics import GHC.Generics
import Network.HTTP.Types (Header) import Network.HTTP.Types
import Network.Wai (Request, requestHeaders) (Header)
import Network.Wai
(Request, requestHeaders)
import Servant.API.BasicAuth (BasicAuthData(BasicAuthData)) import Servant.API.BasicAuth
(BasicAuthData (BasicAuthData))
import Servant.Server.Internal.RoutingApplication import Servant.Server.Internal.RoutingApplication
import Servant.Server.Internal.ServantErr import Servant.Server.Internal.ServantErr

View file

@ -5,17 +5,25 @@
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
module Servant.Server.Internal.Handler where module Servant.Server.Internal.Handler where
import Prelude () import Prelude ()
import Prelude.Compat import Prelude.Compat
import Control.Monad.Base (MonadBase (..)) import Control.Monad.Base
import Control.Monad.Catch (MonadCatch, MonadThrow) (MonadBase (..))
import Control.Monad.Error.Class (MonadError) import Control.Monad.Catch
import Control.Monad.IO.Class (MonadIO) (MonadCatch, MonadThrow)
import Control.Monad.Trans.Control (MonadBaseControl (..)) import Control.Monad.Error.Class
import Control.Monad.Trans.Except (ExceptT, runExceptT) (MonadError)
import GHC.Generics (Generic) import Control.Monad.IO.Class
import Servant.Server.Internal.ServantErr (ServantErr) (MonadIO)
import Control.Monad.Trans.Control
(MonadBaseControl (..))
import Control.Monad.Trans.Except
(ExceptT, runExceptT)
import GHC.Generics
(Generic)
import Servant.Server.Internal.ServantErr
(ServantErr)
newtype Handler a = Handler { runHandler' :: ExceptT ServantErr IO a } newtype Handler a = Handler { runHandler' :: ExceptT ServantErr IO a }
deriving deriving

View file

@ -1,15 +1,18 @@
{-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE CPP #-}
{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE GADTs #-} {-# LANGUAGE GADTs #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
module Servant.Server.Internal.Router where module Servant.Server.Internal.Router where
import Data.Map (Map) import Data.Map
(Map)
import qualified Data.Map as M import qualified Data.Map as M
import Data.Monoid import Data.Monoid
import Data.Text (Text) import Data.Text
(Text)
import qualified Data.Text as T import qualified Data.Text as T
import Network.Wai (Response, pathInfo) import Network.Wai
(Response, pathInfo)
import Servant.Server.Internal.RoutingApplication import Servant.Server.Internal.RoutingApplication
import Servant.Server.Internal.ServantErr import Servant.Server.Internal.ServantErr

View file

@ -10,16 +10,25 @@
{-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE UndecidableInstances #-}
module Servant.Server.Internal.RoutingApplication where module Servant.Server.Internal.RoutingApplication where
import Control.Monad (ap, liftM) import Control.Monad
import Control.Monad.Base (MonadBase (..)) (ap, liftM)
import Control.Monad.Catch (MonadThrow (..)) import Control.Monad.Base
import Control.Monad.Reader (MonadReader (..), ReaderT (..), runReaderT) (MonadBase (..))
import Control.Monad.Trans (MonadIO (..), MonadTrans (..)) import Control.Monad.Catch
import Control.Monad.Trans.Control (ComposeSt, MonadBaseControl (..), MonadTransControl (..), (MonadThrow (..))
defaultLiftBaseWith, defaultRestoreM) import Control.Monad.Reader
import Control.Monad.Trans.Resource (MonadResource (..), ResourceT, runResourceT, transResourceT, withInternalState, runInternalState) (MonadReader (..), ReaderT (..), runReaderT)
import Network.Wai (Application, Request, Response, ResponseReceived) import Control.Monad.Trans
import Prelude () (MonadIO (..), MonadTrans (..))
import Control.Monad.Trans.Control
(ComposeSt, MonadBaseControl (..), MonadTransControl (..),
defaultLiftBaseWith, defaultRestoreM)
import Control.Monad.Trans.Resource
(MonadResource (..), ResourceT, runInternalState,
runResourceT, transResourceT, withInternalState)
import Network.Wai
(Application, Request, Response, ResponseReceived)
import Prelude ()
import Prelude.Compat import Prelude.Compat
import Servant.Server.Internal.Handler import Servant.Server.Internal.Handler
import Servant.Server.Internal.ServantErr import Servant.Server.Internal.ServantErr

View file

@ -1,14 +1,17 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
module Servant.Server.Internal.ServantErr where module Servant.Server.Internal.ServantErr where
import Control.Exception (Exception) import Control.Exception
(Exception)
import qualified Data.ByteString.Char8 as BS import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy as LBS import qualified Data.ByteString.Lazy as LBS
import Data.Typeable (Typeable) import Data.Typeable
(Typeable)
import qualified Network.HTTP.Types as HTTP import qualified Network.HTTP.Types as HTTP
import Network.Wai (Response, responseLBS) import Network.Wai
(Response, responseLBS)
data ServantErr = ServantErr { errHTTPCode :: Int data ServantErr = ServantErr { errHTTPCode :: Int
, errReasonPhrase :: String , errReasonPhrase :: String

View file

@ -15,15 +15,21 @@ module Servant.Utils.StaticFiles
serveDirectory serveDirectory
) where ) where
import Data.ByteString (ByteString) import Data.ByteString
(ByteString)
import Network.Wai.Application.Static import Network.Wai.Application.Static
import Servant.API.Raw (Raw) import Servant.API.Raw
import Servant.Server (ServerT, Tagged (..)) (Raw)
import System.FilePath (addTrailingPathSeparator) import Servant.Server
(ServerT, Tagged (..))
import System.FilePath
(addTrailingPathSeparator)
#if !MIN_VERSION_wai_app_static(3,1,0) #if !MIN_VERSION_wai_app_static(3,1,0)
import Filesystem.Path.CurrentOS (decodeString) import Filesystem.Path.CurrentOS
(decodeString)
#endif #endif
import WaiAppStatic.Storage.Filesystem (ETagLookup) import WaiAppStatic.Storage.Filesystem
(ETagLookup)
-- | Serve anything under the specified directory as a 'Raw' endpoint. -- | Serve anything under the specified directory as a 'Raw' endpoint.
-- --

View file

@ -9,9 +9,10 @@ import Data.Proxy
import Servant.API import Servant.API
import Servant.Server import Servant.Server
import Test.Hspec (Spec, describe, it) import Test.Hspec
import Test.Hspec.Wai (get, matchStatus, post, (Spec, describe, it)
shouldRespondWith, with) import Test.Hspec.Wai
(get, matchStatus, post, shouldRespondWith, with)
spec :: Spec spec :: Spec
spec = describe "Arbitrary monad server" $ do spec = describe "Arbitrary monad server" $ do

View file

@ -1,10 +1,11 @@
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeOperators #-}
module Servant.HoistSpec where module Servant.HoistSpec where
import Test.Hspec (Spec) import Test.Hspec
(Spec)
import Servant import Servant
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- https://github.com/haskell-servant/servant/issues/734 -- https://github.com/haskell-servant/servant/issues/734

View file

@ -6,16 +6,20 @@
{-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -fno-warn-orphans #-}
module Servant.Server.ErrorSpec (spec) where module Servant.Server.ErrorSpec (spec) where
import Control.Monad (when) import Control.Monad
import Data.Aeson (encode) (when)
import Data.Aeson
(encode)
import qualified Data.ByteString.Char8 as BC import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString.Lazy.Char8 as BCL import qualified Data.ByteString.Lazy.Char8 as BCL
import Data.Monoid ((<>)) import Data.Monoid
((<>))
import Data.Proxy import Data.Proxy
import Network.HTTP.Types (hAccept, hAuthorization, import Network.HTTP.Types
hContentType, methodGet, (hAccept, hAuthorization, hContentType, methodGet, methodPost,
methodPost, methodPut) methodPut)
import Safe (readMay) import Safe
(readMay)
import Test.Hspec import Test.Hspec
import Test.Hspec.Wai import Test.Hspec.Wai

View file

@ -2,9 +2,12 @@
{-# OPTIONS_GHC -fdefer-type-errors -Wwarn #-} {-# OPTIONS_GHC -fdefer-type-errors -Wwarn #-}
module Servant.Server.Internal.ContextSpec (spec) where module Servant.Server.Internal.ContextSpec (spec) where
import Data.Proxy (Proxy (..)) import Data.Proxy
import Test.Hspec (Spec, describe, it, shouldBe, context) (Proxy (..))
import Test.ShouldNotTypecheck (shouldNotTypecheck) import Test.Hspec
(Spec, context, describe, it, shouldBe)
import Test.ShouldNotTypecheck
(shouldNotTypecheck)
import Servant.API import Servant.API
import Servant.Server.Internal.Context import Servant.Server.Internal.Context

View file

@ -1,31 +1,37 @@
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE KindSignatures #-} {-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeOperators #-}
module Servant.Server.Internal.RoutingApplicationSpec (spec) where module Servant.Server.Internal.RoutingApplicationSpec (spec) where
import Prelude () import Prelude ()
import Prelude.Compat import Prelude.Compat
import Control.Exception hiding (Handler) import Control.Exception hiding
import Control.Monad.Trans.Resource (register) (Handler)
import Control.Monad.IO.Class import Control.Monad.IO.Class
import Data.IORef import Control.Monad.Trans.Resource
import Data.Proxy (register)
import GHC.TypeLits (Symbol, KnownSymbol, symbolVal) import Data.IORef
import Servant import Data.Proxy
import Servant.Server.Internal.RoutingApplication import GHC.TypeLits
import Network.Wai (defaultRequest) (KnownSymbol, Symbol, symbolVal)
import Test.Hspec import Network.Wai
import Test.Hspec.Wai (request, shouldRespondWith, with) (defaultRequest)
import Servant
import Servant.Server.Internal.RoutingApplication
import Test.Hspec
import Test.Hspec.Wai
(request, shouldRespondWith, with)
import qualified Data.Text as T import qualified Data.Text as T
import System.IO.Unsafe (unsafePerformIO) import System.IO.Unsafe
(unsafePerformIO)
data TestResource x data TestResource x
= TestResourceNone = TestResourceNone

View file

@ -1,20 +1,27 @@
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeOperators #-}
module Servant.Server.RouterSpec (spec) where module Servant.Server.RouterSpec (spec) where
import Control.Monad (unless) import Control.Monad
import Data.Proxy (Proxy(..)) (unless)
import Data.Text (unpack) import Data.Proxy
import Network.HTTP.Types (Status (..)) (Proxy (..))
import Network.Wai (responseBuilder) import Data.Text
import Network.Wai.Internal (Response (ResponseBuilder)) (unpack)
import Test.Hspec import Network.HTTP.Types
import Test.Hspec.Wai (get, shouldRespondWith, with) (Status (..))
import Network.Wai
(responseBuilder)
import Network.Wai.Internal
(Response (ResponseBuilder))
import Servant.API import Servant.API
import Servant.Server import Servant.Server
import Servant.Server.Internal import Servant.Server.Internal
import Test.Hspec
import Test.Hspec.Wai
(get, shouldRespondWith, with)
spec :: Spec spec :: Spec
spec = describe "Servant.Server.Internal.Router" $ do spec = describe "Servant.Server.Internal.Router" $ do

View file

@ -1,18 +1,19 @@
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-} {-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeOperators #-}
-- | This module tests whether streaming works from client to server -- | This module tests whether streaming works from client to server
-- with a server implemented with servant-server. -- with a server implemented with servant-server.
module Servant.Server.StreamingSpec where module Servant.Server.StreamingSpec where
import Control.Concurrent import Control.Concurrent
import Control.Exception hiding (Handler) import Control.Exception hiding
(Handler)
import Control.Monad.IO.Class import Control.Monad.IO.Class
import qualified Data.ByteString as Strict import qualified Data.ByteString as Strict
import qualified Data.ByteString.Lazy as Lazy import qualified Data.ByteString.Lazy as Lazy
import Network.HTTP.Types import Network.HTTP.Types
import Network.Wai import Network.Wai
import Network.Wai.Internal import Network.Wai.Internal

View file

@ -1,12 +1,13 @@
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeOperators #-}
module Servant.Server.UsingContextSpec where module Servant.Server.UsingContextSpec where
import Network.Wai import Network.Wai
import Test.Hspec (Spec, describe, it) import Test.Hspec
(Spec, describe, it)
import Test.Hspec.Wai import Test.Hspec.Wai
import Servant import Servant

View file

@ -1,13 +1,13 @@
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE KindSignatures #-} {-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-} {-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE UndecidableInstances #-}
-- | These are custom combinators for Servant.Server.UsingContextSpec. -- | These are custom combinators for Servant.Server.UsingContextSpec.
-- --

View file

@ -5,20 +5,29 @@
{-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -fno-warn-orphans #-}
module Servant.Utils.StaticFilesSpec where module Servant.Utils.StaticFilesSpec where
import Control.Exception (bracket) import Control.Exception
import Data.Proxy (Proxy (Proxy)) (bracket)
import Network.Wai (Application) import Data.Proxy
import System.Directory (createDirectory, (Proxy (Proxy))
getCurrentDirectory, import Network.Wai
setCurrentDirectory) (Application)
import System.IO.Temp (withSystemTempDirectory) import System.Directory
import Test.Hspec (Spec, around_, describe, it) (createDirectory, getCurrentDirectory, setCurrentDirectory)
import Test.Hspec.Wai (get, shouldRespondWith, with) import System.IO.Temp
(withSystemTempDirectory)
import Test.Hspec
(Spec, around_, describe, it)
import Test.Hspec.Wai
(get, shouldRespondWith, with)
import Servant.API ((:<|>) ((:<|>)), Capture, Get, Raw, (:>), JSON) import Servant.API
import Servant.Server (Server, serve) ((:<|>) ((:<|>)), (:>), Capture, Get, JSON, Raw)
import Servant.ServerSpec (Person (Person)) import Servant.Server
import Servant.Utils.StaticFiles (serveDirectoryFileServer) (Server, serve)
import Servant.ServerSpec
(Person (Person))
import Servant.Utils.StaticFiles
(serveDirectoryFileServer)
type Api = type Api =
"dummy_api" :> Capture "person_name" String :> Get '[JSON] Person "dummy_api" :> Capture "person_name" String :> Get '[JSON] Person

View file

@ -13,9 +13,11 @@
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
module Main where module Main where
import Build_doctests (flags, pkgs, module_sources) import Build_doctests
import Data.Foldable (traverse_) (flags, module_sources, pkgs)
import Test.DocTest import Data.Foldable
(traverse_)
import Test.DocTest
main :: IO () main :: IO ()
main = do main = do

View file

@ -114,9 +114,9 @@ import Servant.API.ResponseHeaders
ResponseHeader (..), addHeader, getHeadersHList, getResponse, ResponseHeader (..), addHeader, getHeadersHList, getResponse,
noHeader) noHeader)
import Servant.API.Stream import Servant.API.Stream
(BoundaryStrategy (..), FromResultStream (..), (BoundaryStrategy (..), ByteStringParser (..),
ByteStringParser (..), FramingRender (..), FramingRender (..), FramingUnrender (..),
FramingUnrender (..), NetstringFraming, NewlineFraming, FromResultStream (..), NetstringFraming, NewlineFraming,
NoFraming, ResultStream (..), Stream, StreamGenerator (..), NoFraming, ResultStream (..), Stream, StreamGenerator (..),
StreamGet, StreamPost, ToStreamGenerator (..)) StreamGet, StreamPost, ToStreamGenerator (..))
import Servant.API.Sub import Servant.API.Sub

View file

@ -3,4 +3,4 @@ module Servant.Utils.Links
( module Servant.Links ) ( module Servant.Links )
where where
import Servant.Links import Servant.Links

View file

@ -12,25 +12,32 @@ import Prelude ()
import Prelude.Compat import Prelude.Compat
import Data.Aeson.Compat import Data.Aeson.Compat
import Data.ByteString.Char8 (ByteString, append, pack) import Data.ByteString.Char8
import qualified Data.ByteString.Lazy as BSL (ByteString, append, pack)
import qualified Data.ByteString.Lazy.Char8 as BSL8 import qualified Data.ByteString.Lazy as BSL
import qualified Data.ByteString.Lazy.Char8 as BSL8
import Data.Either import Data.Either
import Data.Function (on) import Data.Function
import Data.List (maximumBy) (on)
import qualified Data.List.NonEmpty as NE import Data.List
import Data.Maybe (fromJust, isJust, isNothing) (maximumBy)
import qualified Data.List.NonEmpty as NE
import Data.Maybe
(fromJust, isJust, isNothing)
import Data.Proxy import Data.Proxy
import Data.String (IsString (..)) import Data.String
import Data.String.Conversions (cs) (IsString (..))
import qualified Data.Text as TextS import Data.String.Conversions
import qualified Data.Text.Encoding as TextSE (cs)
import qualified Data.Text.Lazy as TextL import qualified Data.Text as TextS
import qualified Data.Text.Encoding as TextSE
import qualified Data.Text.Lazy as TextL
import GHC.Generics import GHC.Generics
import Test.Hspec import Test.Hspec
import Test.QuickCheck import Test.QuickCheck
import Text.Read (readMaybe) import "quickcheck-instances" Test.QuickCheck.Instances ()
import "quickcheck-instances" Test.QuickCheck.Instances () import Text.Read
(readMaybe)
import Servant.API.ContentTypes import Servant.API.ContentTypes

View file

@ -1,11 +1,11 @@
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
module Servant.API.ResponseHeadersSpec where module Servant.API.ResponseHeadersSpec where
import Test.Hspec import Test.Hspec
import Servant.API.Header import Servant.API.Header
import Servant.API.ResponseHeaders import Servant.API.ResponseHeaders
spec :: Spec spec :: Spec
spec = describe "Servant.API.ResponseHeaders" $ do spec = describe "Servant.API.ResponseHeaders" $ do

View file

@ -1,22 +1,25 @@
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-} {-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
#if __GLASGOW_HASKELL__ < 709 #if __GLASGOW_HASKELL__ < 709
{-# OPTIONS_GHC -fcontext-stack=41 #-} {-# OPTIONS_GHC -fcontext-stack=41 #-}
#endif #endif
module Servant.LinksSpec where module Servant.LinksSpec where
import Data.Proxy (Proxy (..)) import Data.Proxy
import Test.Hspec (Expectation, Spec, describe, it, (Proxy (..))
shouldBe) import Data.String
import Data.String (fromString) (fromString)
import Test.Hspec
(Expectation, Spec, describe, it, shouldBe)
import Servant.API import Servant.API
import Servant.API.Internal.Test.ComprehensiveAPI
(comprehensiveAPIWithoutRaw)
import Servant.Links import Servant.Links
import Servant.API.Internal.Test.ComprehensiveAPI (comprehensiveAPIWithoutRaw)
type TestApi = type TestApi =
-- Capture and query params -- Capture and query params

View file

@ -13,9 +13,11 @@
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
module Main where module Main where
import Build_doctests (flags, pkgs, module_sources) import Build_doctests
import Data.Foldable (traverse_) (flags, module_sources, pkgs)
import Test.DocTest import Data.Foldable
(traverse_)
import Test.DocTest
main :: IO () main :: IO ()
main = do main = do