Skip to content

Commit

Permalink
Merge pull request #1153 from input-output-hk/lc/Wmissing-deriving-st…
Browse files Browse the repository at this point in the history
…rategies

Enable -Wmissing-deriving-strategies everywhere
  • Loading branch information
ch1bo authored Nov 6, 2023
2 parents 71af801 + 0baf859 commit 57c031a
Show file tree
Hide file tree
Showing 69 changed files with 266 additions and 238 deletions.
2 changes: 1 addition & 1 deletion hydra-cardano-api/hydra-cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ common project-config
ghc-options:
-Wall -Wcompat -Widentities -Wincomplete-record-updates
-Wincomplete-uni-patterns -Wredundant-constraints -Wunused-packages
-fprint-potential-instances
-Wmissing-deriving-strategies -fprint-potential-instances

library
import: project-config
Expand Down
2 changes: 1 addition & 1 deletion hydra-cluster/src/CardanoClient.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ data Sizes = Sizes
, outputs :: Int
, witnesses :: Int
}
deriving (Eq, Show)
deriving stock (Eq, Show)

defaultSizes :: Sizes
defaultSizes = Sizes{inputs = 0, outputs = 0, witnesses = 0}
Expand Down
2 changes: 1 addition & 1 deletion hydra-cluster/src/CardanoNode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ generateCardanoKey = do
pure (getVerificationKey sk, sk)

data ProcessHasExited = ProcessHasExited Text ExitCode
deriving (Show)
deriving stock (Show)

instance Exception ProcessHasExited

Expand Down
2 changes: 1 addition & 1 deletion hydra-cluster/src/Hydra/Cluster/Faucet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import Hydra.Ledger.Cardano ()
data FaucetException
= FaucetHasNotEnoughFunds {faucetUTxO :: UTxO}
| FaucetFailedToBuildTx {reason :: TxBodyErrorAutoBalance}
deriving (Show)
deriving stock (Show)

instance Exception FaucetException

Expand Down
4 changes: 2 additions & 2 deletions hydra-cluster/src/Hydra/Cluster/Fixture.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ data Actor
| Bob
| Carol
| Faucet
deriving (Eq, Show)
deriving stock (Eq, Show)

actorName :: Actor -> String
actorName = \case
Expand All @@ -63,4 +63,4 @@ data KnownNetwork
= Preview
| Preproduction
| Mainnet
deriving (Show)
deriving stock (Show)
4 changes: 2 additions & 2 deletions hydra-cluster/src/Hydra/Cluster/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ data Options = Options
, stateDirectory :: Maybe FilePath
, publishHydraScripts :: PublishOrReuse
}
deriving (Show)
deriving stock (Show)

data PublishOrReuse = Publish | Reuse TxId
deriving (Show)
deriving stock (Show)

-- TODO: Provide an option to use mithril aggregated snapshots to bootstrap the testnet
parseOptions :: Parser Options
Expand Down
8 changes: 5 additions & 3 deletions hydra-cluster/src/Hydra/Generator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ data Dataset = Dataset
, title :: Maybe Text
, description :: Maybe Text
}
deriving (Show, Generic, ToJSON, FromJSON)
deriving stock (Show, Generic)
deriving anyclass (ToJSON, FromJSON)

instance Arbitrary Dataset where
arbitrary = sized $ \n -> do
Expand All @@ -39,7 +40,7 @@ data ClientKeys = ClientKeys
, externalSigningKey :: SigningKey PaymentKey
-- ^ Key holding funds to commit.
}
deriving (Show)
deriving stock (Show)

instance ToJSON ClientKeys where
toJSON ClientKeys{signingKey, externalSigningKey} =
Expand All @@ -66,7 +67,8 @@ data ClientDataset = ClientDataset
, initialUTxO :: UTxO
, txSequence :: [Tx]
}
deriving (Show, Generic, ToJSON, FromJSON)
deriving stock (Show, Generic)
deriving anyclass (ToJSON, FromJSON)

defaultProtocolParameters :: ProtocolParameters
defaultProtocolParameters = fromLedgerPParams ShelleyBasedEraShelley def
Expand Down
6 changes: 3 additions & 3 deletions hydra-cluster/src/Hydra/LogFilter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ data Trace tx
}
deriving stock (Generic)

deriving instance (IsTx tx) => Eq (Trace tx)
deriving instance (IsTx tx) => Show (Trace tx)
deriving instance (IsTx tx) => ToJSON (Trace tx)
deriving stock instance (IsTx tx) => Eq (Trace tx)
deriving stock instance (IsTx tx) => Show (Trace tx)
deriving anyclass instance (IsTx tx) => ToJSON (Trace tx)

data TraceKey
= EventKey Word64
Expand Down
3 changes: 2 additions & 1 deletion hydra-cluster/src/HydraNode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ data EndToEndLog
| PublishedHydraScriptsAt {hydraScriptsTxId :: TxId}
| UsingHydraScriptsAt {hydraScriptsTxId :: TxId}
| CreatedKey {keyPath :: FilePath}
deriving (Eq, Show, Generic, ToJSON, FromJSON, ToObject)
deriving stock (Eq, Show, Generic)
deriving anyclass (ToJSON, FromJSON, ToObject)

-- XXX: The two lists need to be of same length. Also the verification keys can
-- be derived from the signing keys.
Expand Down
3 changes: 2 additions & 1 deletion hydra-cluster/test/Test/DirectChainSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ data DirectChainTestLog
= FromNode NodeLog
| FromDirectChain Text DirectChainLog
| FromFaucet FaucetLog
deriving (Show, Generic, ToJSON)
deriving stock (Show, Generic)
deriving anyclass (ToJSON)

data DirectChainTest tx m = DirectChainTest
{ postTx :: PostChainTx tx -> m ()
Expand Down
2 changes: 1 addition & 1 deletion hydra-node/exe/hydra-node/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import Hydra.Persistence (createPersistenceIncremental)
import Hydra.Utils (genHydraKeys)

newtype ConfigurationParseException = ConfigurationParseException ProtocolParametersConversionError
deriving (Show)
deriving stock (Show)

instance Exception ConfigurationParseException

Expand Down
4 changes: 2 additions & 2 deletions hydra-node/src/Hydra/API/APIServerLog.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ instance Arbitrary APIServerLog where

-- | New type wrapper to define JSON instances.
newtype PathInfo = PathInfo ByteString
deriving (Eq, Show)
deriving stock (Eq, Show)

instance Arbitrary PathInfo where
arbitrary =
Expand All @@ -55,7 +55,7 @@ instance FromJSON PathInfo where
-- NOTE: We are not using http-types 'StdMethod' as we do not want to be
-- constrained in terms of logging and accept any method in a 'Request'.
newtype Method = Method ByteString
deriving (Eq, Show)
deriving stock (Eq, Show)

instance Arbitrary Method where
arbitrary = Method . renderStdMethod <$> chooseEnum (minBound, maxBound)
Expand Down
10 changes: 5 additions & 5 deletions hydra-node/src/Hydra/API/ClientInput.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ data ClientInput tx
| Close
| Contest
| Fanout
deriving (Generic)
deriving stock (Generic)

deriving instance IsTx tx => Eq (ClientInput tx)
deriving instance IsTx tx => Show (ClientInput tx)
deriving instance IsTx tx => ToJSON (ClientInput tx)
deriving instance IsTx tx => FromJSON (ClientInput tx)
deriving stock instance IsTx tx => Eq (ClientInput tx)
deriving stock instance IsTx tx => Show (ClientInput tx)
deriving anyclass instance IsTx tx => ToJSON (ClientInput tx)
deriving anyclass instance IsTx tx => FromJSON (ClientInput tx)

instance Arbitrary tx => Arbitrary (ClientInput tx) where
arbitrary = genericArbitrary
Expand Down
2 changes: 1 addition & 1 deletion hydra-node/src/Hydra/API/HTTPServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import Network.Wai (
newtype DraftCommitTxResponse = DraftCommitTxResponse
{ commitTx :: Tx
}
deriving (Show, Generic)
deriving stock (Show, Generic)

instance ToJSON DraftCommitTxResponse where
toJSON (DraftCommitTxResponse tx) =
Expand Down
2 changes: 1 addition & 1 deletion hydra-node/src/Hydra/API/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ data RunServerException = RunServerException
, host :: IP
, port :: PortNumber
}
deriving (Show)
deriving stock (Show)

instance Exception RunServerException

Expand Down
15 changes: 8 additions & 7 deletions hydra-node/src/Hydra/API/ServerOutput.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ data ServerOutput tx
Greetings {me :: Party, headStatus :: HeadStatus, snapshotUtxo :: Maybe (UTxOType tx), hydraNodeVersion :: String}
| PostTxOnChainFailed {postChainTx :: PostChainTx tx, postTxError :: PostTxError tx}
| IgnoredHeadInitializing {headId :: HeadId, participants :: [OnChainId]}
deriving (Generic)
deriving stock (Generic)

deriving instance (IsChainState tx) => Eq (ServerOutput tx)
deriving instance (IsChainState tx) => Show (ServerOutput tx)
deriving stock instance (IsChainState tx) => Eq (ServerOutput tx)
deriving stock instance (IsChainState tx) => Show (ServerOutput tx)

instance (IsChainState tx) => ToJSON (ServerOutput tx) where
toJSON =
Expand Down Expand Up @@ -148,17 +148,17 @@ instance
data OutputFormat
= OutputCBOR
| OutputJSON
deriving (Eq, Show)
deriving stock (Eq, Show)

-- | Whether or not to include full UTxO in server outputs.
data WithUTxO = WithUTxO | WithoutUTxO
deriving (Eq, Show)
deriving stock (Eq, Show)

data ServerOutputConfig = ServerOutputConfig
{ txOutputFormat :: OutputFormat
, utxoInSnapshot :: WithUTxO
}
deriving (Eq, Show)
deriving stock (Eq, Show)

-- | Replaces the json encoded tx field with it's cbor representation.
--
Expand Down Expand Up @@ -236,7 +236,8 @@ data HeadStatus
| Closed
| FanoutPossible
| Final
deriving (Eq, Show, Generic, ToJSON, FromJSON)
deriving stock (Eq, Show, Generic)
deriving anyclass (ToJSON, FromJSON)

instance Arbitrary HeadStatus where
arbitrary = genericArbitrary
Expand Down
64 changes: 32 additions & 32 deletions hydra-node/src/Hydra/Chain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,20 @@ data PostChainTx tx
| FanoutTx {utxo :: UTxOType tx, contestationDeadline :: UTCTime}
deriving stock (Generic)

deriving instance IsTx tx => Eq (PostChainTx tx)
deriving instance IsTx tx => Show (PostChainTx tx)
deriving instance IsTx tx => ToJSON (PostChainTx tx)
deriving instance IsTx tx => FromJSON (PostChainTx tx)
deriving stock instance (IsTx tx) => Eq (PostChainTx tx)
deriving stock instance (IsTx tx) => Show (PostChainTx tx)
deriving anyclass instance (IsTx tx) => ToJSON (PostChainTx tx)
deriving anyclass instance (IsTx tx) => FromJSON (PostChainTx tx)

instance IsTx tx => Arbitrary (PostChainTx tx) where
instance (IsTx tx) => Arbitrary (PostChainTx tx) where
arbitrary = genericArbitrary

-- REVIEW(SN): There is a similarly named type in plutus-ledger, so we might
-- want to rename this

-- | Uniquely identifies a Hydra Head.
newtype HeadId = HeadId ByteString
deriving (Show, Eq, Ord, Generic)
deriving stock (Show, Eq, Ord, Generic)
deriving (ToJSON, FromJSON) via (UsingRawBytesHex HeadId)

instance SerialiseAsRawBytes HeadId where
Expand Down Expand Up @@ -130,12 +130,12 @@ data OnChainTx tx
}
| OnContestTx {snapshotNumber :: SnapshotNumber}
| OnFanoutTx
deriving (Generic)
deriving stock (Generic)

deriving instance IsTx tx => Eq (OnChainTx tx)
deriving instance IsTx tx => Show (OnChainTx tx)
deriving instance IsTx tx => ToJSON (OnChainTx tx)
deriving instance IsTx tx => FromJSON (OnChainTx tx)
deriving stock instance (IsTx tx) => Eq (OnChainTx tx)
deriving stock instance (IsTx tx) => Show (OnChainTx tx)
deriving anyclass instance (IsTx tx) => ToJSON (OnChainTx tx)
deriving anyclass instance (IsTx tx) => FromJSON (OnChainTx tx)

instance (Arbitrary tx, Arbitrary (UTxOType tx)) => Arbitrary (OnChainTx tx) where
arbitrary = genericArbitrary
Expand Down Expand Up @@ -172,14 +172,14 @@ data PostTxError tx
FailedToDraftTxNotInitializing
| -- | Committing UTxO addressed to the internal wallet is forbidden.
SpendingNodeUtxoForbidden
deriving (Generic)
deriving stock (Generic)

deriving instance IsChainState tx => Eq (PostTxError tx)
deriving instance IsChainState tx => Show (PostTxError tx)
deriving instance IsChainState tx => ToJSON (PostTxError tx)
deriving instance IsChainState tx => FromJSON (PostTxError tx)
deriving stock instance (IsChainState tx) => Eq (PostTxError tx)
deriving stock instance (IsChainState tx) => Show (PostTxError tx)
deriving anyclass instance (IsChainState tx) => ToJSON (PostTxError tx)
deriving anyclass instance (IsChainState tx) => FromJSON (PostTxError tx)

instance IsChainState tx => Exception (PostTxError tx)
instance (IsChainState tx) => Exception (PostTxError tx)

instance Arbitrary Lovelace where
arbitrary = Lovelace <$> scale (* 8) arbitrary `suchThat` (> 0)
Expand All @@ -194,7 +194,7 @@ data ChainStateHistory tx = UnsafeChainStateHistory
{ history :: NonEmpty (ChainStateType tx)
, defaultChainState :: ChainStateType tx
}
deriving (Generic)
deriving stock (Generic)

currentState :: ChainStateHistory tx -> ChainStateType tx
currentState UnsafeChainStateHistory{history} = head history
Expand All @@ -205,7 +205,7 @@ pushNewState cs h@UnsafeChainStateHistory{history} = h{history = cs <| history}
initHistory :: ChainStateType tx -> ChainStateHistory tx
initHistory cs = UnsafeChainStateHistory{history = cs :| [], defaultChainState = cs}

rollbackHistory :: IsChainState tx => ChainSlot -> ChainStateHistory tx -> ChainStateHistory tx
rollbackHistory :: (IsChainState tx) => ChainSlot -> ChainStateHistory tx -> ChainStateHistory tx
rollbackHistory rollbackChainSlot h@UnsafeChainStateHistory{history, defaultChainState} =
h{history = fromMaybe (defaultChainState :| []) (nonEmpty rolledBack)}
where
Expand All @@ -214,12 +214,12 @@ rollbackHistory rollbackChainSlot h@UnsafeChainStateHistory{history, defaultChai
(\cs -> chainStateSlot cs > rollbackChainSlot)
(toList history)

deriving instance Eq (ChainStateType tx) => Eq (ChainStateHistory tx)
deriving instance Show (ChainStateType tx) => Show (ChainStateHistory tx)
deriving anyclass instance ToJSON (ChainStateType tx) => ToJSON (ChainStateHistory tx)
deriving anyclass instance FromJSON (ChainStateType tx) => FromJSON (ChainStateHistory tx)
deriving stock instance (Eq (ChainStateType tx)) => Eq (ChainStateHistory tx)
deriving stock instance (Show (ChainStateType tx)) => Show (ChainStateHistory tx)
deriving anyclass instance (ToJSON (ChainStateType tx)) => ToJSON (ChainStateHistory tx)
deriving anyclass instance (FromJSON (ChainStateType tx)) => FromJSON (ChainStateHistory tx)

instance Arbitrary (ChainStateType tx) => Arbitrary (ChainStateHistory tx) where
instance (Arbitrary (ChainStateType tx)) => Arbitrary (ChainStateHistory tx) where
arbitrary = genericArbitrary

-- | Interface available from a chain state. Expected to be instantiated by all
Expand All @@ -242,7 +242,7 @@ class

-- | Handle to interface with the main chain network
data Chain tx m = Chain
{ postTx :: MonadThrow m => PostChainTx tx -> m ()
{ postTx :: (MonadThrow m) => PostChainTx tx -> m ()
-- ^ Construct and send a transaction to the main chain corresponding to the
-- given 'PostChainTx' description.
-- This function is not expected to block, so it is only responsible for
Expand All @@ -251,12 +251,12 @@ data Chain tx m = Chain
--
-- Does at least throw 'PostTxError'.
, draftCommitTx ::
MonadThrow m =>
(MonadThrow m) =>
UTxO' (TxOut CtxUTxO, Witness WitCtxTxIn) ->
m (Either (PostTxError Tx) Tx)
-- ^ Create a commit transaction using user provided utxos (zero or many) and
-- information to spend from a script. Errors are handled at the call site.
, submitTx :: MonadThrow m => Tx -> m ()
, submitTx :: (MonadThrow m) => Tx -> m ()
-- ^ Submit a cardano transaction.
--
-- Throws at least 'PostTxError'.
Expand Down Expand Up @@ -293,12 +293,12 @@ data ChainEvent tx
{ chainTime :: UTCTime
, chainSlot :: ChainSlot
}
deriving (Generic)
deriving stock (Generic)

deriving instance (IsTx tx, Eq (ChainStateType tx)) => Eq (ChainEvent tx)
deriving instance (IsTx tx, Show (ChainStateType tx)) => Show (ChainEvent tx)
deriving instance (IsTx tx, ToJSON (ChainStateType tx)) => ToJSON (ChainEvent tx)
deriving instance (IsTx tx, FromJSON (ChainStateType tx)) => FromJSON (ChainEvent tx)
deriving stock instance (IsTx tx, Eq (ChainStateType tx)) => Eq (ChainEvent tx)
deriving stock instance (IsTx tx, Show (ChainStateType tx)) => Show (ChainEvent tx)
deriving anyclass instance (IsTx tx, ToJSON (ChainStateType tx)) => ToJSON (ChainEvent tx)
deriving anyclass instance (IsTx tx, FromJSON (ChainStateType tx)) => FromJSON (ChainEvent tx)

instance
( Arbitrary tx
Expand Down
Loading

0 comments on commit 57c031a

Please sign in to comment.