on master help sign in
Update hlint.yaml and fix some hints in servant and servant-server
22ec980Oleg Grenrus
HLint.hsdeleted−6
@@ -1,6 +0,0 @@
1−import "hint" HLint.Default
2−
3−ignore "Redundant do"
4−ignore "Parse error"
5−ignore "Use list comprehension"
6−ignore "Use liftM"
hlint.yamlnew file+65
@@ -0,0 +1,65 @@
1+# HLint configuration file
2+# https://github.com/ndmitchell/hlint
3+##########################
4+
5+# This file contains a template configuration file, which is typically
6+# placed as .hlint.yaml in the root of your project
7+
8+
9+# Specify additional command line arguments
10+#
11+# - arguments: [--color, --cpp-simple, -XQuasiQuotes]
12+
13+
14+# Control which extensions/flags/modules/functions can be used
15+#
16+# - extensions:
17+# - default: false # all extension are banned by default
18+# - name: [PatternGuards, ViewPatterns] # only these listed extensions can be used
19+# - {name: CPP, within: CrossPlatform} # CPP can only be used in a given module
20+#
21+# - flags:
22+# - {name: -w, within: []} # -w is allowed nowhere
23+#
24+# - modules:
25+# - {name: [Data.Set, Data.HashSet], as: Set} # if you import Data.Set qualified, it must be as 'Set'
26+# - {name: Control.Arrow, within: []} # Certain modules are banned entirely
27+#
28+# - functions:
29+# - {name: unsafePerformIO, within: []} # unsafePerformIO can only appear in no modules
30+
31+
32+# Add custom hints for this project
33+#
34+# Will suggest replacing "wibbleMany [myvar]" with "wibbleOne myvar"
35+# - error: {lhs: "wibbleMany [x]", rhs: wibbleOne x}
36+
37+
38+# Turn on hints that are off by default
39+#
40+# Ban "module X(module X) where", to require a real export list
41+# - warn: {name: Use explicit module export list}
42+#
43+# Replace a $ b $ c with a . b $ c
44+# - group: {name: dollar, enabled: true}
45+#
46+# Generalise map to fmap, ++ to <>
47+# - group: {name: generalise, enabled: true}
48+
49+
50+# Ignore some builtin hints
51+- ignore: {name: Redundant do}
52+- ignore: {name: Parse error}
53+- ignore: {name: Use fmap}
54+- ignore: {name: Use list comprehension}
55+- ignore: {name: Use lambda-case}
56+- ignore: {name: Eta reduce}
57+# - ignore: {name: Use const, within: SpecialModule} # Only within certain modules
58+
59+
60+# Define some custom infix operators
61+# - fixity: infixr 3 ~^#^~
62+
63+
64+# To generate a suitable file for HLint do:
65+# $ hlint --default > .hlint.yaml
servant-server/src/Servant/Server.hs−1
@@ -1,7 +1,6 @@
1{-# LANGUAGE ConstraintKinds #-}
1{-# LANGUAGE ConstraintKinds #-}
2{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE DataKinds #-}
3{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE FlexibleContexts #-}
4−{-# LANGUAGE OverloadedStrings #-}
5{-# LANGUAGE RankNTypes #-}
4{-# LANGUAGE RankNTypes #-}
6{-# LANGUAGE TypeFamilies #-}
5{-# LANGUAGE TypeFamilies #-}
7
6
servant-server/src/Servant/Server/Internal.hs+1−1
@@ -326,7 +326,7 @@ streamRouter splitHeaders method framingproxy ctypeproxy action = leafRouter $ \
326 write . BB.lazyByteString $ header framingproxy ctypeproxy
326 write . BB.lazyByteString $ header framingproxy ctypeproxy
327 case boundary framingproxy ctypeproxy of
327 case boundary framingproxy ctypeproxy of
328 BoundaryStrategyBracket f ->
328 BoundaryStrategyBracket f ->
329− let go x = let bs = mimeRender ctypeproxy $ x
329+ let go x = let bs = mimeRender ctypeproxy x
330 (before, after) = f bs
330 (before, after) = f bs
331 in write ( BB.lazyByteString before
331 in write ( BB.lazyByteString before
332 <> BB.lazyByteString bs
332 <> BB.lazyByteString bs
servant-server/src/Servant/Server/Internal/Handler.hs−1
@@ -1,5 +1,4 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2−{-# LANGUAGE DeriveDataTypeable #-}
3{-# LANGUAGE DeriveGeneric #-}
2{-# LANGUAGE DeriveGeneric #-}
4{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5{-# LANGUAGE MultiParamTypeClasses #-}
4{-# LANGUAGE MultiParamTypeClasses #-}
servant-server/src/Servant/Server/Internal/Router.hs−1
@@ -1,7 +1,6 @@
1{-# LANGUAGE DeriveFunctor #-}
1{-# LANGUAGE DeriveFunctor #-}
2{-# LANGUAGE CPP #-}
2{-# LANGUAGE CPP #-}
3{-# LANGUAGE GADTs #-}
3{-# LANGUAGE GADTs #-}
4−{-# LANGUAGE KindSignatures #-}
5{-# LANGUAGE OverloadedStrings #-}
4{-# LANGUAGE OverloadedStrings #-}
6module Servant.Server.Internal.Router where
5module Servant.Server.Internal.Router where
7
6
servant-server/src/Servant/Server/Internal/RoutingApplication.hs+2−6
@@ -3,12 +3,8 @@
3{-# LANGUAGE FlexibleInstances #-}
3{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE GADTs #-}
4{-# LANGUAGE GADTs #-}
5{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5{-# LANGUAGE GeneralizedNewtypeDeriving #-}
6−{-# LANGUAGE KindSignatures #-}
7{-# LANGUAGE MultiParamTypeClasses #-}
6{-# LANGUAGE MultiParamTypeClasses #-}
8−{-# LANGUAGE OverloadedStrings #-}
9{-# LANGUAGE RecordWildCards #-}
7{-# LANGUAGE RecordWildCards #-}
10−{-# LANGUAGE StandaloneDeriving #-}
11−{-# LANGUAGE TupleSections #-}
12{-# LANGUAGE TypeFamilies #-}
8{-# LANGUAGE TypeFamilies #-}
13{-# LANGUAGE TypeOperators #-}
9{-# LANGUAGE TypeOperators #-}
14{-# LANGUAGE UndecidableInstances #-}
10{-# LANGUAGE UndecidableInstances #-}
@@ -82,7 +78,7 @@ instance MonadBaseControl b m => MonadBaseControl b (RouteResultT m) where
82
78
83instance MonadTransControl RouteResultT where
79instance MonadTransControl RouteResultT where
84 type StT RouteResultT a = RouteResult a
80 type StT RouteResultT a = RouteResult a
85− liftWith f = RouteResultT $ liftM return $ f $ runRouteResultT
81+ liftWith f = RouteResultT $ liftM return $ f runRouteResultT
86 restoreT = RouteResultT
82 restoreT = RouteResultT
87
83
88instance MonadThrow m => MonadThrow (RouteResultT m) where
84instance MonadThrow m => MonadThrow (RouteResultT m) where
@@ -367,7 +363,7 @@ runAction :: Delayed env (Handler a)
367 -> (RouteResult Response -> IO r)
363 -> (RouteResult Response -> IO r)
368 -> (a -> RouteResult Response)
364 -> (a -> RouteResult Response)
369 -> IO r
365 -> IO r
370−runAction action env req respond k = runResourceT $ do
366+runAction action env req respond k = runResourceT $
371 runDelayed action env req >>= go >>= liftIO . respond
367 runDelayed action env req >>= go >>= liftIO . respond
372 where
368 where
373 go (Fail e) = return $ Fail e
369 go (Fail e) = return $ Fail e
servant/src/Servant/API/ContentTypes.hs+3−3
@@ -282,7 +282,7 @@ instance OVERLAPPABLE_
282 , AllMimeRender (ctyp' ': ctyps) a
282 , AllMimeRender (ctyp' ': ctyps) a
283 ) => AllMimeRender (ctyp ': ctyp' ': ctyps) a where
283 ) => AllMimeRender (ctyp ': ctyp' ': ctyps) a where
284 allMimeRender _ a =
284 allMimeRender _ a =
285− (map (, bs) $ NE.toList $ contentTypes pctyp)
285+ map (, bs) (NE.toList $ contentTypes pctyp)
286 ++ allMimeRender pctyps a
286 ++ allMimeRender pctyps a
287 where
287 where
288 bs = mimeRender pctyp a
288 bs = mimeRender pctyp a
@@ -317,10 +317,10 @@ instance ( MimeUnrender ctyp a
317 , AllMimeUnrender ctyps a
317 , AllMimeUnrender ctyps a
318 ) => AllMimeUnrender (ctyp ': ctyps) a where
318 ) => AllMimeUnrender (ctyp ': ctyps) a where
319 allMimeUnrender _ =
319 allMimeUnrender _ =
320− (map mk $ NE.toList $ contentTypes pctyp)
320+ map mk (NE.toList $ contentTypes pctyp)
321 ++ allMimeUnrender pctyps
321 ++ allMimeUnrender pctyps
322 where
322 where
323− mk ct = (ct, \bs -> mimeUnrenderWithType pctyp ct bs)
323+ mk ct = (ct, mimeUnrenderWithType pctyp ct)
324 pctyp = Proxy :: Proxy ctyp
324 pctyp = Proxy :: Proxy ctyp
325 pctyps = Proxy :: Proxy ctyps
325 pctyps = Proxy :: Proxy ctyps
326
326
servant/src/Servant/API/Header.hs−1
@@ -1,6 +1,5 @@
1{-# LANGUAGE DataKinds #-}
1{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE DeriveDataTypeable #-}
2{-# LANGUAGE DeriveDataTypeable #-}
3−{-# LANGUAGE DeriveFunctor #-}
4{-# LANGUAGE PolyKinds #-}
3{-# LANGUAGE PolyKinds #-}
5{-# OPTIONS_HADDOCK not-home #-}
4{-# OPTIONS_HADDOCK not-home #-}
6module Servant.API.Header (
5module Servant.API.Header (
servant/src/Servant/API/ResponseHeaders.hs+2−2
@@ -67,7 +67,7 @@ data HList a where
67
67
68type family HeaderValMap (f :: * -> *) (xs :: [*]) where
68type family HeaderValMap (f :: * -> *) (xs :: [*]) where
69 HeaderValMap f '[] = '[]
69 HeaderValMap f '[] = '[]
70− HeaderValMap f (Header h x ': xs) = Header h (f x) ': (HeaderValMap f xs)
70+ HeaderValMap f (Header h x ': xs) = Header h (f x) ': HeaderValMap f xs
71
71
72
72
73class BuildHeadersTo hs where
73class BuildHeadersTo hs where
@@ -80,7 +80,7 @@ instance OVERLAPPING_ BuildHeadersTo '[] where
80 buildHeadersTo _ = HNil
80 buildHeadersTo _ = HNil
81
81
82instance OVERLAPPABLE_ ( FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h )
82instance OVERLAPPABLE_ ( FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h )
83− => BuildHeadersTo ((Header h v) ': xs) where
83+ => BuildHeadersTo (Header h v ': xs) where
84 buildHeadersTo headers =
84 buildHeadersTo headers =
85 let wantedHeader = CI.mk . pack $ symbolVal (Proxy :: Proxy h)
85 let wantedHeader = CI.mk . pack $ symbolVal (Proxy :: Proxy h)
86 matching = snd <$> filter (\(h, _) -> h == wantedHeader) headers
86 matching = snd <$> filter (\(h, _) -> h == wantedHeader) headers
servant/src/Servant/API/Stream.hs+1−1
@@ -40,7 +40,7 @@ instance ToStreamGenerator StreamGenerator a
40 where toStreamGenerator x = x
40 where toStreamGenerator x = x
41
41
42-- | Clients reading from streaming endpoints can be implemented as producing a @ResultStream@ that captures the setup, takedown, and incremental logic for a read, being an IO continuation that takes a producer of Just either values or errors that terminates with a Nothing.
42-- | Clients reading from streaming endpoints can be implemented as producing a @ResultStream@ that captures the setup, takedown, and incremental logic for a read, being an IO continuation that takes a producer of Just either values or errors that terminates with a Nothing.
43−data ResultStream a = ResultStream ((forall b. (IO (Maybe (Either String a)) -> IO b) -> IO b))
43+newtype ResultStream a = ResultStream (forall b. (IO (Maybe (Either String a)) -> IO b) -> IO b)
44
44
45-- | BuildFromStream is intended to be implemented for types such as Conduit, Pipe, etc. By implementing this class, all such streaming abstractions can be used directly on the client side for talking to streaming endpoints.
45-- | BuildFromStream is intended to be implemented for types such as Conduit, Pipe, etc. By implementing this class, all such streaming abstractions can be used directly on the client side for talking to streaming endpoints.
46class BuildFromStream a b where
46class BuildFromStream a b where
servant/src/Servant/Utils/Enter.hs−1
@@ -1,5 +1,4 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE CPP #-}
2−{-# LANGUAGE DeriveDataTypeable #-}
3{-# LANGUAGE FlexibleInstances #-}
2{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE FunctionalDependencies #-}
3{-# LANGUAGE FunctionalDependencies #-}
5{-# LANGUAGE MultiParamTypeClasses #-}
4{-# LANGUAGE MultiParamTypeClasses #-}