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

Add hlint CI job #1290

Merged
merged 1 commit into from
Feb 15, 2024
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
4 changes: 4 additions & 0 deletions .github/workflows/formatting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ jobs:
- name: 📐 Check code formatting
run: |
nix develop .#fmt --command treefmt --fail-on-change

- name: 📐 Check hlint
run: |
nix develop .#fmt --command hlint .
2 changes: 2 additions & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- ignore: {name: Redundant <$>, within: [Hydra.Contract.HeadTokens]}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: Leave a hint on the corresponding code location

You mentioned that we can't have a local ignore pragma because of plutus-tx, but can we somehow make a link that we want to get rid of that change the next time when we recompile / change the script hashes?

- ignore: {name: Redundant compare, within: [Hydra.PartySpec]}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: use a local ignore pragma or address this

This should be possible, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know really, GHC just doesn't like it when I do the suggestions in the docs.

3 changes: 1 addition & 2 deletions hydra-cardano-api/src/Hydra/Cardano/Api/ScriptHash.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ hashScriptInAnyLang (ScriptInAnyLang _ script) =

instance Arbitrary ScriptHash where
arbitrary = do
plutusScript <- arbitrary
pure $ hashScript (PlutusScript PlutusScriptV2 plutusScript)
hashScript . PlutusScript PlutusScriptV2 <$> arbitrary
2 changes: 1 addition & 1 deletion hydra-cardano-api/src/Hydra/Cardano/Api/TxOut.hs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ fromPlutusTxOut ::
Plutus.TxOut ->
Maybe (TxOut CtxUTxO era)
fromPlutusTxOut network out = do
value <- shelleyBasedEraConstraints (shelleyBasedEra @era) $ TxOutValueShelleyBased (shelleyBasedEra @era) <$> (toLedgerValue (maryEraOnwards @era) <$> fromPlutusValue plutusValue)
value <- shelleyBasedEraConstraints (shelleyBasedEra @era) (TxOutValueShelleyBased (shelleyBasedEra @era) . toLedgerValue (maryEraOnwards @era) <$> fromPlutusValue plutusValue)
pure $ TxOut addressInEra value datum ReferenceScriptNone
where
addressInEra = fromPlutusAddress network plutusAddress
Expand Down
1 change: 0 additions & 1 deletion hydra-cluster/bench/Main.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedRecordDot #-}

module Main where

Expand Down
16 changes: 8 additions & 8 deletions hydra-cluster/src/Hydra/Cluster/Mithril.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ downloadLatestSnapshotTo tracer network directory = do

genesisKeyURLForNetwork :: KnownNetwork -> Maybe String
genesisKeyURLForNetwork = \case
Mainnet -> Just $ "https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/release-mainnet/genesis.vkey"
Preproduction -> Just $ "https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/release-preprod/genesis.vkey"
Preview -> Just $ "https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/pre-release-preview/genesis.vkey"
Sanchonet -> Just $ "https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/testing-sanchonet/genesis.vkey"
Mainnet -> Just "https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/release-mainnet/genesis.vkey"
Preproduction -> Just "https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/release-preprod/genesis.vkey"
Preview -> Just "https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/pre-release-preview/genesis.vkey"
Sanchonet -> Just "https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/testing-sanchonet/genesis.vkey"

aggregatorEndpointForNetwork :: KnownNetwork -> Maybe String
aggregatorEndpointForNetwork = \case
Mainnet -> Just $ "https://aggregator.release-mainnet.api.mithril.network/aggregator"
Preproduction -> Just $ "https://aggregator.release-preprod.api.mithril.network/aggregator"
Preview -> Just $ "https://aggregator.pre-release-preview.api.mithril.network/aggregator"
Sanchonet -> Just $ "https://aggregator.testing-sanchonet.api.mithril.network/aggregator"
Mainnet -> Just "https://aggregator.release-mainnet.api.mithril.network/aggregator"
Preproduction -> Just "https://aggregator.release-preprod.api.mithril.network/aggregator"
Preview -> Just "https://aggregator.pre-release-preview.api.mithril.network/aggregator"
Sanchonet -> Just "https://aggregator.testing-sanchonet.api.mithril.network/aggregator"
6 changes: 3 additions & 3 deletions hydra-cluster/test/Test/Hydra/Cluster/CardanoCliSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ spec =
it "query protocol-parameters is compatible with our FromJSON instance" $ \tracer ->
withTempDir "hydra-cluster" $ \tmpDir -> do
withCardanoNodeDevnet tracer tmpDir $ \RunningNode{nodeSocket, networkId} -> do
protocolParameters <- cliQueryProtocolParameters nodeSocket (networkId)
case (parseEither pparamsFromJson protocolParameters) of
protocolParameters <- cliQueryProtocolParameters nodeSocket networkId
case parseEither pparamsFromJson protocolParameters of
Left e -> failure $ "Failed to decode JSON: " <> e <> "\n" <> show protocolParameters
Right _ -> pure ()

it "query protocol-parameters matches our schema" $ \tracer ->
withJsonSpecifications $ \tmpDir ->
withCardanoNodeDevnet tracer tmpDir $ \RunningNode{nodeSocket, networkId} -> do
pparamsValue <- cliQueryProtocolParameters nodeSocket (networkId)
pparamsValue <- cliQueryProtocolParameters nodeSocket networkId
validateJSON
(tmpDir </> "api.json")
(key "components" . key "schemas" . key "ProtocolParameters")
Expand Down
11 changes: 5 additions & 6 deletions hydra-node/exe/hydra-net/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ injectReqSn peer snapshotNumber hydraKeyFile fakeHydraKeyFile = do
traceWith tracer $ ConnectedTo sockAddr
runClient iomgr (mkApplication sk party tracer) sock
where
runClient iomgr app sock =
runClient iomgr app =
connectToNodeSocket
iomgr
unversionedHandshakeCodec
Expand All @@ -192,7 +192,6 @@ injectReqSn peer snapshotNumber hydraKeyFile fakeHydraKeyFile = do
networkConnectTracers
(HandshakeCallbacks acceptableVersion queryVersion)
(unversionedProtocol app)
sock

networkConnectTracers =
NetworkConnectTracers
Expand All @@ -207,17 +206,17 @@ injectReqSn peer snapshotNumber hydraKeyFile fakeHydraKeyFile = do
_ -> die "getAdrrInfo failed"

mkApplication sk party tracer =
OuroborosApplication $
OuroborosApplication
[ MiniProtocol
{ miniProtocolNum = MiniProtocolNum 42
, miniProtocolLimits = MiniProtocolLimits{maximumIngressQueue = maxBound}
, miniProtocolRun =
InitiatorProtocolOnly
( mkMiniProtocolCbFromPeer
( \_ ->
( (contramap TraceSendRecv tracer)
( const
( contramap TraceSendRecv tracer
, codecFireForget
, (fireForgetClientPeer $ client tracer sk party)
, fireForgetClientPeer $ client tracer sk party
)
)
)
Expand Down
2 changes: 1 addition & 1 deletion hydra-node/src/Hydra/API/ServerOutput.hs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ instance
data WithUTxO = WithUTxO | WithoutUTxO
deriving stock (Eq, Show)

data ServerOutputConfig = ServerOutputConfig
newtype ServerOutputConfig = ServerOutputConfig
{ utxoInSnapshot :: WithUTxO
}
deriving stock (Eq, Show)
Expand Down
4 changes: 2 additions & 2 deletions hydra-node/src/Hydra/Chain/CardanoClient.hs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ submitTransaction networkId socket tx =
-- safely constructed through 'buildTransaction'.
data SubmitTransactionException
= SubmitEraMismatch EraMismatch
| SubmitTxValidationError (TxValidationErrorInCardanoMode)
| SubmitTxValidationError TxValidationErrorInCardanoMode
deriving stock (Show)

instance Exception SubmitTransactionException
Expand Down Expand Up @@ -240,7 +240,7 @@ querySystemStart networkId socket queryPoint =
-- Throws at least 'QueryException' if query fails.
queryEraHistory :: NetworkId -> SocketPath -> QueryPoint -> IO EraHistory
queryEraHistory networkId socket queryPoint =
runQuery networkId socket queryPoint $ QueryEraHistory
runQuery networkId socket queryPoint QueryEraHistory

-- | Query the current epoch number.
--
Expand Down
9 changes: 3 additions & 6 deletions hydra-node/src/Hydra/Crypto.hs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ instance SerialiseAsRawBytes (Hash HydraKey) where
serialiseToRawBytes (HydraKeyHash vkh) = hashToBytes vkh

deserialiseFromRawBytes (AsHash AsHydraKey) bs =
maybe (error "TODO: SerialiseAsRawBytesError, but constructor not exported") Right $
HydraKeyHash <$> hashFromBytes bs
maybe (error "TODO: SerialiseAsRawBytesError, but constructor not exported") (Right . HydraKeyHash) (hashFromBytes bs)

instance Key HydraKey where
-- Hydra verification key, which can be used to 'verify' signed messages.
Expand Down Expand Up @@ -135,8 +134,7 @@ instance SerialiseAsRawBytes (SigningKey HydraKey) where
rawSerialiseSignKeyDSIGN sk

deserialiseFromRawBytes (AsSigningKey AsHydraKey) bs =
maybe (error "TODO: SerialiseAsRawBytesError, but constructor not exported") Right $
HydraSigningKey <$> rawDeserialiseSignKeyDSIGN bs
maybe (error "TODO: SerialiseAsRawBytesError, but constructor not exported") (Right . HydraSigningKey) (rawDeserialiseSignKeyDSIGN bs)

instance HasTextEnvelope (SigningKey HydraKey) where
textEnvelopeType _ =
Expand All @@ -151,8 +149,7 @@ instance SerialiseAsRawBytes (VerificationKey HydraKey) where
rawSerialiseVerKeyDSIGN vk

deserialiseFromRawBytes (AsVerificationKey AsHydraKey) bs =
maybe (error "TODO: SerialiseAsRawBytesError, but constructor not exported") Right $
HydraVerificationKey <$> rawDeserialiseVerKeyDSIGN bs
maybe (error "TODO: SerialiseAsRawBytesError, but constructor not exported") (Right . HydraVerificationKey) (rawDeserialiseVerKeyDSIGN bs)

instance ToJSON (VerificationKey HydraKey) where
toJSON = toJSON . serialiseToRawBytesHexText
Expand Down
4 changes: 2 additions & 2 deletions hydra-node/src/Hydra/HeadLogic/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import Hydra.Snapshot (SnapshotNumber)
-- | Preliminary type for collecting errors occurring during 'update'.
-- TODO: Try to merge this (back) into 'Outcome'.
data LogicError tx
= InvalidEvent {invalidEvent :: (Event tx), currentHeadState :: (HeadState tx)}
| RequireFailed {requirementFailure :: (RequirementFailure tx)}
= InvalidEvent {invalidEvent :: Event tx, currentHeadState :: HeadState tx}
| RequireFailed {requirementFailure :: RequirementFailure tx}
| NotOurHead {ourHeadId :: HeadId, otherHeadId :: HeadId}
deriving stock (Generic)

Expand Down
12 changes: 6 additions & 6 deletions hydra-node/src/Hydra/Ledger/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ instance ToJSON Tx where
toJSON tx =
let TextEnvelopeType envelopeType = textEnvelopeType (proxyToAsType (Proxy @Tx))
in object
[ "cborHex" .= (Aeson.String $ decodeUtf8 $ Base16.encode $ serialiseToCBOR tx)
, "txId" .= (txId tx)
[ "cborHex" .= Aeson.String (decodeUtf8 $ Base16.encode $ serialiseToCBOR tx)
, "txId" .= txId tx
, "type" .= envelopeType
, "description" .= Aeson.String mempty
]
Expand All @@ -153,7 +153,7 @@ instance FromJSON Tx where
(o .:? "txId") >>= \case
Nothing -> pure tx
Just txid' -> do
guard (txid' == (txId tx))
guard (txid' == txId tx)
pure tx

instance Arbitrary Tx where
Expand Down Expand Up @@ -362,8 +362,8 @@ genTxOut =
`suchThat` notByronAddress
where
gen =
fmap (modifyTxOutValue (<> (lovelaceToValue $ Lovelace 10_000_000))) $
oneof
modifyTxOutValue (<> (lovelaceToValue $ Lovelace 10_000_000))
<$> oneof
[ fromLedgerTxOut <$> arbitrary
, notMultiAsset . fromLedgerTxOut <$> arbitrary
]
Expand Down Expand Up @@ -429,7 +429,7 @@ genAddressInEra networkId =
mkVkAddress networkId <$> genVerificationKey

genValue :: Gen Value
genValue = liftA2 (<>) (pure $ lovelaceToValue $ Lovelace 10_000_000) (scale (`div` 10) $ fromLedgerValue <$> arbitrary)
genValue = fmap ((lovelaceToValue $ Lovelace 10_000_000) <>) (scale (`div` 10) $ fromLedgerValue <$> arbitrary)

-- | Generate UTXO entries that do not contain any assets. Useful to test /
-- measure cases where
Expand Down
7 changes: 3 additions & 4 deletions hydra-node/src/Hydra/Network/Ouroboros/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ fireForgetServerPeer ::
Peer (FireForget msg) 'AsServer 'StIdle m a
fireForgetServerPeer FireForgetServer{recvMsg, recvMsgDone} =
-- In the 'StIdle' the server is awaiting a request message
Await (ClientAgency TokIdle) $ \msg ->
Await (ClientAgency TokIdle) $ \case
-- The client got to choose between two messages and we have to handle
-- either of them
case msg of
MsgSend payload -> Effect $ fireForgetServerPeer <$> recvMsg payload
MsgDone -> Effect $ Done TokDone <$> recvMsgDone
MsgSend payload -> Effect $ fireForgetServerPeer <$> recvMsg payload
MsgDone -> Effect $ Done TokDone <$> recvMsgDone
2 changes: 1 addition & 1 deletion hydra-node/src/Hydra/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ genDirPath = do
pure $ intercalate "/" path

genChainPoint :: Gen ChainPoint
genChainPoint = ChainPoint <$> (SlotNo <$> arbitrary) <*> someHeaderHash
genChainPoint = (ChainPoint . SlotNo <$> arbitrary) <*> someHeaderHash
where
someHeaderHash = do
bytes <- vectorOf 32 arbitrary
Expand Down
2 changes: 1 addition & 1 deletion hydra-node/src/Hydra/Party.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ instance ToJSONKey Party where
toJSONKey = toJSONKeyText (serialiseToRawBytesHexText . vkey)

instance FromJSONKey Party where
fromJSONKey = FromJSONKeyTextParser $ partyFromHexText
fromJSONKey = FromJSONKeyTextParser partyFromHexText
where
partyFromHexText :: MonadFail m => Text -> m Party
partyFromHexText t =
Expand Down
8 changes: 3 additions & 5 deletions hydra-node/test/Hydra/Chain/Direct/Contract/Close.hs
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,9 @@ data CloseInitialMutation
-- right away.
genCloseInitialMutation :: (Tx, UTxO) -> Gen SomeMutation
genCloseInitialMutation (tx, _utxo) =
oneof
[ SomeMutation (Just $ toErrorCode IncorrectClosedContestationDeadline) MutateCloseContestationDeadline' <$> do
mutatedDeadline <- genMutatedDeadline
pure $ ChangeOutput 0 $ modifyInlineDatum (replaceContestationDeadline mutatedDeadline) headTxOut
]
SomeMutation (Just $ toErrorCode IncorrectClosedContestationDeadline) MutateCloseContestationDeadline' <$> do
mutatedDeadline <- genMutatedDeadline
pure $ ChangeOutput 0 $ modifyInlineDatum (replaceContestationDeadline mutatedDeadline) headTxOut
where
headTxOut = fromJust $ txOuts' tx !!? 0

Expand Down
2 changes: 1 addition & 1 deletion hydra-node/test/Hydra/Chain/Direct/Contract/Init.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ genInitMutation (tx, _utxo) =
out

removeInitialOutputDatum ix out =
ChangeOutput ix $ modifyTxOutDatum (const $ TxOutDatumNone) out
ChangeOutput ix $ modifyTxOutDatum (const TxOutDatumNone) out

changeInitialOutputToNotAHeadId ix out =
ChangeOutput ix $ modifyTxOutDatum (const $ TxOutDatumInline $ toScriptData (42 :: Integer)) out
2 changes: 1 addition & 1 deletion hydra-node/test/Hydra/Chain/Direct/TxSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ spec =
genericCoverTable [transition] $
counterexample (show transition) $
let utxo = getKnownUTxO st
in case (observeHeadTx testNetworkId utxo tx) of
in case observeHeadTx testNetworkId utxo tx of
NoHeadTx -> property False
Init{} -> transition === Transition.Init
Abort{} -> transition === Transition.Abort
Expand Down
2 changes: 1 addition & 1 deletion hydra-node/test/Hydra/Chain/Direct/WalletSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ genChainPoint =
-- | Generate a chain point at given slot with a likely invalid block header hash.
genChainPointAt :: SlotNo -> Gen ChainPoint
genChainPointAt s =
ChainPoint s <$> (HeaderHash <$> arbitrary)
ChainPoint s . HeaderHash <$> arbitrary

-- | Generate an arbitrary list of transactions from a UTXO set such that,
-- transactions may *sometimes* consume given UTXO and produce new ones. The
Expand Down
4 changes: 2 additions & 2 deletions hydra-node/test/Hydra/JSONSchemaSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ spec = do
validateJSON (dir </> "api.json") id Null

it "fails on non-existing schema file" $
validateJSON ("does-not-exist.json") id Null
validateJSON "does-not-exist.json" id Null
`shouldThrow` exceptionContaining @IOException "does-not-exist.json"

it "fails with missing tool" $ do
withClearedPATH $
validateJSON ("does-not-matter.json") id Null
validateJSON "does-not-matter.json" id Null
`shouldThrow` exceptionContaining @IOException "installed"

it "selects a sub-schema correctly" $
Expand Down
2 changes: 1 addition & 1 deletion hydra-node/test/Hydra/Network/ReliabilitySpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ spec = parallel $ do
let networkMessagesFile = tmpDir <> "/network-messages"

Persistence{load, save} <- createPersistence $ tmpDir <> "/acks"
PersistenceIncremental{loadAll, append} <- createPersistenceIncremental $ networkMessagesFile
PersistenceIncremental{loadAll, append} <- createPersistenceIncremental networkMessagesFile

let messagePersistence =
MessagePersistence
Expand Down
2 changes: 1 addition & 1 deletion hydra-plutus-extras/src/Hydra/Plutus/Orphans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ instance Arbitrary a => Arbitrary (UpperBound a) where
arbitrary = upperBound <$> arbitrary

instance ToJSON PubKeyHash where
toJSON = \kh ->
toJSON kh =
object
[ "tag" .= Aeson.String "PubKeyHash"
, "keyHash" .= Aeson.String (decodeUtf8 $ Base16.encode $ fromBuiltin $ getPubKeyHash kh)
Expand Down
2 changes: 1 addition & 1 deletion hydra-plutus/exe/inspect-script/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ main = do
, (abortDatum, "abortDatum")
]

headDatum = toData $ Head.Initial 1_000_000_000_000 [] (toPlutusCurrencySymbol $ HeadTokens.headPolicyId $ someTxIn) (toPlutusTxOutRef someTxIn)
headDatum = toData $ Head.Initial 1_000_000_000_000 [] (toPlutusCurrencySymbol $ HeadTokens.headPolicyId someTxIn) (toPlutusTxOutRef someTxIn)

someTxIn = TxIn (TxId $ unsafeHashFromBytes "01234567890123456789012345678901") (TxIx 1)

Expand Down
2 changes: 0 additions & 2 deletions hydra-plutus/src/Hydra/Contract/Error.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{-# LANGUAGE TemplateHaskell #-}

-- | Error codes to be used in plutus scripts.
--
-- Define a new type and instantiate 'ToErrorCode' for error cases you want to
Expand Down
4 changes: 2 additions & 2 deletions hydra-plutus/src/Hydra/Contract/Initial.hs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ checkCommit commitValidator headId committedRefs context =
go = \case
([], []) ->
True
([], (_ : _)) ->
([], _ : _) ->
traceError $(errorCode MissingCommittedTxOutInOutputDatum)
((_ : _), []) ->
(_ : _, []) ->
traceError $(errorCode CommittedTxOutMissingInOutputDatum)
(TxInInfo{txInInfoOutRef, txInInfoResolved} : restCommitted, Commit{input, preSerializedOutput} : restCommits) ->
Builtins.serialiseData (toBuiltinData txInInfoResolved) == preSerializedOutput
Expand Down
2 changes: 1 addition & 1 deletion hydra-test-utils/src/Test/Network/Ports.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ withFreePort action = getRandomPort >>= action
randomUnusedTCPPorts :: Int -> IO [Int]
randomUnusedTCPPorts count =
fmap fromIntegral
<$> replicateM count (withFreePort (\port -> return port))
<$> replicateM count (withFreePort return)
6 changes: 6 additions & 0 deletions nix/hydra/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ let

fourmolu = pkgs.haskell-nix.tool compiler "fourmolu" "0.14.0.0";
cabal-fmt = pkgs.haskell-nix.tool compiler "cabal-fmt" "0.1.9";
hlint = pkgs.haskell-nix.tool compiler "hlint" "3.8";
apply-refact = pkgs.haskell-nix.tool compiler "apply-refact" "0.14.0.0";

# Build HLS form our fork (see flake.nix)
haskell-language-server = pkgs.haskell-nix.tool compiler "haskell-language-server" rec {
Expand Down Expand Up @@ -45,6 +47,8 @@ let
fourmolu
cabal-fmt
pkgs.nixpkgs-fmt
hlint
apply-refact
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For

hlint --refactor --refactor-options="-i"

applies everything.

# For validating JSON instances against a pre-defined schema
pkgs.check-jsonschema
# For generating plantuml drawings
Expand Down Expand Up @@ -155,6 +159,8 @@ let
fourmolu
cabal-fmt
pkgs.nixpkgs-fmt
hlint
apply-refact
];
};

Expand Down
2 changes: 1 addition & 1 deletion plutus-cbor/test/Plutus/Codec/CBOR/EncodingSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ genInteger =

genByteString :: Gen ByteString
genByteString = do
(\n -> BS.pack <$> vector n) =<< elements [0, 8, 16, 28, 32]
fmap BS.pack . vector =<< elements [0, 8, 16, 28, 32]

shrinkByteString :: ByteString -> [ByteString]
shrinkByteString =
Expand Down