Skip to content

Commit 8cab121

Browse files
authored
Merge pull request #896 from phadej/hlint
Update hlint.yaml and fix some hints in servant and servant-server
2 parents 030cbbc + 22ec980 commit 8cab121

File tree

12 files changed

+74
-24
lines changed

12 files changed

+74
-24
lines changed

HLint.hs

Lines changed: 0 additions & 6 deletions
This file was deleted.

hlint.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{-# LANGUAGE DeriveFunctor #-}
22
{-# LANGUAGE CPP #-}
33
{-# LANGUAGE GADTs #-}
4-
{-# LANGUAGE KindSignatures #-}
54
{-# LANGUAGE OverloadedStrings #-}
65
module Servant.Server.Internal.Router where
76

servant-server/src/Servant/Server/Internal/RoutingApplication.hs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

8379
instance 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

8884
instance 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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE DataKinds #-}
22
{-# LANGUAGE DeriveDataTypeable #-}
3-
{-# LANGUAGE DeriveFunctor #-}
43
{-# LANGUAGE PolyKinds #-}
54
{-# OPTIONS_HADDOCK not-home #-}
65
module Servant.API.Header (

servant/src/Servant/API/ResponseHeaders.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ data HList a where
6767

6868
type 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

7373
class BuildHeadersTo hs where
@@ -80,7 +80,7 @@ instance OVERLAPPING_ BuildHeadersTo '[] where
8080
buildHeadersTo _ = HNil
8181

8282
instance 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

0 commit comments

Comments
 (0)