Skip to content

Commit

Permalink
Enable Redundant $ hint for HLint.
Browse files Browse the repository at this point in the history
  • Loading branch information
chungyc committed Oct 5, 2024
1 parent 3e4dbbf commit 5f0ba96
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 21 deletions.
1 change: 0 additions & 1 deletion .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
- ignore: {name: "Eta reduce"} # 1 hint
- ignore: {name: "Fuse foldr/map"} # 1 hint
- ignore: {name: "Move brackets to avoid $"} # 8 hints
- ignore: {name: "Redundant $"} # 23 hints
- ignore: {name: "Redundant ^."} # 2 hints
- ignore: {name: "Redundant bracket"} # 13 hints
- ignore: {name: "Unused LANGUAGE pragma"} # 11 hints
Expand Down
2 changes: 1 addition & 1 deletion discrimination-ieee754/test/test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ nansTestGroup
, Arbitrary b, FiniteBits b, Ord b, Show b
)
=> Sort a -> (a -> b) -> (Bool -> b -> a) -> (b -> b) -> Test
nansTestGroup s toWord makeNaN makePayload = testGroup "NaNs" $
nansTestGroup s toWord makeNaN makePayload = testGroup "NaNs"
[ testProperty "-NaN < everything" $ \x payload ->
sortCompare s (makeNaN True payload) x == LT
, testProperty "-NaN < -Infinity" $ \payload ->
Expand Down
4 changes: 2 additions & 2 deletions proto-lens-protoc/app/Data/ProtoLens/Compiler/Generate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ generateEnumDecls info =
-- instance Data.ProtoLens.FieldDefault Foo where
-- fieldDefault = FirstEnumValue
, instance' (var "Data.ProtoLens.FieldDefault" @@ dataType)
[valBind "fieldDefault" $ defaultCon]
[valBind "fieldDefault" defaultCon]

-- instance NFData Foo where
-- rnf x__ = seq x__ ()
Expand Down Expand Up @@ -953,7 +953,7 @@ messageInstance env protoName m =
, funBind "packedMessageDescriptor" $ match [wildP] $ string msgDescriptor
, funBind "packedFileDescriptor" $ match [wildP] $ var "packedFileDescriptor"
, valBind "fieldsByTag" $
let' (map (fieldDescriptorVarBind $ messageName m) $ fields)
let' (map (fieldDescriptorVarBind $ messageName m) fields)
$ var "Data.Map.fromList" @@ list fieldsByTag
, valBind "unknownFields"
$ rawFieldAccessor (unqual $ messageUnknownFields m)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ data CommentedModule = CommentedModule

getModuleName :: CommentedModule -> ModuleName
getModuleName m =
fromMaybe (error $ "getModuleName: No explicit name")
fromMaybe (error "getModuleName: No explicit name")
$ fmap unLoc $ hsmodName $ moduleHeader m

instance Outputable CommentedModule where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ checkMissingFields s =
in if null missing then return ()
else fail ("Missing required fields: " ++ show missing)
-}
let' [valBind missing $ allMissingFields]
let' [valBind missing allMissingFields]
$ if' (var "Prelude.null" @@ var missing) (var "Prelude.return" @@ unit)
$ var "Prelude.fail"
@@ (var "Prelude.++"
Expand Down Expand Up @@ -497,7 +497,7 @@ buildPlainField x f = case plainFieldKind f of
, match [conP "Prelude.Just" [v']]
$ buildTaggedField info v'
]
OptionalValueField -> let' [valBind v $ fieldValue]
OptionalValueField -> let' [valBind v fieldValue]
$ if' (var "Prelude.==" @@ v' @@ var "Data.ProtoLens.fieldDefault")
mempty'
(buildTaggedField info v')
Expand Down
3 changes: 1 addition & 2 deletions proto-lens-protoc/src/Data/ProtoLens/Compiler/ModuleName.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ protoModuleName path = fixModuleName rawModuleName
fixModuleName (c:cs) = c : fixModuleName cs
rawModuleName = intercalate "."
. (prefix :)
. splitDirectories $ dropExtension
$ path
. splitDirectories $ dropExtension path

prefix :: String
prefix = "Proto"
4 changes: 2 additions & 2 deletions proto-lens-tests/src/Data/ProtoLens/TestUtil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ roundTripTest name = TypedTest $ testGroup name
[ testProperty "shrink sanity" $
-- Disable automatic shrinking so the test behaves
-- sensibly if there's a bug in shrinkMessage.
noShrinking $
noShrinking (
#if MIN_VERSION_QuickCheck(2,10,0)
-- Limit the number of tests since shrinking is slow for large messages.
withMaxSuccess 20
#endif
(shrinkSanityProperty :: MessageProperty a)
(shrinkSanityProperty :: MessageProperty a))
, testProperty "wire" (wireRoundTripProperty :: MessageProperty a)
, testProperty "text" (textRoundTripProperty :: MessageProperty a)
]
Expand Down
10 changes: 5 additions & 5 deletions proto-lens-tests/tests/message_set_test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ main = testMain
, testMessageSetSerialization "with extension"
(defMessage @Foo & unknownFields .~
[ TaggedValue 10 (Wire.Lengthy $ encodeMessage $ defMessage @Bar & bar .~ "hello") ])
(mconcat [tagged 1 $ GroupStart, tagged 2 $ VarInt 10, tagged 3 $ Lengthy (tagged 1 $ Lengthy "hello"), tagged 1 $ GroupEnd])
(mconcat [tagged 1 GroupStart, tagged 2 $ VarInt 10, tagged 3 $ Lengthy (tagged 1 $ Lengthy "hello"), tagged 1 GroupEnd])
, testMessageSetSerialization "with multiple extensions"
(defMessage @Foo & unknownFields .~
[ TaggedValue 10 (Wire.Lengthy $ encodeMessage $ defMessage @Bar & bar .~ "hello")
, TaggedValue 11 (Wire.Lengthy $ encodeMessage $ defMessage @Baz & baz .~ "world") ])
(mconcat [ tagged 1 $ GroupStart, tagged 2 $ VarInt 10, tagged 3 $ Lengthy (tagged 1 $ Lengthy "hello"), tagged 1 $ GroupEnd
, tagged 1 $ GroupStart, tagged 2 $ VarInt 11, tagged 3 $ Lengthy (tagged 1 $ Lengthy "world"), tagged 1 $ GroupEnd])
(mconcat [ tagged 1 GroupStart, tagged 2 $ VarInt 10, tagged 3 $ Lengthy (tagged 1 $ Lengthy "hello"), tagged 1 GroupEnd
, tagged 1 GroupStart, tagged 2 $ VarInt 11, tagged 3 $ Lengthy (tagged 1 $ Lengthy "world"), tagged 1 GroupEnd])
, deserializeFrom "empty" (Just $ defMessage @Foo) mempty
, deserializeFrom "with bar extension"
(Just $ defMessage @Foo & unknownFields .~
[ TaggedValue 10 (Wire.Lengthy $ encodeMessage $ defMessage @Bar & bar .~ "hello") ])
(mconcat [tagged 1 $ GroupStart, tagged 2 $ VarInt 10, tagged 3 $ Lengthy (tagged 1 $ Lengthy "hello"), tagged 1 $ GroupEnd])
(mconcat [tagged 1 GroupStart, tagged 2 $ VarInt 10, tagged 3 $ Lengthy (tagged 1 $ Lengthy "hello"), tagged 1 GroupEnd])
, deserializeFrom "with reversed tag and message (unsupported)"
(Nothing :: Maybe Foo)
(mconcat [tagged 1 $ GroupStart, tagged 3 $ Lengthy (tagged 1 $ Lengthy "hello"), tagged 2 $ VarInt 10, tagged 1 $ GroupEnd])
(mconcat [tagged 1 GroupStart, tagged 3 $ Lengthy (tagged 1 $ Lengthy "hello"), tagged 2 $ VarInt 10, tagged 1 GroupEnd])
]

testMessageSetSerialization
Expand Down
2 changes: 1 addition & 1 deletion proto-lens-tests/tests/pathological_test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ import Data.ProtoLens.TestUtil (testMain, runTypedTest, roundTripTest, TypedTest
import Proto.Pathological

main :: IO ()
main = testMain $
main = testMain
[ runTypedTest (roundTripTest "pathological_foo" :: TypedTest Foo) ]
6 changes: 3 additions & 3 deletions proto-lens-tests/tests/unknown_fields_test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ testUnknownGroup =
& a .~ 42
& b .~ 17
& unknownFields .~
[ TaggedValue 100 $ Wire.StartGroup
[ TaggedValue 100 Wire.StartGroup
, TaggedValue 150 $ Wire.VarInt 5
, TaggedValue 100 $ Wire.EndGroup
, TaggedValue 100 Wire.EndGroup
])
(vcat [ keyedInt "a" 42
, keyedInt "b" 17
Expand All @@ -110,4 +110,4 @@ testUnknownSerialization name msg ts bs = testCase name $ do
Right msg @=? decodeMessage bs'
renderIndenting ts @=? renderIndenting (pprintMessage msg)
-- Can't decode unknown fields from text format
satisfies isLeft $ (readMessage $ LT.pack $ show ts :: Either String msg)
satisfies isLeft (readMessage $ LT.pack $ show ts :: Either String msg)
2 changes: 1 addition & 1 deletion proto-lens/src/Data/ProtoLens/TextFormat/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ parser = whiteSpace ptp *> parseMessage <* eof
value <- naturalOrFloat ptp
return $ makeNumberValue negative value
parseString = liftM (ByteStringValue . mconcat)
$ many1 $ lexeme ptp $ protoStringLiteral
$ many1 $ lexeme ptp protoStringLiteral
parseEnumValue = liftM EnumValue (identifier ptp)
parseMessageValue =
braces ptp (parseAny <|>
Expand Down

0 comments on commit 5f0ba96

Please sign in to comment.