on master help sign in
Fix #654: Remove ANNotations, and some cleanup

- `make lint` is clean with HLint-2.1.18 - HLint.hs -> .hlint.yaml

commitd32d8a84ef66474b3538235890674d94ab14aefe authorOleg Grenrus <oleg.grenrus@iki.fi> dateMon 13 May 2019, 02:48 (7 years ago) parent378ff14
13 files changed+21−33
.hlint.yaml+6 Data/Aeson/Parser/Internal.hs+7−6 Data/Aeson/TH.hs−2 Data/Aeson/Types/Class.hs−1 Data/Aeson/Types/FromJSON.hs−1 Data/Aeson/Types/Generic.hs−1 Data/Aeson/Types/ToJSON.hs−4 HLint.hs−12 benchmarks/Compare/JsonBench.hs+2−2 benchmarks/CompareWithJSON.hs+1−1 benchmarks/JsonParse.hs+1−1 stack-lts12.yaml+1−1 stack-nightly.yaml+3−1
.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 ((<|>))
4141import Control.Monad (void, when)
4242import Data.Aeson.Types.Internal (IResult(..), JSONPath, Result(..), Value(..))
4343import Data.Attoparsec.ByteString.Char8 (Parser, char, decimal, endOfInput, isDigit_w8, signed, string)
44+import Data.Functor.Compat (($>))
4445import Data.Scientific (Scientific)
4546import Data.Text (Text)
4647import Data.Vector as Vector (Vector, empty, fromListN, reverse)
@@ -174,9 +175,9 @@ value = do
174175 DOUBLE_QUOTE -> A.anyWord8 *> (String <$> jstring_)
175176 OPEN_CURLY -> A.anyWord8 *> object_
176177 OPEN_SQUARE -> A.anyWord8 *> array_
177− C_f -> string "false" *> pure (Bool False)
178− C_t -> string "true" *> pure (Bool True)
179− C_n -> string "null" *> pure Null
178+ C_f -> string "false" $> Bool False
179+ C_t -> string "true" $> Bool True
180+ C_n -> string "null" $> Null
180181 _ | w >= 48 && w <= 57 || w == 45
181182 -> Number <$> scientific
182183 | otherwise -> fail "not a valid json value"
@@ -192,9 +193,9 @@ value' = do
192193 return (String s)
193194 OPEN_CURLY -> A.anyWord8 *> object_'
194195 OPEN_SQUARE -> A.anyWord8 *> array_'
195− C_f -> string "false" *> pure (Bool False)
196− C_t -> string "true" *> pure (Bool True)
197− C_n -> string "null" *> pure Null
196+ C_f -> string "false" $> Bool False
197+ C_t -> string "true" $> Bool True
198+ C_n -> string "null" $> Null
198199 _ | w >= 48 && w <= 57 || w == 45
199200 -> do
200201 !n <- scientific
Data/Aeson/TH.hs−2
@@ -159,8 +159,6 @@ import qualified Data.Text as T (Text, pack, unpack)
159159import qualified Data.Vector as V (unsafeIndex, null, length, create, empty)
160160import qualified Data.Vector.Mutable as VM (unsafeNew, unsafeWrite)
161161
162−{-# ANN module "Hlint: ignore Reduce duplication" #-}
163−
164162--------------------------------------------------------------------------------
165163-- Convenience
166164--------------------------------------------------------------------------------
Data/Aeson/Types/Class.hs−1
@@ -6,7 +6,6 @@
66{-# LANGUAGE MultiParamTypeClasses #-}
77{-# LANGUAGE NoImplicitPrelude #-}
88{-# LANGUAGE ScopedTypeVariables #-}
9−{-# LANGUAGE TypeSynonymInstances #-}
109
1110-- |
1211-- Module: Data.Aeson.Types.Class
Data/Aeson/Types/FromJSON.hs−1
@@ -11,7 +11,6 @@
1111{-# LANGUAGE RecordWildCards #-}
1212{-# LANGUAGE ScopedTypeVariables #-}
1313{-# LANGUAGE TypeOperators #-}
14−{-# LANGUAGE TypeSynonymInstances #-}
1514{-# LANGUAGE UndecidableInstances #-}
1615{-# LANGUAGE ViewPatterns #-}
1716
Data/Aeson/Types/Generic.hs−1
@@ -5,7 +5,6 @@
55{-# LANGUAGE FlexibleInstances #-}
66{-# LANGUAGE FunctionalDependencies #-}
77{-# LANGUAGE KindSignatures #-}
8−{-# LANGUAGE MultiParamTypeClasses #-}
98{-# LANGUAGE NoImplicitPrelude #-}
109{-# LANGUAGE ScopedTypeVariables #-}
1110{-# LANGUAGE TypeOperators #-}
Data/Aeson/Types/ToJSON.hs−4
@@ -5,7 +5,6 @@
55{-# LANGUAGE FlexibleInstances #-}
66{-# LANGUAGE FunctionalDependencies #-}
77{-# LANGUAGE GADTs #-}
8−{-# LANGUAGE MultiParamTypeClasses #-}
98{-# LANGUAGE NamedFieldPuns #-}
109{-# LANGUAGE NoImplicitPrelude #-}
1110{-# LANGUAGE OverloadedStrings #-}
@@ -13,7 +12,6 @@
1312{-# LANGUAGE RecordWildCards #-}
1413{-# LANGUAGE ScopedTypeVariables #-}
1514{-# LANGUAGE TypeOperators #-}
16−{-# LANGUAGE TypeSynonymInstances #-}
1715{-# LANGUAGE UndecidableInstances #-}
1816
1917#if __GLASGOW_HASKELL__ >= 706
@@ -147,8 +145,6 @@ import qualified Data.ByteString.Internal as S
147145import qualified Data.ByteString.Lazy.Internal as L
148146#endif
149147
150−{-# ANN module ("HLint: ignore Reduce duplication"::String) #-}
151−
152148toJSONPair :: (a -> Value) -> (b -> Value) -> (a, b) -> Value
153149toJSONPair a b = liftToJSON2 a (listValue a) b (listValue b)
154150{-# 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 !_ = ()
6868instance NFData Fruit where rnf !_ = ()
6969
7070instance NFData Friend where
71− rnf Friend {..} = rnf fId `seq` rnf fName `seq` ()
71+ rnf Friend {..} = rnf fId `seq` rnf fName
7272
7373instance 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
7575
7676eyeColorTable :: [(Text, EyeColor)]
7777eyeColorTable = [("brown", Brown), ("green", Green), ("blue", Blue)]
benchmarks/CompareWithJSON.hs+1−1
@@ -27,7 +27,7 @@ instance (NFData v) => NFData (J.JSObject v) where
2727instance NFData J.JSValue where
2828 rnf J.JSNull = ()
2929 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
3131 rnf (J.JSString s) = rnf (J.fromJSString s)
3232 rnf (J.JSArray lst) = rnf lst
3333 rnf (J.JSObject o) = rnf o
benchmarks/JsonParse.hs+1−1
@@ -17,7 +17,7 @@ import Text.JSON
1717instance NFData JSValue where
1818 rnf JSNull = ()
1919 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
2121 rnf (JSString s) = rnf (fromJSString s)
2222 rnf (JSArray vs) = rnf vs
2323 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
22packages:
33- '.'
44- attoparsec-iso8601
stack-nightly.yaml+3−1
@@ -1,4 +1,4 @@
1−resolver: nightly-2018-09-26
1+resolver: nightly-2019-05-13
22packages:
33- '.'
44- attoparsec-iso8601
@@ -7,3 +7,5 @@ flags:
77 fast: true
88 attoparsec-iso8601:
99 fast: true
10+extra-deps:
11+- hlint-2.1.18