From 1cab9194f1471c81d255c1d4413695717bd3739d Mon Sep 17 00:00:00 2001 From: Chris Martin Date: Fri, 20 Oct 2023 10:52:18 -0600 Subject: [PATCH] fix remainder of hlint warnings --- .hlint.yaml | 117 +++++++++--------- .../lib/CabalFile/CabalFile.hs | 12 +- flake.nix | 1 + 3 files changed, 66 insertions(+), 64 deletions(-) diff --git a/.hlint.yaml b/.hlint.yaml index a26d927..3362d44 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -1,65 +1,66 @@ -- ignore: {name: "Redundant do", within: spec} -- ignore: {name: "Eta reduce"} -- ignore: {name: "Use list comprehension"} -- ignore: {name: "Reduce duplication"} -- ignore: {name: "Use fmap"} # we use classy prelude so this would be in error -- ignore: {name: "Avoid restricted function", within: "**.Prelude"} # allow "as X" -- ignore: {name: "Use ."} # commonly broken or less readable -- ignore: {name: "Use &&"} # we like "and" at 3+ elements -- ignore: {name: "Use ||"} # we like "or" at 3+ elements -- ignore: {name: "Use join"} # this often leads to cryptic code when do notation is easier to read -- ignore: {name: "Use Just"} # makes code less readable -- ignore: {name: "Redundant ^."} # commonly broken by esqueleto +- ignore: { name: "Redundant do", within: spec } +- ignore: { name: "Eta reduce" } +- ignore: { name: "Use list comprehension" } +- ignore: { name: "Reduce duplication" } +- ignore: { name: "Use fmap" } # we use classy prelude so this would be in error +- ignore: { name: "Avoid restricted function", within: "**.Prelude" } # allow "as X" +- ignore: { name: "Use ." } # commonly broken or less readable +- ignore: { name: "Use &&" } # we like "and" at 3+ elements +- ignore: { name: "Use ||" } # we like "or" at 3+ elements +- ignore: { name: "Use join" } # this often leads to cryptic code when do notation is easier to read +- ignore: { name: "Use Just" } # makes code less readable +- ignore: { name: "Redundant ^." } # commonly broken by esqueleto # Custom Warnings -- warn: {lhs: mapM, rhs: traverse} -- warn: {lhs: mapM_, rhs: traverse_} -- warn: {lhs: forM, rhs: for} -- warn: {lhs: forM_, rhs: for_} -- warn: {lhs: return, rhs: pure} +- warn: { lhs: mapM, rhs: traverse } +- warn: { lhs: mapM_, rhs: traverse_ } +- warn: { lhs: forM, rhs: for } +- warn: { lhs: forM_, rhs: for_ } +- warn: { lhs: return, rhs: pure } # Specify additional command line arguments - arguments: - - -XBangPatterns - - -XDataKinds - - -XDeriveAnyClass - - -XDeriveFoldable - - -XDeriveFunctor - - -XDeriveGeneric - - -XDeriveLift - - -XDeriveTraversable - - -XDerivingStrategies - - -XFlexibleContexts - - -XFlexibleInstances - - -XGADTs - - -XGeneralizedNewtypeDeriving - - -XLambdaCase - - -XMultiParamTypeClasses - - -XNoImplicitPrelude - - -XNoMonomorphismRestriction - - -XOverloadedStrings - - -XQuasiQuotes - - -XRankNTypes - - -XRecordWildCards - - -XScopedTypeVariables - - -XStandaloneDeriving - - -XTypeApplications - - -XTypeFamilies + - -XBangPatterns + - -XDataKinds + - -XDeriveAnyClass + - -XDeriveFoldable + - -XDeriveFunctor + - -XDeriveGeneric + - -XDeriveLift + - -XDeriveTraversable + - -XDerivingStrategies + - -XFlexibleContexts + - -XFlexibleInstances + - -XGADTs + - -XGeneralizedNewtypeDeriving + - -XLambdaCase + - -XMultiParamTypeClasses + - -XNoImplicitPrelude + - -XNoMonomorphismRestriction + - -XOverloadedRecordDot + - -XOverloadedStrings + - -XQuasiQuotes + - -XRankNTypes + - -XRecordWildCards + - -XScopedTypeVariables + - -XStandaloneDeriving + - -XTypeApplications + - -XTypeFamilies - modules: - - {name: [Data.Set], as: Set} - - {name: [Data.Map], as: Map} - - {name: [Data.HashSet], as: HashSet} - - {name: [Data.HashMap.Strict], as: HashMap} - - {name: [Data.Text], as: T} - - {name: [Data.Text.Encoding], as: T} - - {name: [Data.Text.IO], as: T} - - {name: [Data.Text.Lazy], as: TL} - - {name: [Data.Text.Lazy.Encoding], as: TL} - - {name: [Data.Text.IO.Lazy], as: TL} - - {name: [Data.ByteString], as: BS} - - {name: [Data.ByteString.Lazy], as: BSL} - - {name: [Data.ByteString.Char8], as: BS8} - - {name: [Data.ByteString.Lazy.Char8], as: BSL8} - - {name: [Data.List.NonEmpty], as: NE} - - {name: [Data.Sequence], as: Seq} + - { name: [Data.Set], as: Set } + - { name: [Data.Map], as: Map } + - { name: [Data.HashSet], as: HashSet } + - { name: [Data.HashMap.Strict], as: HashMap } + - { name: [Data.Text], as: T } + - { name: [Data.Text.Encoding], as: T } + - { name: [Data.Text.IO], as: T } + - { name: [Data.Text.Lazy], as: TL } + - { name: [Data.Text.Lazy.Encoding], as: TL } + - { name: [Data.Text.IO.Lazy], as: TL } + - { name: [Data.ByteString], as: BS } + - { name: [Data.ByteString.Lazy], as: BSL } + - { name: [Data.ByteString.Char8], as: BS8 } + - { name: [Data.ByteString.Lazy.Char8], as: BSL8 } + - { name: [Data.List.NonEmpty], as: NE } + - { name: [Data.Sequence], as: Seq } diff --git a/cabal-file-inspector/lib/CabalFile/CabalFile.hs b/cabal-file-inspector/lib/CabalFile/CabalFile.hs index c8377a3..634833f 100644 --- a/cabal-file-inspector/lib/CabalFile/CabalFile.hs +++ b/cabal-file-inspector/lib/CabalFile/CabalFile.hs @@ -33,13 +33,13 @@ import CabalFile.Package import CabalFile.PackageName import Control.Exception (Exception) import Control.Monad.Validate -import Data.ByteString qualified as ByteString.Strict +import Data.ByteString qualified as BS import Data.Either qualified as Either import Data.List.NonEmpty (NonEmpty, nonEmpty) import Data.String (IsString) import Data.String qualified as IsString (IsString (..)) -import Data.Text qualified as T.Strict -import Data.Text.Encoding qualified as T.Strict +import Data.Text qualified as T +import Data.Text.Encoding qualified as T import Essentials import GHC.Stack (HasCallStack, callStack, prettyCallStack) import Map (Map) @@ -104,15 +104,15 @@ instance Show e => Show (CabalReadException e) where -- | Parses like the contents of a .cabal file. Ignores warnings. Bottom if parsing fails. instance IsString CabalFile where fromString = - T.Strict.pack - >>> T.Strict.encodeUtf8 + T.pack + >>> T.encodeUtf8 >>> parseCabalFile >>> (.result) >>> either (error . show) id -- | Interpret a byte string as a .cabal file, hopefully generating a 'CabalFile', -- possibly generating warnings and errors -parseCabalFile :: ByteString.Strict.ByteString -> CabalRead CabalFile +parseCabalFile :: BS.ByteString -> CabalRead CabalFile parseCabalFile = Cabal.Parsec.parseGenericPackageDescription >>> Cabal.Parsec.runParseResult diff --git a/flake.nix b/flake.nix index ac3d74f..988cc6c 100644 --- a/flake.nix +++ b/flake.nix @@ -27,6 +27,7 @@ nixpkgs-unstable.haskell-language-server nixpkgs-unstable.haskellPackages.weeder freckle.fourmolu-0-13-x + nixpkgs-stable.hlint ]; }; }