git.iko.soy/typeable/servant
on master help sign in
Update hlint.yaml and fix some hints in servant and servant-server
commit22ec980f6e5242c83aac2d32e4e3a0b6e8fcabaa authorOleg Grenrus <oleg.grenrus@iki.fi> dateFri 26 Jan 2018, 17:38 (9 years ago) parent030cbbc
12 files changed+74−24
HLint.hs−6 hlint.yaml+65 servant-server/src/Servant/Server.hs−1 servant-server/src/Servant/Server/Internal.hs+1−1 servant-server/src/Servant/Server/Internal/Handler.hs−1 servant-server/src/Servant/Server/Internal/Router.hs−1 servant-server/src/Servant/Server/Internal/RoutingApplication.hs+2−6 servant/src/Servant/API/ContentTypes.hs+3−3 servant/src/Servant/API/Header.hs−1 servant/src/Servant/API/ResponseHeaders.hs+2−2 servant/src/Servant/API/Stream.hs+1−1 servant/src/Servant/Utils/Enter.hs−1
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 @@
11{-# LANGUAGE ConstraintKinds #-}
22{-# LANGUAGE DataKinds #-}
33{-# LANGUAGE FlexibleContexts #-}
4−{-# LANGUAGE OverloadedStrings #-}
54{-# LANGUAGE RankNTypes #-}
65{-# LANGUAGE TypeFamilies #-}
76
servant-server/src/Servant/Server/Internal.hs+1−1
@@ -326,7 +326,7 @@ streamRouter splitHeaders method framingproxy ctypeproxy action = leafRouter $ \
326326 write . BB.lazyByteString $ header framingproxy ctypeproxy
327327 case boundary framingproxy ctypeproxy of
328328 BoundaryStrategyBracket f ->
329− let go x = let bs = mimeRender ctypeproxy $ x
329+ let go x = let bs = mimeRender ctypeproxy x
330330 (before, after) = f bs
331331 in write ( BB.lazyByteString before
332332 <> BB.lazyByteString bs
servant-server/src/Servant/Server/Internal/Handler.hs−1
@@ -1,5 +1,4 @@
11{-# LANGUAGE CPP #-}
2−{-# LANGUAGE DeriveDataTypeable #-}
32{-# LANGUAGE DeriveGeneric #-}
43{-# LANGUAGE GeneralizedNewtypeDeriving #-}
54{-# LANGUAGE MultiParamTypeClasses #-}
servant-server/src/Servant/Server/Internal/Router.hs−1
@@ -1,7 +1,6 @@
11{-# LANGUAGE DeriveFunctor #-}
22{-# LANGUAGE CPP #-}
33{-# LANGUAGE GADTs #-}
4−{-# LANGUAGE KindSignatures #-}
54{-# LANGUAGE OverloadedStrings #-}
65module Servant.Server.Internal.Router where
76
servant-server/src/Servant/Server/Internal/RoutingApplication.hs+2−6
@@ -3,12 +3,8 @@
33{-# LANGUAGE FlexibleInstances #-}
44{-# LANGUAGE GADTs #-}
55{-# LANGUAGE GeneralizedNewtypeDeriving #-}
6−{-# LANGUAGE KindSignatures #-}
76{-# LANGUAGE MultiParamTypeClasses #-}
8−{-# LANGUAGE OverloadedStrings #-}
97{-# LANGUAGE RecordWildCards #-}
10−{-# LANGUAGE StandaloneDeriving #-}
11−{-# LANGUAGE TupleSections #-}
128{-# LANGUAGE TypeFamilies #-}
139{-# LANGUAGE TypeOperators #-}
1410{-# LANGUAGE UndecidableInstances #-}
@@ -82,7 +78,7 @@ instance MonadBaseControl b m => MonadBaseControl b (RouteResultT m) where
8278
8379instance MonadTransControl RouteResultT where
8480 type StT RouteResultT a = RouteResult a
85− liftWith f = RouteResultT $ liftM return $ f $ runRouteResultT
81+ liftWith f = RouteResultT $ liftM return $ f runRouteResultT
8682 restoreT = RouteResultT
8783
8884instance MonadThrow m => MonadThrow (RouteResultT m) where
@@ -367,7 +363,7 @@ runAction :: Delayed env (Handler a)
367363 -> (RouteResult Response -> IO r)
368364 -> (a -> RouteResult Response)
369365 -> IO r
370−runAction action env req respond k = runResourceT $ do
366+runAction action env req respond k = runResourceT $
371367 runDelayed action env req >>= go >>= liftIO . respond
372368 where
373369 go (Fail e) = return $ Fail e
servant/src/Servant/API/ContentTypes.hs+3−3
@@ -282,7 +282,7 @@ instance OVERLAPPABLE_
282282 , AllMimeRender (ctyp' ': ctyps) a
283283 ) => AllMimeRender (ctyp ': ctyp' ': ctyps) a where
284284 allMimeRender _ a =
285− (map (, bs) $ NE.toList $ contentTypes pctyp)
285+ map (, bs) (NE.toList $ contentTypes pctyp)
286286 ++ allMimeRender pctyps a
287287 where
288288 bs = mimeRender pctyp a
@@ -317,10 +317,10 @@ instance ( MimeUnrender ctyp a
317317 , AllMimeUnrender ctyps a
318318 ) => AllMimeUnrender (ctyp ': ctyps) a where
319319 allMimeUnrender _ =
320− (map mk $ NE.toList $ contentTypes pctyp)
320+ map mk (NE.toList $ contentTypes pctyp)
321321 ++ allMimeUnrender pctyps
322322 where
323− mk ct = (ct, \bs -> mimeUnrenderWithType pctyp ct bs)
323+ mk ct = (ct, mimeUnrenderWithType pctyp ct)
324324 pctyp = Proxy :: Proxy ctyp
325325 pctyps = Proxy :: Proxy ctyps
326326
servant/src/Servant/API/Header.hs−1
@@ -1,6 +1,5 @@
11{-# LANGUAGE DataKinds #-}
22{-# LANGUAGE DeriveDataTypeable #-}
3−{-# LANGUAGE DeriveFunctor #-}
43{-# LANGUAGE PolyKinds #-}
54{-# OPTIONS_HADDOCK not-home #-}
65module Servant.API.Header (
servant/src/Servant/API/ResponseHeaders.hs+2−2
@@ -67,7 +67,7 @@ data HList a where
6767
6868type family HeaderValMap (f :: * -> *) (xs :: [*]) where
6969 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
7171
7272
7373class BuildHeadersTo hs where
@@ -80,7 +80,7 @@ instance OVERLAPPING_ BuildHeadersTo '[] where
8080 buildHeadersTo _ = HNil
8181
8282instance OVERLAPPABLE_ ( FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h )
83− => BuildHeadersTo ((Header h v) ': xs) where
83+ => BuildHeadersTo (Header h v ': xs) where
8484 buildHeadersTo headers =
8585 let wantedHeader = CI.mk . pack $ symbolVal (Proxy :: Proxy h)
8686 matching = snd <$> filter (\(h, _) -> h == wantedHeader) headers
servant/src/Servant/API/Stream.hs+1−1
@@ -40,7 +40,7 @@ instance ToStreamGenerator StreamGenerator a
4040 where toStreamGenerator x = x
4141
4242-- | 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)
4444
4545-- | 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.
4646class BuildFromStream a b where
servant/src/Servant/Utils/Enter.hs−1
@@ -1,5 +1,4 @@
11{-# LANGUAGE CPP #-}
2−{-# LANGUAGE DeriveDataTypeable #-}
32{-# LANGUAGE FlexibleInstances #-}
43{-# LANGUAGE FunctionalDependencies #-}
54{-# LANGUAGE MultiParamTypeClasses #-}