Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔮 Apply hlint suggestions from the future. #4172

Merged
merged 6 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ prop_subsequencesOfSize =
== Set.size subsets
, Set.unions (F.toList subsets)
== xs
, all (== k) (length <$> subsequences)
, all ((== k) . length) subsequences
]
where
n = Set.size xs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,17 +533,28 @@ prop_selectRandom_all index f = monadicIO $
, F.foldl' (flip (uncurry UTxOIndex.insert)) indexReduced selected
=== index
, property
$ all (`UTxOIndex.member` index)
$ fst <$> selected
$ all
((`UTxOIndex.member` index) . fst)
selected
, property
$ all (not . (`UTxOIndex.member` indexReduced))
$ fst <$> selected
$ all
(not . (`UTxOIndex.member` indexReduced) . fst)
selected
, property
$ all (selectionFilterMatchesBundleCategory f)
$ categorizeTokenBundle . snd <$> selected
$ all
( selectionFilterMatchesBundleCategory f
. categorizeTokenBundle
. snd
)
selected
, property
$ all (not . selectionFilterMatchesBundleCategory f)
$ categorizeTokenBundle . snd <$> UTxOIndex.toList indexReduced
$ all
( not
. selectionFilterMatchesBundleCategory f
. categorizeTokenBundle
. snd
)
(UTxOIndex.toList indexReduced)
]

-- | Verify that priority order is respected when selecting with more than
Expand Down
1 change: 0 additions & 1 deletion lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ toFlatList b =
toNestedList
:: TokenMap -> [(TokenPolicyId, NonEmpty (TokenName, TokenQuantity))]
toNestedList (TokenMap m) =
mapMaybe (traverse NE.nonEmpty . fmap MonoidMap.toList) $ MonoidMap.toList m
mapMaybe (traverse (NE.nonEmpty . MonoidMap.toList)) $ MonoidMap.toList m

-- | Converts a token map to a nested map.
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ prop_adjustQuantity_hasQuantity b asset =
prop_maximumQuantity_all
:: TokenMap -> Property
prop_maximumQuantity_all b =
property $ all (<= maxQ) (snd <$> TokenMap.toFlatList b)
property $ all ((<= maxQ) . snd) (TokenMap.toFlatList b)
where
maxQ = TokenMap.maximumQuantity b

Expand Down
13 changes: 8 additions & 5 deletions lib/wallet-e2e/src/Cardano/Wallet/Spec/Effect/Random.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@ runRandom gen = reinterpret (evalState gen) \_ -> \case
RandomMnemonic -> do
randomByteString <- uniformByteStringM 32 stGen
mnemonic <-
Mnemonic.unsafeFromList
. Cardano.mnemonicToText
. Cardano.entropyToMnemonic
<$> toEntropy @256 randomByteString
& either (fail . show) pure
either
(fail . show)
(pure
. Mnemonic.unsafeFromList
. Cardano.mnemonicToText
. Cardano.entropyToMnemonic
)
(toEntropy @256 randomByteString)
trace $ "Generated a random mnemonic: " <> Mnemonic.toText mnemonic
pure mnemonic
RandomWalletName (Tagged prefix) -> do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ import Cardano.Wallet.Transaction
( TokenMapWithScripts, ValidityIntervalExplicit )
import Control.Category
( (<<<) )
import Data.Function
( (&) )
import GHC.Generics
( Generic )
import Servant.Server
Expand Down Expand Up @@ -111,5 +109,7 @@ txCBORParser = parser *.** deserializeTx
-- | Parse CBOR to some values and throw a server deserialize error if failing.
parseTxCBOR :: TxCBOR -> Handler ParsedTxCBOR
parseTxCBOR cbor =
extractEraValue <$> sequenceEraValue (applyEraFun txCBORParser cbor)
& either (liftE . ErrParseCBOR) pure
either
(liftE . ErrParseCBOR)
(pure . extractEraValue)
(sequenceEraValue (applyEraFun txCBORParser cbor))
Original file line number Diff line number Diff line change
Expand Up @@ -795,14 +795,13 @@ spec = describe "BYRON_TRANSACTIONS" $ do
rl3 <- request @([ApiTransaction n]) ctx linkList3 Default Empty
verify rl3 [expectListSize 2]
where
listTransactionsFilteredByAddress wallet addrM =
listTransactionsFilteredByAddress wallet =
Link.listTransactions' @'Byron wallet
Nothing
Nothing
Nothing
Nothing
Nothing
addrM

oneAda :: Integer
oneAda = 1_000_000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2707,14 +2707,13 @@ spec = describe "SHARED_TRANSACTIONS" $ do
rl1c <- request @([ApiTransaction n]) ctx linkList1a Default Empty
verify rl1c [expectListSize 2]
where
listTransactionsFilteredByAddress wallet addrM =
listTransactionsFilteredByAddress wallet =
Link.listTransactions' @'Shared wallet
Nothing
Nothing
Nothing
Nothing
Nothing
addrM

oneAda :: Integer
oneAda = 1_000_000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4486,14 +4486,13 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do
rl1c <- request @([ApiTransaction n]) ctx query1 Default Empty
verify rl1c [expectListSize 2]
where
listTransactionsFilteredByAddress wallet addrM =
listTransactionsFilteredByAddress wallet =
Link.listTransactions' @'Shelley wallet
Nothing
Nothing
Nothing
Nothing
Nothing
addrM

-- | Just one million Ada, in Lovelace.
oneMillionAda :: Integer
Expand Down
2 changes: 1 addition & 1 deletion lib/wallet/src/Cardano/DB/Sqlite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ noManualMigration :: ManualMigration
noManualMigration = ManualMigration $ const $ pure ()

foldMigrations :: [Sqlite.Connection -> IO ()] -> ManualMigration
foldMigrations ms = ManualMigration $ \conn -> sequence_ $ ms <&> ($ conn)
foldMigrations ms = ManualMigration $ \conn -> mapM_ ($ conn) ms

data DBField where
DBField
Expand Down
11 changes: 8 additions & 3 deletions lib/wallet/src/Data/Time/Text.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@ utcTimeToText f = T.pack . formatTime defaultTimeLocale (timeFormatPattern f)
-- 'Nothing' if none of the formats matched.
--
utcTimeFromText :: [TimeFormat] -> Text -> Maybe UTCTime
utcTimeFromText fs t = foldr (<|>) Nothing $
flip (parseTimeM False defaultTimeLocale) (T.unpack t) . timeFormatPattern
<$> fs
utcTimeFromText fs t =
foldr
( (<|>)
. flip (parseTimeM False defaultTimeLocale) (T.unpack t)
. timeFormatPattern
)
Nothing
fs

-- | Represents a particular way of representing a moment in time in text.
data TimeFormat = TimeFormat
Expand Down
2 changes: 1 addition & 1 deletion lib/wallet/test/unit/Cardano/Pool/DB/Arbitrary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ isValidSinglePoolCertificateSequence
firstCertificateIsNotRetirement
where
allCertificatesReferToSamePool =
all (== sharedPoolId) (getPoolCertificatePoolId <$> certificates)
all ((== sharedPoolId) . getPoolCertificatePoolId) certificates
firstCertificateIsNotRetirement = case certificates of
[] -> True
Registration _ : _ -> True
Expand Down
2 changes: 1 addition & 1 deletion lib/wallet/test/unit/Cardano/Wallet/ApiSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ instance
:: Applicative m
=> (l0 -> m l1) -> [(l0, r)] -> m [(l1, r)]
traverseLeft fn xs =
fmap swap <$> traverse (traverse fn) (swap <$> xs)
fmap swap <$> traverse (traverse fn . swap) xs

instance
( KnownSymbol h
Expand Down
2 changes: 1 addition & 1 deletion lib/wallet/test/unit/Cardano/Wallet/DB/StateMachine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ validateGenerators = describe "Validate generators & shrinkers" $ do

sanityCheckShrink = \case
[] -> pure ()
[x] -> sanityCheckShrink (concatMap shrinker [x])
[x] -> sanityCheckShrink (shrinker x)
xs -> sanityCheckShrink (concatMap shrinker [head xs, last xs])

dbLayerUnused :: DBLayer m s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ prop_dropGroupBoundary_isValid (getTxSeq -> txSeq) =
prop_dropGroupBoundary_toTxs :: ShrinkableTxSeq -> Property
prop_dropGroupBoundary_toTxs (getTxSeq -> txSeq) =
all
(== TxSeq.toTxList txSeq)
(TxSeq.toTxList <$> TxSeq.dropGroupBoundary txSeq)
((== TxSeq.toTxList txSeq) . TxSeq.toTxList)
(TxSeq.dropGroupBoundary txSeq)
=== True

prop_dropGroupBoundary_txGroupCount_length
Expand All @@ -291,8 +291,8 @@ prop_dropGroupBoundary_txGroupCount_pred (getTxSeq -> txSeq)
| txGroupCount == 0 =
TxSeq.dropGroupBoundary txSeq === []
| otherwise =
all (== pred txGroupCount)
(TxSeq.txGroupCount <$> TxSeq.dropGroupBoundary txSeq)
all ((== pred txGroupCount) . TxSeq.txGroupCount)
(TxSeq.dropGroupBoundary txSeq)
=== True
where
txGroupCount = TxSeq.txGroupCount txSeq
Expand Down Expand Up @@ -396,7 +396,7 @@ prop_shrinkTxSeq_genShrinkSequence_isValid :: Property
prop_shrinkTxSeq_genShrinkSequence_isValid =
forAll (genShrinkSequence shrinkTxSeq =<< genTxSeq genUTxO genAddress) $
\txSeqShrinks ->
all TxSeq.isValid (getTxSeq <$> txSeqShrinks)
all (TxSeq.isValid . getTxSeq) txSeqShrinks

prop_shrinkTxSeq_genShrinkSequence_length :: Property
prop_shrinkTxSeq_genShrinkSequence_length =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ withBodyContent era modTxBody cont =
checkSubsetOf :: (Eq a, Show a) => [a] -> [a] -> Property
checkSubsetOf as bs = property
$ counterexample counterexampleText
$ all (`Set.member` ys) (ShowOrd <$> as)
$ all ((`Set.member` ys) . ShowOrd) as
where
xs = Set.fromList (ShowOrd <$> as)
ys = Set.fromList (ShowOrd <$> bs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2184,6 +2184,7 @@ block0 = W.Block
, delegations = []
}

{- HLINT ignore costModelsForTesting "Use underscore" -}
costModelsForTesting :: Alonzo.CostModels
costModelsForTesting = either (error . show) id $ do
v1 <- Alonzo.mkCostModel PlutusV1
Expand Down