Skip to content

Commit

Permalink
Enable Redundant bracket hint for HLint. (#483)
Browse files Browse the repository at this point in the history
Remove redundant brackets.
  • Loading branch information
chungyc authored Oct 8, 2024
1 parent c3c3283 commit d020b88
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
1 change: 0 additions & 1 deletion .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
- ignore: {name: "Fuse foldr/map"} # 1 hint
- ignore: {name: "Move brackets to avoid $"} # 8 hints
- ignore: {name: "Redundant ^."} # 2 hints
- ignore: {name: "Redundant bracket"} # 13 hints
- ignore: {name: "Unused LANGUAGE pragma"} # 11 hints
- ignore: {name: "Use :"} # 2 hints
- ignore: {name: "Use <$"} # 1 hint
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 @@ -30,7 +30,7 @@ propNegLTPos :: Num a => Sort a -> (a, a) -> Bool
propNegLTPos s (l, r) = sortCompare s (negate (abs l)) (abs r) == LT

propNegZeroLTZero :: Fractional a => Sort a -> Bool
propNegZeroLTZero s = sortCompare s (-0.0) (0.0) == LT
propNegZeroLTZero s = sortCompare s (-0.0) 0.0 == LT

inf :: Fractional a => a
inf = 1.0 / 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ messageDefs features protoPrefix hsPrefix groups d
, messageDescriptor = d
, messageFields =
map (PlainFieldInfo <$>
(fieldKind features' mapEntries) <*> (fieldInfo hsPrefix'))
fieldKind features' mapEntries <*> fieldInfo hsPrefix')
$ Map.findWithDefault [] Nothing allFields
, messageOneofFields = collectOneofFields hsPrefix' d allFields
, messageUnknownFields =
Expand Down
6 changes: 3 additions & 3 deletions proto-lens-protoc/app/Data/ProtoLens/Compiler/Generate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ messageComment fieldModName n fields =
(moduleNameStrToString fieldModName)
(occNameStrToString $ nameFromSymbol $ lensSymbol l))
Outputable.<>
(Outputable.ppr $ var "Lens'" @@ t @@ (lensFieldType l))
(Outputable.ppr $ var "Lens'" @@ t @@ lensFieldType l)
Outputable.<> Outputable.char '@'
t = var (unqual n)

Expand Down Expand Up @@ -412,7 +412,7 @@ generatePrisms env oneofInfo =
-- The oneof sum type name
@@ (var . unqual $ oneofTypeName oneofInfo)
-- The field contained in the sum
@@ (hsFieldType env f)
@@ hsFieldType env f
-- Generate function definition
-- Prism' is constructed with Constructor for building value
-- and Deconstructor and wrapping in Just for getting value
Expand Down Expand Up @@ -880,7 +880,7 @@ hsFieldValueDefault env fd = case fd ^. #type' of
-> var "Data.Text.pack" @@ string (T.unpack def)
FieldDescriptorProto'TYPE_BYTES
-> var "Data.ByteString.pack"
@@ list ((mkByte . fromEnum) <$> T.unpack def)
@@ list (mkByte . fromEnum <$> T.unpack def)
where mkByte c
| c > 0 && c < 255 = int $ fromIntegral c
| otherwise = errorMessage "bytes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ generatedParser env m =
| Just g <- groupFieldNumber m = do'
[ tag <-- getVarInt'
, stmt $ case' tag $
(match [int (groupEndTag g)] (finish m exprs))
match [int (groupEndTag g)] (finish m exprs)
: parseTagCases continue exprs m
]
{- Regular message type:
Expand Down Expand Up @@ -125,14 +125,14 @@ finish m s = do' $
[ stmt $ checkMissingFields s
, stmt $ var "Prelude.return" @@
(over' unknownFields' (var "Prelude.reverse")
@@(foldr (@@)
@@ foldr (@@)
(partialMessage s)
(Map.intersectionWith
(\finfo frozen ->
var "Lens.Family2.set"
@@ fieldOfVector finfo
@@ var (unqual frozen))
repeatedInfos frozenNames)))
repeatedInfos frozenNames))
]

where
Expand Down Expand Up @@ -220,7 +220,7 @@ updateParseState ::
HsExpr' -- ^ An expression of type @msg -> msg@
-> ParseState HsExpr'
-> ParseState HsExpr'
updateParseState f s = s { partialMessage = f @@ (partialMessage s) }
updateParseState f s = s { partialMessage = f @@ partialMessage s }

-- | Transform the loop arguments by marking a required field
-- as having been set.
Expand Down Expand Up @@ -264,7 +264,7 @@ checkMissingFields s =
missing = "missing"
allMissingFields = Map.foldrWithKey consIfMissing (list []) (requiredFieldsUnset s)
consIfMissing (FieldId f) e rest =
(if' e (cons @@ string (Text.unpack f)) (var "Prelude.id")) @@ rest
if' e (cons @@ string (Text.unpack f)) (var "Prelude.id") @@ rest

-- | A list case alternatives for the fields of a message.
--
Expand Down Expand Up @@ -584,7 +584,7 @@ buildPackedField f x = let' [valBind p x]

buildOneofField :: HsExpr' -> OneofInfo -> HsExpr'
buildOneofField x info = case' (view' @@ fieldOfOneof info @@ x) $
(match [conP_ "Prelude.Nothing"] mempty')
match [conP_ "Prelude.Nothing"] mempty'
: [ match [conP "Prelude.Just" [conP (unqual $ caseConstructorName c)
[v]]]
$ buildTaggedField (caseField c) v
Expand Down
6 changes: 4 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,14 @@ roundTripTest name = TypedTest $ testGroup name
[ testProperty "shrink sanity" $
-- Disable automatic shrinking so the test behaves
-- sensibly if there's a bug in shrinkMessage.
noShrinking (
#if MIN_VERSION_QuickCheck(2,10,0)
noShrinking $
-- Limit the number of tests since shrinking is slow for large messages.
withMaxSuccess 20
(shrinkSanityProperty :: MessageProperty a)
#else
noShrinking (shrinkSanityProperty :: MessageProperty a)
#endif
(shrinkSanityProperty :: MessageProperty a))
, testProperty "wire" (wireRoundTripProperty :: MessageProperty a)
, testProperty "text" (textRoundTripProperty :: MessageProperty a)
]
Expand Down
2 changes: 1 addition & 1 deletion proto-lens-tests/tests/text_format_test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ main = testMain
(Just $ def1 & b .~ "\a\b\f\n\r\t\v\\\'\"")
(Data.Text.Lazy.pack "b: \"\a\b\f\n\r\t\v\\\\\\\'\\\"\"")
, readFrom
("Parse string with legal non-escaped \' quote character")
"Parse string with legal non-escaped \' quote character"
(Just $ def1 & b .~ "'")
(Data.Text.Lazy.pack "b: \"'\"")
, testCase "Render string with escape sequences" $
Expand Down
2 changes: 1 addition & 1 deletion proto-lens/tests/parser_test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ testIsolate :: [TestTree]
testIsolate =
[ testProperty "many" $ \bs bs' ->
runParser ((,) <$> (isolate (length bs) $ manyTillEnd getWord8) <*>
(manyTillEnd getWord8))
manyTillEnd getWord8)
(B.pack (bs ++ bs'))
== Right (bs, bs')
, testProperty "negative length" $ \n ws ->
Expand Down

0 comments on commit d020b88

Please sign in to comment.