Skip to content

Commit

Permalink
Refactor: Replace ListMap.toList, ListMap.fromList with IsList(toList…
Browse files Browse the repository at this point in the history
…,fromList)
  • Loading branch information
carbolymer committed Aug 15, 2024
1 parent 1dc1260 commit 1935756
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
1 change: 0 additions & 1 deletion cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ test-suite cardano-cli-golden
cardano-cli,
cardano-cli:cardano-cli-test-lib,
cardano-crypto-wrapper,
cardano-data >=1.1,
cardano-ledger-byron,
cardano-ledger-shelley >=1.10.0.0,
cardano-strict-containers ^>=0.1,
Expand Down
6 changes: 3 additions & 3 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ updateOutputTemplate
, sgMaxLovelaceSupply = fromIntegral $ nonDelegCoin + delegCoin
, sgGenDelegs = shelleyDelKeys
, sgInitialFunds =
ListMap.fromList
fromList
[ (toShelleyAddr addr, v)
| (addr, v) <-
distribute (nonDelegCoin - subtractForTreasury) nUtxoAddrsNonDeleg utxoAddrsNonDeleg
Expand Down Expand Up @@ -1080,7 +1080,7 @@ updateTemplate
, sgMaxLovelaceSupply = fromIntegral $ nonDelegCoin + delegCoin
, sgGenDelegs = shelleyDelKeys
, sgInitialFunds =
ListMap.fromList
fromList
[ (toShelleyAddr addr, v)
| (addr, v) <-
distribute (nonDelegCoin - subtractForTreasury) utxoAddrsNonDeleg
Expand All @@ -1090,7 +1090,7 @@ updateTemplate
, sgStaking =
ShelleyGenesisStaking
{ sgsPools =
ListMap.fromList
fromList
[ (L.ppId poolParams, poolParams)
| poolParams <- Map.elems poolSpecs
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import qualified Data.Aeson as Aeson
import Data.Bifunctor (Bifunctor (..))
import qualified Data.ByteString.Lazy.Char8 as LBS
import Data.ListMap (ListMap (..))
import qualified Data.ListMap as ListMap
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.Maybe (fromMaybe)
Expand Down Expand Up @@ -351,7 +350,7 @@ runGenesisCreateTestNetDataCmd
:: [(VerificationKey StakeKey, VerificationKey DRepKey)]
-> ListMap (L.Credential L.Staking L.StandardCrypto) (L.Delegatee L.StandardCrypto)
delegs =
ListMap.fromList
fromList
. map
( bimap
verificationKeytoStakeCredential
Expand All @@ -363,7 +362,7 @@ runGenesisCreateTestNetDataCmd
-> [VerificationKey DRepKey]
-> ListMap (L.Credential L.DRepRole L.StandardCrypto) (L.DRepState L.StandardCrypto)
initialDReps minDeposit =
ListMap.fromList
fromList
. map
( \c ->
( verificationKeyToDRepCredential c
Expand Down Expand Up @@ -706,7 +705,7 @@ updateOutputTemplate
, sgMaxLovelaceSupply = totalSupply
, sgGenDelegs = shelleyDelKeys
, sgInitialFunds =
ListMap.fromList
fromList
[ (toShelleyAddr addr, v)
| (addr, v) <-
distribute nonDelegCoin nUtxoAddrsNonDeleg utxoAddrsNonDeleg
Expand Down
7 changes: 3 additions & 4 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,10 +1107,9 @@ writePoolState mOutFile serialisedCurrentEpochState = do
let hks :: [L.KeyHash L.StakePool StandardCrypto]
hks =
toList $
fromList @(Set (L.KeyHash L.StakePool StandardCrypto)) $
Map.keys (L.psStakePoolParams poolState)
<> Map.keys (L.psFutureStakePoolParams poolState)
<> Map.keys (L.psRetiring poolState)
Map.keysSet (L.psStakePoolParams poolState)
<> Map.keysSet (L.psFutureStakePoolParams poolState)
<> Map.keysSet (L.psRetiring poolState)

let poolStates :: Map (L.KeyHash 'L.StakePool StandardCrypto) (Params StandardCrypto)
poolStates =
Expand Down
3 changes: 2 additions & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import Data.Bifunctor (Bifunctor (..))
import qualified Data.ByteString as Data.Bytestring
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as LBS
import Data.Containers.ListUtils (nubOrd)
import Data.Data ((:~:) (..))
import qualified Data.Foldable as Foldable
import Data.Function ((&))
Expand Down Expand Up @@ -199,7 +200,7 @@ runTransactionBuildCmd
<$> readTxGovernanceActions eon proposalFiles

-- the same collateral input can be used for several plutus scripts
let filteredTxinsc = toList @(Set _) $ fromList txinsc
let filteredTxinsc = nubOrd txinsc

let allReferenceInputs =
getAllReferenceInputs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import qualified Cardano.Ledger.Shelley.API as L
import Control.Monad
import Control.Monad.IO.Class
import Data.List (intercalate, sort)
import qualified Data.ListMap as ListMap
import qualified Data.Sequence.Strict as Seq
import Data.Word (Word32)
import GHC.Exts (IsList (..))
import System.Directory
import System.Directory.Extra (listDirectories)
import System.FilePath
Expand Down Expand Up @@ -177,7 +177,7 @@ hprop_golden_create_testnet_data_deleg_non_deleg =
-- Because we don't test this elsewhere in this file:
(L.sgMaxLovelaceSupply genesis) H.=== (fromIntegral totalSupply)

let initialFunds = ListMap.toList $ L.sgInitialFunds genesis
let initialFunds = toList $ L.sgInitialFunds genesis
-- This checks that there is actually only one funded address
(length initialFunds) H.=== 1

Expand Down

0 comments on commit 1935756

Please sign in to comment.