Skip to content

Commit

Permalink
Fix haskell#654: Remove ANNotations, and some cleanup
Browse files Browse the repository at this point in the history
- `make lint` is clean with HLint-2.1.18
- HLint.hs -> .hlint.yaml
  • Loading branch information
phadej committed May 14, 2019
1 parent 378ff14 commit d32d8a8
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 33 deletions.
6 changes: 6 additions & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Ignore some builtin hints
- ignore:
name: "Reduce duplication"
within:
- Data.Aeson.Types.ToJSON
- ignore: {name: "Eta reduce" }
13 changes: 7 additions & 6 deletions Data/Aeson/Parser/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import Control.Applicative ((<|>))
import Control.Monad (void, when)
import Data.Aeson.Types.Internal (IResult(..), JSONPath, Result(..), Value(..))
import Data.Attoparsec.ByteString.Char8 (Parser, char, decimal, endOfInput, isDigit_w8, signed, string)
import Data.Functor.Compat (($>))
import Data.Scientific (Scientific)
import Data.Text (Text)
import Data.Vector as Vector (Vector, empty, fromListN, reverse)
Expand Down Expand Up @@ -174,9 +175,9 @@ value = do
DOUBLE_QUOTE -> A.anyWord8 *> (String <$> jstring_)
OPEN_CURLY -> A.anyWord8 *> object_
OPEN_SQUARE -> A.anyWord8 *> array_
C_f -> string "false" *> pure (Bool False)
C_t -> string "true" *> pure (Bool True)
C_n -> string "null" *> pure Null
C_f -> string "false" $> Bool False
C_t -> string "true" $> Bool True
C_n -> string "null" $> Null
_ | w >= 48 && w <= 57 || w == 45
-> Number <$> scientific
| otherwise -> fail "not a valid json value"
Expand All @@ -192,9 +193,9 @@ value' = do
return (String s)
OPEN_CURLY -> A.anyWord8 *> object_'
OPEN_SQUARE -> A.anyWord8 *> array_'
C_f -> string "false" *> pure (Bool False)
C_t -> string "true" *> pure (Bool True)
C_n -> string "null" *> pure Null
C_f -> string "false" $> Bool False
C_t -> string "true" $> Bool True
C_n -> string "null" $> Null
_ | w >= 48 && w <= 57 || w == 45
-> do
!n <- scientific
Expand Down
2 changes: 0 additions & 2 deletions Data/Aeson/TH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ import qualified Data.Text as T (Text, pack, unpack)
import qualified Data.Vector as V (unsafeIndex, null, length, create, empty)
import qualified Data.Vector.Mutable as VM (unsafeNew, unsafeWrite)

{-# ANN module "Hlint: ignore Reduce duplication" #-}

--------------------------------------------------------------------------------
-- Convenience
--------------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion Data/Aeson/Types/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeSynonymInstances #-}

-- |
-- Module: Data.Aeson.Types.Class
Expand Down
1 change: 0 additions & 1 deletion Data/Aeson/Types/FromJSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ViewPatterns #-}

Expand Down
1 change: 0 additions & 1 deletion Data/Aeson/Types/Generic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
Expand Down
4 changes: 0 additions & 4 deletions Data/Aeson/Types/ToJSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE UndecidableInstances #-}

#if __GLASGOW_HASKELL__ >= 706
Expand Down Expand Up @@ -147,8 +145,6 @@ import qualified Data.ByteString.Internal as S
import qualified Data.ByteString.Lazy.Internal as L
#endif

{-# ANN module ("HLint: ignore Reduce duplication"::String) #-}

toJSONPair :: (a -> Value) -> (b -> Value) -> (a, b) -> Value
toJSONPair a b = liftToJSON2 a (listValue a) b (listValue b)
{-# INLINE toJSONPair #-}
Expand Down
12 changes: 0 additions & 12 deletions HLint.hs

This file was deleted.

4 changes: 2 additions & 2 deletions benchmarks/Compare/JsonBench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ instance NFData Gender where rnf !_ = ()
instance NFData Fruit where rnf !_ = ()

instance NFData Friend where
rnf Friend {..} = rnf fId `seq` rnf fName `seq` ()
rnf Friend {..} = rnf fId `seq` rnf fName

instance NFData User where
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` ()
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

eyeColorTable :: [(Text, EyeColor)]
eyeColorTable = [("brown", Brown), ("green", Green), ("blue", Blue)]
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/CompareWithJSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ instance (NFData v) => NFData (J.JSObject v) where
instance NFData J.JSValue where
rnf J.JSNull = ()
rnf (J.JSBool b) = rnf b
rnf (J.JSRational a b) = rnf a `seq` rnf b `seq` ()
rnf (J.JSRational a b) = rnf a `seq` rnf b
rnf (J.JSString s) = rnf (J.fromJSString s)
rnf (J.JSArray lst) = rnf lst
rnf (J.JSObject o) = rnf o
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/JsonParse.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Text.JSON
instance NFData JSValue where
rnf JSNull = ()
rnf (JSBool b) = rnf b
rnf (JSRational b r) = rnf b `seq` rnf r `seq` ()
rnf (JSRational b r) = rnf b `seq` rnf r
rnf (JSString s) = rnf (fromJSString s)
rnf (JSArray vs) = rnf vs
rnf (JSObject kvs) = rnf (fromJSObject kvs)
Expand Down
2 changes: 1 addition & 1 deletion stack-lts12.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-12.10
resolver: lts-12.26
packages:
- '.'
- attoparsec-iso8601
Expand Down
4 changes: 3 additions & 1 deletion stack-nightly.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: nightly-2018-09-26
resolver: nightly-2019-05-13
packages:
- '.'
- attoparsec-iso8601
Expand All @@ -7,3 +7,5 @@ flags:
fast: true
attoparsec-iso8601:
fast: true
extra-deps:
- hlint-2.1.18

0 comments on commit d32d8a8

Please sign in to comment.