From feb79d78009f2217292f19e6d0357f3f9fe30f0a Mon Sep 17 00:00:00 2001 From: Yoo Chung Date: Wed, 9 Oct 2024 21:40:28 +0000 Subject: [PATCH 1/2] Enable `Move brackets to avoid $` hint for HLint. --- .hlint.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.hlint.yaml b/.hlint.yaml index e082d884..13dabb47 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -14,7 +14,6 @@ - ignore: {name: "Avoid lambda"} # 1 hint - ignore: {name: "Eta reduce"} # 1 hint - ignore: {name: "Fuse foldr/map"} # 1 hint -- ignore: {name: "Move brackets to avoid $"} # 8 hints - ignore: {name: "Use :"} # 2 hints - ignore: {name: "Use <$"} # 1 hint - ignore: {name: "Use <$>"} # 1 hint From a03492bce72120c65bf2f3c5b053d0e75820a0ef Mon Sep 17 00:00:00 2001 From: Yoo Chung Date: Wed, 9 Oct 2024 22:26:18 +0000 Subject: [PATCH 2/2] Move brackets to avoid `$`. --- proto-lens-protoc/app/Data/ProtoLens/Compiler/Generate.hs | 8 ++++---- .../app/Data/ProtoLens/Compiler/Generate/Encoding.hs | 2 +- proto-lens-protoc/app/protoc-gen-haskell.hs | 2 +- proto-lens/src/Data/ProtoLens/Encoding/Bytes.hs | 4 ++-- proto-lens/tests/parser_test.hs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/proto-lens-protoc/app/Data/ProtoLens/Compiler/Generate.hs b/proto-lens-protoc/app/Data/ProtoLens/Compiler/Generate.hs index dc4e1e56..a1bc99b0 100644 --- a/proto-lens-protoc/app/Data/ProtoLens/Compiler/Generate.hs +++ b/proto-lens-protoc/app/Data/ProtoLens/Compiler/Generate.hs @@ -99,7 +99,7 @@ generateModule modName fdesc imports publicImports definitions importedEnv servi ++ map importQualified (imports List.\\ publicImports) ++ map import' publicImports) []) - $ (concatMap generateDecls $ Map.toList definitions) + $ concatMap generateDecls (Map.toList definitions) ++ map uncommented (concatMap (generateServiceDecls env) services) ++ map uncommented packedFileDescriptorProto , CommentedModule pragmas @@ -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) @@ -422,7 +422,7 @@ generatePrisms env oneofInfo = -- Sum type constructor @@ var (unqual consName) -- Case deconstruction - @@ (lambda [bvar "p__"] $ + @@ lambda [bvar "p__"] ( case' (var "p__") $ [ match [conP (unqual consName) [bvar "p__val"]] $ var "Prelude.Just" @@ var "p__val" @@ -430,7 +430,7 @@ generatePrisms env oneofInfo = -- We want to generate the otherwise case -- depending on the amount of sum type cases there are ++ otherwiseCase - ) + ) generatePrism :: [RawMatch] -> OneofCase -> [HsDecl'] generatePrism otherwiseCase oneofCase = let consName = caseConstructorName oneofCase diff --git a/proto-lens-protoc/app/Data/ProtoLens/Compiler/Generate/Encoding.hs b/proto-lens-protoc/app/Data/ProtoLens/Compiler/Generate/Encoding.hs index 5661ecf2..d96abf4c 100644 --- a/proto-lens-protoc/app/Data/ProtoLens/Compiler/Generate/Encoding.hs +++ b/proto-lens-protoc/app/Data/ProtoLens/Compiler/Generate/Encoding.hs @@ -629,7 +629,7 @@ unsafeLiftIO' = var "Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO" -- | Returns an expression of type @Parser a@ for the given field. parseField :: FieldInfo -> HsExpr' parseField f = var "Data.ProtoLens.Encoding.Bytes." - @@ (parseFieldType $ fieldInfoEncoding f) + @@ parseFieldType (fieldInfoEncoding f) @@ string n where n = Text.unpack (fieldDescriptor f ^. #name) diff --git a/proto-lens-protoc/app/protoc-gen-haskell.hs b/proto-lens-protoc/app/protoc-gen-haskell.hs index 447e191c..9431283e 100644 --- a/proto-lens-protoc/app/protoc-gen-haskell.hs +++ b/proto-lens-protoc/app/protoc-gen-haskell.hs @@ -73,7 +73,7 @@ makeResponse dflags prog request = let ] preamble = defMessage & #supportedFeatures .~ - (foldl (.|.) zeroBits $ fmap (toEnum . fromEnum) features) + foldl (.|.) zeroBits (fmap (toEnum . fromEnum) features) -- Do not process actual Protobuf Editions files yet. & #minimumEdition .~ fromIntegral (fromEnum EDITION_PROTO2) & #maximumEdition .~ fromIntegral (fromEnum EDITION_2023) diff --git a/proto-lens/src/Data/ProtoLens/Encoding/Bytes.hs b/proto-lens/src/Data/ProtoLens/Encoding/Bytes.hs index 301e36ef..7888f8bc 100644 --- a/proto-lens/src/Data/ProtoLens/Encoding/Bytes.hs +++ b/proto-lens/src/Data/ProtoLens/Encoding/Bytes.hs @@ -95,9 +95,9 @@ getVarIntH :: Handle -> ExceptT String IO Word64 getVarIntH h = do buf <- liftIO malloc let loopStart !n !s = - (liftIO $ hGetBuf h buf 1) >>= + liftIO (hGetBuf h buf 1) >>= \case - 1 -> (liftIO $ peek buf) >>= + 1 -> liftIO (peek buf) >>= getVarIntLoopFinish loopStart n s _ -> throwE "Unexpected end of file" res <- loopStart 0 1 diff --git a/proto-lens/tests/parser_test.hs b/proto-lens/tests/parser_test.hs index 198a332e..7df0ef12 100644 --- a/proto-lens/tests/parser_test.hs +++ b/proto-lens/tests/parser_test.hs @@ -73,7 +73,7 @@ testFailure = testIsolate :: [TestTree] testIsolate = [ testProperty "many" $ \bs bs' -> - runParser ((,) <$> (isolate (length bs) $ manyTillEnd getWord8) <*> + runParser ((,) <$> isolate (length bs) (manyTillEnd getWord8) <*> manyTillEnd getWord8) (B.pack (bs ++ bs')) == Right (bs, bs')