From b50e9128c148ccd02883578c078295aeba9a82fc Mon Sep 17 00:00:00 2001 From: "Julian K. Arni" Date: Wed, 23 Sep 2015 12:05:49 +0200 Subject: [PATCH 1/7] Turn on Werror on travis. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d9aee216..5f82ccd6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ install: script: - stack setup - - stack build + - stack build --pedantic - stack test cache: From 965063171b9b6ecde45361f4a2d4d74a60ee6ec2 Mon Sep 17 00:00:00 2001 From: "Julian K. Arni" Date: Wed, 23 Sep 2015 18:26:05 +0200 Subject: [PATCH 2/7] Janitoring --- servant-docs/servant-docs.cabal | 1 + servant-docs/src/Servant/Docs/Internal.hs | 18 ++++++++++-------- .../auth-combinator/auth-combinator.hs | 1 + servant-examples/hackage/hackage.hs | 2 ++ servant-examples/servant-examples.cabal | 4 ++++ servant-examples/tutorial/T3.hs | 1 + servant-js/servant-js.cabal | 3 +++ servant-js/src/Servant/JS/Internal.hs | 3 ++- servant-mock/src/Servant/Mock.hs | 3 ++- servant-server/servant-server.cabal | 5 +++++ servant/servant.cabal | 5 +++++ stack.yaml | 2 ++ 12 files changed, 38 insertions(+), 10 deletions(-) diff --git a/servant-docs/servant-docs.cabal b/servant-docs/servant-docs.cabal index 9a238e3f..ee6f71bf 100644 --- a/servant-docs/servant-docs.cabal +++ b/servant-docs/servant-docs.cabal @@ -65,6 +65,7 @@ executable greet-docs test-suite spec type: exitcode-stdio-1.0 main-is: Spec.hs + other-modules: Servant.DocsSpec hs-source-dirs: test ghc-options: -Wall build-depends: diff --git a/servant-docs/src/Servant/Docs/Internal.hs b/servant-docs/src/Servant/Docs/Internal.hs index d2ca2127..619084dd 100644 --- a/servant-docs/src/Servant/Docs/Internal.hs +++ b/servant-docs/src/Servant/Docs/Internal.hs @@ -23,19 +23,21 @@ module Servant.Docs.Internal where import Control.Applicative import Control.Arrow (second) -import Control.Lens hiding (List, to, from) +import Control.Lens (makeLenses, over, traversed, (%~), + (&), (.~), (<>~), (^.), _1, _2, + _last, (|>)) import qualified Control.Monad.Omega as Omega import Data.ByteString.Conversion (ToByteString, toByteString) import Data.ByteString.Lazy.Char8 (ByteString) import qualified Data.CaseInsensitive as CI -import Data.Hashable +import Data.Hashable (Hashable) import Data.HashMap.Strict (HashMap) import Data.List import Data.Maybe import Data.Monoid import Data.Ord (comparing) -import Data.Proxy -import Data.String.Conversions +import Data.Proxy (Proxy(Proxy)) +import Data.String.Conversions (cs) import Data.Text (Text, pack, unpack) import GHC.Exts (Constraint) import GHC.Generics @@ -494,9 +496,9 @@ sampleByteStrings -> Proxy a -> [(Text, M.MediaType, ByteString)] sampleByteStrings ctypes@Proxy Proxy = - let samples = toSamples (Proxy :: Proxy a) + let samples' = toSamples (Proxy :: Proxy a) enc (t, s) = uncurry (t,,) <$> allMimeRender ctypes s - in concatMap enc samples + in concatMap enc samples' -- | Generate a list of 'MediaType' values describing the content types -- accepted by an API component. @@ -640,10 +642,10 @@ markdown api = unlines $ rqbodyStr :: [M.MediaType] -> [(M.MediaType, ByteString)]-> [String] rqbodyStr [] [] = [] - rqbodyStr types samples = + rqbodyStr types s = ["#### Request:", ""] <> formatTypes types - <> concatMap formatBody samples + <> concatMap formatBody s formatTypes [] = [] formatTypes ts = ["- Supported content types are:", ""] diff --git a/servant-examples/auth-combinator/auth-combinator.hs b/servant-examples/auth-combinator/auth-combinator.hs index c82510f3..26cc0475 100644 --- a/servant-examples/auth-combinator/auth-combinator.hs +++ b/servant-examples/auth-combinator/auth-combinator.hs @@ -5,6 +5,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} +{-# OPTIONS_GHC -fno-warn-unused-binds #-} import Data.Aeson import Data.ByteString (ByteString) import Data.Text (Text) diff --git a/servant-examples/hackage/hackage.hs b/servant-examples/hackage/hackage.hs index a559d85f..685974cc 100644 --- a/servant-examples/hackage/hackage.hs +++ b/servant-examples/hackage/hackage.hs @@ -2,6 +2,8 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TypeOperators #-} +{-# OPTIONS_GHC -fno-warn-unused-binds #-} +{-# OPTIONS_GHC -fno-warn-unused-imports #-} import Control.Applicative import Control.Monad import Control.Monad.IO.Class diff --git a/servant-examples/servant-examples.cabal b/servant-examples/servant-examples.cabal index 41533dee..9c8cfaca 100644 --- a/servant-examples/servant-examples.cabal +++ b/servant-examples/servant-examples.cabal @@ -20,6 +20,7 @@ source-repository head executable tutorial main-is: tutorial.hs other-modules: T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 + ghc-options: -Wall -fno-warn-unused-binds -fno-warn-name-shadowing build-depends: aeson >= 0.8 , base >= 4.7 && < 5 @@ -45,8 +46,10 @@ executable tutorial executable t8-main main-is: t8-main.hs + other-modules: T3, T8 hs-source-dirs: tutorial default-language: Haskell2010 + ghc-options: -Wall -fno-warn-unused-binds -fno-warn-name-shadowing build-depends: aeson , base >= 4.7 && < 5 @@ -101,6 +104,7 @@ executable auth-combinator executable socket-io-chat main-is: socket-io-chat.hs + other-modules: Chat build-depends: aeson >= 0.8 , base >= 4.7 && < 5 diff --git a/servant-examples/tutorial/T3.hs b/servant-examples/tutorial/T3.hs index 7b5bdeb3..09c9c2ae 100644 --- a/servant-examples/tutorial/T3.hs +++ b/servant-examples/tutorial/T3.hs @@ -2,6 +2,7 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} +{-# OPTIONS_GHC -fno-warn-unused-binds #-} module T3 where import Control.Monad.Trans.Except diff --git a/servant-js/servant-js.cabal b/servant-js/servant-js.cabal index 6734524e..4cb95107 100644 --- a/servant-js/servant-js.cabal +++ b/servant-js/servant-js.cabal @@ -77,6 +77,9 @@ test-suite spec hs-source-dirs: test ghc-options: -Wall main-is: Spec.hs + other-modules: + Servant.JSSpec + Servant.JSSpec.CustomHeaders build-depends: base , hspec >= 2.1.8 , hspec-expectations diff --git a/servant-js/src/Servant/JS/Internal.hs b/servant-js/src/Servant/JS/Internal.hs index ec807dbd..37efda59 100644 --- a/servant-js/src/Servant/JS/Internal.hs +++ b/servant-js/src/Servant/JS/Internal.hs @@ -1,3 +1,4 @@ +<<<<<<< HEAD module Servant.JS.Internal ( JavaScriptGenerator , CommonGeneratorOptions(..) @@ -29,7 +30,7 @@ module Servant.JS.Internal , Get , Raw , Header - ) where + ) where import Control.Lens hiding (List) import qualified Data.CharSet as Set diff --git a/servant-mock/src/Servant/Mock.hs b/servant-mock/src/Servant/Mock.hs index 00f445b2..1bd93a04 100644 --- a/servant-mock/src/Servant/Mock.hs +++ b/servant-mock/src/Servant/Mock.hs @@ -5,6 +5,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} +{-# OPTIONS_GHC -fno-warn-orphans #-} -- | -- Module : Servant.Mock -- Copyright : 2015 Alp Mestanogullari @@ -165,7 +166,7 @@ instance (Arbitrary a, AllCTRender ctypes a) => HasMock (Put ctypes a) where mock _ = mockArbitrary instance HasMock Raw where - mock _ = \req respond -> do + mock _ = \_req respond -> do bdy <- genBody respond $ responseLBS status200 [] bdy diff --git a/servant-server/servant-server.cabal b/servant-server/servant-server.cabal index 74a6045e..7a65a12a 100644 --- a/servant-server/servant-server.cabal +++ b/servant-server/servant-server.cabal @@ -91,6 +91,11 @@ test-suite spec default-language: Haskell2010 hs-source-dirs: test main-is: Spec.hs + other-modules: + Servant.Server.ErrorSpec + Servant.Server.Internal.EnterSpec + Servant.ServerSpec + Servant.Utils.StaticFilesSpec build-depends: base == 4.* , aeson diff --git a/servant/servant.cabal b/servant/servant.cabal index 49fa3c3e..301a46d8 100644 --- a/servant/servant.cabal +++ b/servant/servant.cabal @@ -90,6 +90,11 @@ test-suite spec default-language: Haskell2010 hs-source-dirs: test main-is: Spec.hs + other-modules: + Servant.API.ContentTypesSpec + Servant.API.ResponseHeadersSpec + Servant.Common.TextSpec + Servant.Utils.LinksSpec build-depends: base == 4.* , aeson diff --git a/stack.yaml b/stack.yaml index 006f455c..ed418ce5 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,6 +1,8 @@ flags: servant-js: example: false +ghc-options: + "*": -Wall packages: - servant/ - servant-blaze/ From dfc49dd0a05ad5383b8e4d96d47f416ae1ba5b08 Mon Sep 17 00:00:00 2001 From: "Julian K. Arni" Date: Wed, 23 Sep 2015 19:05:27 +0200 Subject: [PATCH 3/7] Further cleanup --- servant-examples/auth-combinator/auth-combinator.hs | 1 - servant-examples/hackage/hackage.hs | 1 - servant-examples/servant-examples.cabal | 4 +++- servant-examples/tutorial/T3.hs | 1 - servant-examples/tutorial/T8.hs | 1 - servant-examples/tutorial/T9.hs | 1 - stack.yaml | 2 -- 7 files changed, 3 insertions(+), 8 deletions(-) diff --git a/servant-examples/auth-combinator/auth-combinator.hs b/servant-examples/auth-combinator/auth-combinator.hs index 26cc0475..c82510f3 100644 --- a/servant-examples/auth-combinator/auth-combinator.hs +++ b/servant-examples/auth-combinator/auth-combinator.hs @@ -5,7 +5,6 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} -{-# OPTIONS_GHC -fno-warn-unused-binds #-} import Data.Aeson import Data.ByteString (ByteString) import Data.Text (Text) diff --git a/servant-examples/hackage/hackage.hs b/servant-examples/hackage/hackage.hs index 685974cc..81d18883 100644 --- a/servant-examples/hackage/hackage.hs +++ b/servant-examples/hackage/hackage.hs @@ -2,7 +2,6 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TypeOperators #-} -{-# OPTIONS_GHC -fno-warn-unused-binds #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} import Control.Applicative import Control.Monad diff --git a/servant-examples/servant-examples.cabal b/servant-examples/servant-examples.cabal index 9c8cfaca..a722cf49 100644 --- a/servant-examples/servant-examples.cabal +++ b/servant-examples/servant-examples.cabal @@ -20,7 +20,7 @@ source-repository head executable tutorial main-is: tutorial.hs other-modules: T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 - ghc-options: -Wall -fno-warn-unused-binds -fno-warn-name-shadowing + ghc-options: -Wall -fno-warn-unused-binds -fno-warn-name-shadowing -fno-warn-orphans -fno-warn-unused-imports build-depends: aeson >= 0.8 , base >= 4.7 && < 5 @@ -89,6 +89,7 @@ executable wai-middleware executable auth-combinator main-is: auth-combinator.hs + ghc-options: -Wall -fno-warn-unused-binds -fno-warn-name-shadowing build-depends: aeson >= 0.8 , base >= 4.7 && < 5 @@ -104,6 +105,7 @@ executable auth-combinator executable socket-io-chat main-is: socket-io-chat.hs + ghc-options: -Wall -fno-warn-unused-binds -fno-warn-name-shadowing other-modules: Chat build-depends: aeson >= 0.8 diff --git a/servant-examples/tutorial/T3.hs b/servant-examples/tutorial/T3.hs index 09c9c2ae..7b5bdeb3 100644 --- a/servant-examples/tutorial/T3.hs +++ b/servant-examples/tutorial/T3.hs @@ -2,7 +2,6 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} -{-# OPTIONS_GHC -fno-warn-unused-binds #-} module T3 where import Control.Monad.Trans.Except diff --git a/servant-examples/tutorial/T8.hs b/servant-examples/tutorial/T8.hs index c0f8b691..68d52467 100644 --- a/servant-examples/tutorial/T8.hs +++ b/servant-examples/tutorial/T8.hs @@ -4,7 +4,6 @@ module T8 where import Control.Monad.Trans.Except -import Data.Aeson import Servant import Servant.Client diff --git a/servant-examples/tutorial/T9.hs b/servant-examples/tutorial/T9.hs index 08545228..365f6e54 100644 --- a/servant-examples/tutorial/T9.hs +++ b/servant-examples/tutorial/T9.hs @@ -13,7 +13,6 @@ import GHC.Generics import Network.Wai import Servant import Servant.JS -import Servant.JS.JQuery import System.Random import qualified Data.Text as T diff --git a/stack.yaml b/stack.yaml index ed418ce5..006f455c 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,8 +1,6 @@ flags: servant-js: example: false -ghc-options: - "*": -Wall packages: - servant/ - servant-blaze/ From 7e3fdd661426207d9b42a849846e03404177d298 Mon Sep 17 00:00:00 2001 From: "Julian K. Arni" Date: Wed, 23 Sep 2015 19:27:25 +0200 Subject: [PATCH 4/7] Use --ghc-options rather than --pendantic. The latter seems to override cabal. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5f82ccd6..890e8d7c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ install: script: - stack setup - - stack build --pedantic + - stack build --ghc-options "-Werror" - stack test cache: From 3c3efda0d5a3c9ea75f6560aa6c66cf6caad1b6d Mon Sep 17 00:00:00 2001 From: "Julian K. Arni" Date: Wed, 23 Sep 2015 19:36:20 +0200 Subject: [PATCH 5/7] Extra file --- servant-server/servant-server.cabal | 1 - 1 file changed, 1 deletion(-) diff --git a/servant-server/servant-server.cabal b/servant-server/servant-server.cabal index 7a65a12a..b44e754b 100644 --- a/servant-server/servant-server.cabal +++ b/servant-server/servant-server.cabal @@ -92,7 +92,6 @@ test-suite spec hs-source-dirs: test main-is: Spec.hs other-modules: - Servant.Server.ErrorSpec Servant.Server.Internal.EnterSpec Servant.ServerSpec Servant.Utils.StaticFilesSpec From 487f323f2f99dd005ebb6f78c4f7f82f881b5593 Mon Sep 17 00:00:00 2001 From: "Julian K. Arni" Date: Wed, 23 Sep 2015 20:30:45 +0200 Subject: [PATCH 6/7] More Werror fixes --- servant-foreign/src/Servant/Foreign.hs | 4 ++-- servant-js/src/Servant/JS/Internal.hs | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/servant-foreign/src/Servant/Foreign.hs b/servant-foreign/src/Servant/Foreign.hs index 555a9146..8599aede 100644 --- a/servant-foreign/src/Servant/Foreign.hs +++ b/servant-foreign/src/Servant/Foreign.hs @@ -4,7 +4,6 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE NullaryTypeClasses #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} @@ -47,7 +46,8 @@ module Servant.Foreign #if !MIN_VERSION_base(4,8,0) import Control.Applicative #endif -import Control.Lens hiding (List) +import Control.Lens (makeLenses, (%~), (&), (.~), + (<>~), _last) import Data.Char (toLower, toUpper) import Data.List import Data.Proxy diff --git a/servant-js/src/Servant/JS/Internal.hs b/servant-js/src/Servant/JS/Internal.hs index 37efda59..a7af966b 100644 --- a/servant-js/src/Servant/JS/Internal.hs +++ b/servant-js/src/Servant/JS/Internal.hs @@ -1,4 +1,3 @@ -<<<<<<< HEAD module Servant.JS.Internal ( JavaScriptGenerator , CommonGeneratorOptions(..) @@ -32,7 +31,7 @@ module Servant.JS.Internal , Header ) where -import Control.Lens hiding (List) +import Control.Lens ((^.)) import qualified Data.CharSet as Set import qualified Data.CharSet.Unicode.Category as Set import Data.List From 4206285e2daedad11c76517bbadcd89b6a8e0a3c Mon Sep 17 00:00:00 2001 From: "Julian K. Arni" Date: Wed, 23 Sep 2015 20:39:46 +0200 Subject: [PATCH 7/7] CPP NullaryTypeClass --- servant-foreign/src/Servant/Foreign.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/servant-foreign/src/Servant/Foreign.hs b/servant-foreign/src/Servant/Foreign.hs index 8599aede..6cd72b84 100644 --- a/servant-foreign/src/Servant/Foreign.hs +++ b/servant-foreign/src/Servant/Foreign.hs @@ -3,6 +3,9 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} +#if !MIN_VERSION_base(4,8,0) +{-# LANGUAGE NullaryTypeClasses #-} +#endif {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TemplateHaskell #-}