on master help sign in
Merge pull request #699 from phadej/issue-654
2a3fd22Adam Bergmark
.hlint.yamlnew file+6
@@ -0,0 +1,6 @@
1+# Ignore some builtin hints
2+- ignore:
3+ name: "Reduce duplication"
4+ within:
5+ - Data.Aeson.Types.ToJSON
6+- ignore: {name: "Eta reduce" }
Data/Aeson/Parser/Internal.hs+7−6
@@ -41,6 +41,7 @@ import Control.Applicative ((<|>))
41import Control.Monad (void, when)
41import Control.Monad (void, when)
42import Data.Aeson.Types.Internal (IResult(..), JSONPath, Result(..), Value(..))
42import Data.Aeson.Types.Internal (IResult(..), JSONPath, Result(..), Value(..))
43import Data.Attoparsec.ByteString.Char8 (Parser, char, decimal, endOfInput, isDigit_w8, signed, string)
43import Data.Attoparsec.ByteString.Char8 (Parser, char, decimal, endOfInput, isDigit_w8, signed, string)
44+import Data.Functor.Compat (($>))
44import Data.Scientific (Scientific)
45import Data.Scientific (Scientific)
45import Data.Text (Text)
46import Data.Text (Text)
46import Data.Vector as Vector (Vector, empty, fromListN, reverse)
47import Data.Vector as Vector (Vector, empty, fromListN, reverse)
@@ -174,9 +175,9 @@ value = do
174 DOUBLE_QUOTE -> A.anyWord8 *> (String <$> jstring_)
175 DOUBLE_QUOTE -> A.anyWord8 *> (String <$> jstring_)
175 OPEN_CURLY -> A.anyWord8 *> object_
176 OPEN_CURLY -> A.anyWord8 *> object_
176 OPEN_SQUARE -> A.anyWord8 *> array_
177 OPEN_SQUARE -> A.anyWord8 *> array_
177− C_f -> string "false" *> pure (Bool False)
178+ C_f -> string "false" $> Bool False
178− C_t -> string "true" *> pure (Bool True)
179+ C_t -> string "true" $> Bool True
179− C_n -> string "null" *> pure Null
180+ C_n -> string "null" $> Null
180 _ | w >= 48 && w <= 57 || w == 45
181 _ | w >= 48 && w <= 57 || w == 45
181 -> Number <$> scientific
182 -> Number <$> scientific
182 | otherwise -> fail "not a valid json value"
183 | otherwise -> fail "not a valid json value"
@@ -192,9 +193,9 @@ value' = do
192 return (String s)
193 return (String s)
193 OPEN_CURLY -> A.anyWord8 *> object_'
194 OPEN_CURLY -> A.anyWord8 *> object_'
194 OPEN_SQUARE -> A.anyWord8 *> array_'
195 OPEN_SQUARE -> A.anyWord8 *> array_'
195− C_f -> string "false" *> pure (Bool False)
196+ C_f -> string "false" $> Bool False
196− C_t -> string "true" *> pure (Bool True)
197+ C_t -> string "true" $> Bool True
197− C_n -> string "null" *> pure Null
198+ C_n -> string "null" $> Null
198 _ | w >= 48 && w <= 57 || w == 45
199 _ | w >= 48 && w <= 57 || w == 45
199 -> do
200 -> do
200 !n <- scientific
201 !n <- scientific
Data/Aeson/TH.hs−2
@@ -159,8 +159,6 @@ import qualified Data.Text as T (Text, pack, unpack)
159import qualified Data.Vector as V (unsafeIndex, null, length, create, empty)
159import qualified Data.Vector as V (unsafeIndex, null, length, create, empty)
160import qualified Data.Vector.Mutable as VM (unsafeNew, unsafeWrite)
160import qualified Data.Vector.Mutable as VM (unsafeNew, unsafeWrite)
161
161
162−{-# ANN module "Hlint: ignore Reduce duplication" #-}
163−
164--------------------------------------------------------------------------------
162--------------------------------------------------------------------------------
165-- Convenience
163-- Convenience
166--------------------------------------------------------------------------------
164--------------------------------------------------------------------------------
Data/Aeson/Types/Class.hs−1
@@ -6,7 +6,6 @@
6{-# LANGUAGE MultiParamTypeClasses #-}
6{-# LANGUAGE MultiParamTypeClasses #-}
7{-# LANGUAGE NoImplicitPrelude #-}
7{-# LANGUAGE NoImplicitPrelude #-}
8{-# LANGUAGE ScopedTypeVariables #-}
8{-# LANGUAGE ScopedTypeVariables #-}
9−{-# LANGUAGE TypeSynonymInstances #-}
10
9
11-- |
10-- |
12-- Module: Data.Aeson.Types.Class
11-- Module: Data.Aeson.Types.Class
Data/Aeson/Types/FromJSON.hs−1
@@ -11,7 +11,6 @@
11{-# LANGUAGE RecordWildCards #-}
11{-# LANGUAGE RecordWildCards #-}
12{-# LANGUAGE ScopedTypeVariables #-}
12{-# LANGUAGE ScopedTypeVariables #-}
13{-# LANGUAGE TypeOperators #-}
13{-# LANGUAGE TypeOperators #-}
14−{-# LANGUAGE TypeSynonymInstances #-}
15{-# LANGUAGE UndecidableInstances #-}
14{-# LANGUAGE UndecidableInstances #-}
16{-# LANGUAGE ViewPatterns #-}
15{-# LANGUAGE ViewPatterns #-}
17
16
Data/Aeson/Types/Generic.hs−1
@@ -5,7 +5,6 @@
5{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE FlexibleInstances #-}
6{-# LANGUAGE FunctionalDependencies #-}
6{-# LANGUAGE FunctionalDependencies #-}
7{-# LANGUAGE KindSignatures #-}
7{-# LANGUAGE KindSignatures #-}
8−{-# LANGUAGE MultiParamTypeClasses #-}
9{-# LANGUAGE NoImplicitPrelude #-}
8{-# LANGUAGE NoImplicitPrelude #-}
10{-# LANGUAGE ScopedTypeVariables #-}
9{-# LANGUAGE ScopedTypeVariables #-}
11{-# LANGUAGE TypeOperators #-}
10{-# LANGUAGE TypeOperators #-}
Data/Aeson/Types/ToJSON.hs−4
@@ -5,7 +5,6 @@
5{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE FlexibleInstances #-}
6{-# LANGUAGE FunctionalDependencies #-}
6{-# LANGUAGE FunctionalDependencies #-}
7{-# LANGUAGE GADTs #-}
7{-# LANGUAGE GADTs #-}
8−{-# LANGUAGE MultiParamTypeClasses #-}
9{-# LANGUAGE NamedFieldPuns #-}
8{-# LANGUAGE NamedFieldPuns #-}
10{-# LANGUAGE NoImplicitPrelude #-}
9{-# LANGUAGE NoImplicitPrelude #-}
11{-# LANGUAGE OverloadedStrings #-}
10{-# LANGUAGE OverloadedStrings #-}
@@ -13,7 +12,6 @@
13{-# LANGUAGE RecordWildCards #-}
12{-# LANGUAGE RecordWildCards #-}
14{-# LANGUAGE ScopedTypeVariables #-}
13{-# LANGUAGE ScopedTypeVariables #-}
15{-# LANGUAGE TypeOperators #-}
14{-# LANGUAGE TypeOperators #-}
16−{-# LANGUAGE TypeSynonymInstances #-}
17{-# LANGUAGE UndecidableInstances #-}
15{-# LANGUAGE UndecidableInstances #-}
18
16
19#if __GLASGOW_HASKELL__ >= 706
17#if __GLASGOW_HASKELL__ >= 706
@@ -147,8 +145,6 @@ import qualified Data.ByteString.Internal as S
147import qualified Data.ByteString.Lazy.Internal as L
145import qualified Data.ByteString.Lazy.Internal as L
148#endif
146#endif
149
147
150−{-# ANN module ("HLint: ignore Reduce duplication"::String) #-}
151−
152toJSONPair :: (a -> Value) -> (b -> Value) -> (a, b) -> Value
148toJSONPair :: (a -> Value) -> (b -> Value) -> (a, b) -> Value
153toJSONPair a b = liftToJSON2 a (listValue a) b (listValue b)
149toJSONPair a b = liftToJSON2 a (listValue a) b (listValue b)
154{-# INLINE toJSONPair #-}
150{-# INLINE toJSONPair #-}
HLint.hsdeleted−12
@@ -1,12 +0,0 @@
1−module HLint.HLint where
2−
3−import "hint" HLint.Default
4−import "hint" HLint.Builtin.All
5−import "hint" HLint.Dollar
6−
7−ignore "Avoid lambda"
8−ignore "Eta reduce"
9−ignore "Functor law"
10−ignore "Use >=>"
11−ignore "Use lambda-case"
12−ignore "Use $>"
benchmarks/Compare/JsonBench.hs+2−2
@@ -68,10 +68,10 @@ instance NFData Gender where rnf !_ = ()
68instance NFData Fruit where rnf !_ = ()
68instance NFData Fruit where rnf !_ = ()
69
69
70instance NFData Friend where
70instance NFData Friend where
71− rnf Friend {..} = rnf fId `seq` rnf fName `seq` ()
71+ rnf Friend {..} = rnf fId `seq` rnf fName
72
72
73instance NFData User where
73instance NFData User where
74− rnf User {..} = rnf uId `seq` rnf uIndex `seq` rnf uGuid `seq` rnf uIsActive `seq` rnf uBalance `seq` rnf uPicture `seq` rnf uAge `seq` rnf uEyeColor `seq` rnf uName `seq` rnf uGender `seq` rnf uCompany `seq` rnf uEmail `seq` rnf uPhone `seq` rnf uAddress `seq` rnf uAbout `seq` rnf uRegistered `seq` rnf uLatitude `seq` rnf uLongitude `seq` rnf uTags `seq` rnf uFriends `seq` rnf uGreeting `seq` rnf uFavouriteFruit `seq` ()
74+ rnf User {..} = rnf uId `seq` rnf uIndex `seq` rnf uGuid `seq` rnf uIsActive `seq` rnf uBalance `seq` rnf uPicture `seq` rnf uAge `seq` rnf uEyeColor `seq` rnf uName `seq` rnf uGender `seq` rnf uCompany `seq` rnf uEmail `seq` rnf uPhone `seq` rnf uAddress `seq` rnf uAbout `seq` rnf uRegistered `seq` rnf uLatitude `seq` rnf uLongitude `seq` rnf uTags `seq` rnf uFriends `seq` rnf uGreeting `seq` rnf uFavouriteFruit
75
75
76eyeColorTable :: [(Text, EyeColor)]
76eyeColorTable :: [(Text, EyeColor)]
77eyeColorTable = [("brown", Brown), ("green", Green), ("blue", Blue)]
77eyeColorTable = [("brown", Brown), ("green", Green), ("blue", Blue)]
benchmarks/CompareWithJSON.hs+1−1
@@ -27,7 +27,7 @@ instance (NFData v) => NFData (J.JSObject v) where
27instance NFData J.JSValue where
27instance NFData J.JSValue where
28 rnf J.JSNull = ()
28 rnf J.JSNull = ()
29 rnf (J.JSBool b) = rnf b
29 rnf (J.JSBool b) = rnf b
30− rnf (J.JSRational a b) = rnf a `seq` rnf b `seq` ()
30+ rnf (J.JSRational a b) = rnf a `seq` rnf b
31 rnf (J.JSString s) = rnf (J.fromJSString s)
31 rnf (J.JSString s) = rnf (J.fromJSString s)
32 rnf (J.JSArray lst) = rnf lst
32 rnf (J.JSArray lst) = rnf lst
33 rnf (J.JSObject o) = rnf o
33 rnf (J.JSObject o) = rnf o
benchmarks/JsonParse.hs+1−1
@@ -17,7 +17,7 @@ import Text.JSON
17instance NFData JSValue where
17instance NFData JSValue where
18 rnf JSNull = ()
18 rnf JSNull = ()
19 rnf (JSBool b) = rnf b
19 rnf (JSBool b) = rnf b
20− rnf (JSRational b r) = rnf b `seq` rnf r `seq` ()
20+ rnf (JSRational b r) = rnf b `seq` rnf r
21 rnf (JSString s) = rnf (fromJSString s)
21 rnf (JSString s) = rnf (fromJSString s)
22 rnf (JSArray vs) = rnf vs
22 rnf (JSArray vs) = rnf vs
23 rnf (JSObject kvs) = rnf (fromJSObject kvs)
23 rnf (JSObject kvs) = rnf (fromJSObject kvs)
stack-lts12.yaml+1−1
@@ -1,4 +1,4 @@
1−resolver: lts-12.10
1+resolver: lts-12.26
2packages:
2packages:
3- '.'
3- '.'
4- attoparsec-iso8601
4- attoparsec-iso8601
stack-nightly.yaml+3−1
@@ -1,4 +1,4 @@
1−resolver: nightly-2018-09-26
1+resolver: nightly-2019-05-13
2packages:
2packages:
3- '.'
3- '.'
4- attoparsec-iso8601
4- attoparsec-iso8601
@@ -7,3 +7,5 @@ flags:
7 fast: true
7 fast: true
8 attoparsec-iso8601:
8 attoparsec-iso8601:
9 fast: true
9 fast: true
10+extra-deps:
11+- hlint-2.1.18