Skip to content

Commit b84c973

Browse files
committed
Remove NoImplicitPrelude from cardano-api. We import Prelude explicitly from the majority of cardano-api modules. Removing this language extension makes this unnecessary.
1 parent 9665b3d commit b84c973

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+69
-179
lines changed

cardano-api/cardano-api.cabal

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ extra-source-files: README.md, ChangeLog.md
1717

1818
common project-config
1919
default-language: Haskell2010
20-
default-extensions: NoImplicitPrelude
21-
OverloadedStrings
20+
default-extensions: OverloadedStrings
2221
build-depends: base >= 4.14 && < 4.15
2322

2423
ghc-options: -Wall
@@ -211,6 +210,7 @@ test-suite cardano-api-test
211210
type: exitcode-stdio-1.0
212211

213212
build-depends: aeson >= 1.5.6.0
213+
, bytestring
214214
, cardano-api
215215
, cardano-api:gen
216216
, cardano-data ^>= 0.1
@@ -219,7 +219,6 @@ test-suite cardano-api-test
219219
, cardano-crypto-test ^>= 1.4
220220
, cardano-crypto-tests ^>= 2.0
221221
, cardano-ledger-core ^>= 0.1
222-
, cardano-prelude
223222
, cardano-slotting ^>= 0.1
224223
, containers
225224
, hedgehog

cardano-api/gen/Gen/Cardano/Api.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ module Gen.Cardano.Api
88
, genAlonzoGenesis
99
) where
1010

11-
import Cardano.Prelude
11+
import Cardano.Prelude (panic)
1212

1313
import Cardano.Api.Shelley as Api
1414

15-
import Control.Monad (MonadFail (fail))
1615
import qualified Data.Map.Strict as Map
1716
import qualified Data.Text as Text
17+
import Data.Word (Word64)
1818

1919
--TODO: why do we have this odd split? We can get rid of the old name "typed"
2020
import Gen.Cardano.Api.Typed (genCostModel, genRational)
@@ -26,7 +26,6 @@ import qualified Cardano.Ledger.BaseTypes as Ledger
2626
import qualified Cardano.Ledger.Coin as Ledger
2727
import Cardano.Ledger.Shelley.Metadata (Metadata (..), Metadatum (..))
2828

29-
3029
import Hedgehog (Gen, Range)
3130
import qualified Hedgehog.Gen as Gen
3231
import qualified Hedgehog.Internal.Range as Range
@@ -97,7 +96,6 @@ genCostModels = do
9796
Right alonzoCostModel ->
9897
Alonzo.CostModels . conv <$> Gen.list (Range.linear 1 3) (return alonzoCostModel)
9998
where
100-
conv :: [Alonzo.CostModel] -> Map Alonzo.Language Alonzo.CostModel
10199
conv [] = mempty
102100
conv (c : rest) = Map.singleton (Alonzo.getCostModelLanguage c) c <> conv rest
103101

cardano-api/gen/Gen/Cardano/Api/Metadata.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ module Gen.Cardano.Api.Metadata
77
) where
88

99
import Cardano.Api
10-
import Cardano.Prelude
1110
import Data.Aeson (ToJSON (..))
11+
import Data.ByteString (ByteString)
12+
import Data.Text (Text)
13+
import Data.Word (Word64)
1214
import Hedgehog (Gen)
1315

1416
import qualified Data.Aeson as Aeson

cardano-api/gen/Gen/Cardano/Api/Typed.hs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ module Gen.Cardano.Api.Typed
105105
, genRational
106106
) where
107107

108+
import Cardano.Prelude (panic)
109+
108110
import Cardano.Api hiding (txIns)
109111
import qualified Cardano.Api as Api
110112
import Cardano.Api.Byron (KeyWitness (ByronKeyWitness),
@@ -116,14 +118,18 @@ import Cardano.Api.Shelley (Hash (ScriptDataHash), KESPeriod (KESPerio
116118
StakeCredential (StakeCredentialByKey), StakePoolKey,
117119
refInsScriptsAndInlineDatsSupportedInEra)
118120

119-
import Cardano.Prelude
120-
121-
import Control.Monad.Fail (fail)
121+
import Data.ByteString (ByteString)
122122
import qualified Data.ByteString as BS
123123
import qualified Data.ByteString.Short as SBS
124124
import Data.Coerce
125+
import Data.Int (Int64)
126+
import Data.Map.Strict (Map)
127+
import Data.Maybe (maybeToList)
128+
import Data.Ratio (Ratio, (%))
125129
import Data.String
126130
import qualified Data.Text as Text
131+
import Data.Word (Word64)
132+
import Numeric.Natural (Natural)
127133

128134
import qualified Cardano.Binary as CBOR
129135
import qualified Cardano.Crypto.Hash as Crypto

cardano-api/gen/Gen/Cardano/Crypto/Seed.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ module Gen.Cardano.Crypto.Seed
55

66
import Cardano.Api (AsType, Key)
77
import Cardano.Crypto.Seed (Seed)
8-
import Data.Functor ((<$>))
9-
import Data.Int (Int)
108
import Hedgehog (MonadGen, Range)
11-
import Prelude (fromIntegral)
129

1310
import qualified Cardano.Api as API
1411
import qualified Cardano.Crypto.Seed as C

cardano-api/gen/Gen/Hedgehog/Roundtrip/Bech32.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module Gen.Hedgehog.Roundtrip.Bech32
33
) where
44

55
import Cardano.Api
6-
import Cardano.Prelude
76
import Hedgehog (Gen, Property)
87

98
import qualified Hedgehog as H

cardano-api/gen/Gen/Hedgehog/Roundtrip/CBOR.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ module Gen.Hedgehog.Roundtrip.CBOR
66
) where
77

88
import Cardano.Api
9-
import Cardano.Prelude
109
import Hedgehog (Gen, Property)
1110

1211
import qualified Hedgehog as H

cardano-api/src/Cardano/Api/Address.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ module Cardano.Api.Address (
7676
isKeyAddress
7777
) where
7878

79-
import Prelude
80-
8179
import Control.Applicative ((<|>))
8280
import Data.Aeson (FromJSON (..), ToJSON (..), withText, (.=))
8381
import qualified Data.Aeson as Aeson
@@ -104,7 +102,6 @@ import Cardano.Api.EraCast
104102
import Cardano.Api.Eras
105103
import Cardano.Api.Hash
106104
import Cardano.Api.HasTypeProxy
107-
import Cardano.Api.Keys.Class
108105
import Cardano.Api.Keys.Byron
109106
import Cardano.Api.Keys.Shelley
110107
import Cardano.Api.NetworkId

cardano-api/src/Cardano/Api/Block.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ module Cardano.Api.Block (
4848
makeChainTip,
4949
) where
5050

51-
import Prelude
52-
5351
import Data.Aeson (FromJSON (..), ToJSON (..), object, (.=))
5452
import qualified Data.Aeson as Aeson
5553
import qualified Data.ByteString as BS

cardano-api/src/Cardano/Api/Certificate.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ module Cardano.Api.Certificate (
3636
AsType(..)
3737
) where
3838

39-
import Prelude
40-
4139
import Data.ByteString (ByteString)
4240
import qualified Data.Foldable as Foldable
4341
import qualified Data.Map.Strict as Map
@@ -62,8 +60,8 @@ import Cardano.Ledger.Shelley.TxBody (MIRPot (..))
6260
import qualified Cardano.Ledger.Shelley.TxBody as Shelley
6361

6462
import Cardano.Api.Address
65-
import Cardano.Api.HasTypeProxy
6663
import Cardano.Api.Hash
64+
import Cardano.Api.HasTypeProxy
6765
import Cardano.Api.Keys.Byron
6866
import Cardano.Api.Keys.Praos
6967
import Cardano.Api.Keys.Shelley

cardano-api/src/Cardano/Api/Convenience/Construction.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ module Cardano.Api.Convenience.Construction (
1313

1414
) where
1515

16-
import Prelude
17-
1816
import qualified Data.List as List
1917
import qualified Data.Map.Strict as Map
2018
import Data.Set (Set)

cardano-api/src/Cardano/Api/Convenience/Query.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ module Cardano.Api.Convenience.Query (
1313
renderQueryConvenienceError,
1414
) where
1515

16-
import Prelude
17-
1816
import Control.Monad.Trans.Except (ExceptT (..), except, runExceptT)
1917
import Control.Monad.Trans.Except.Extra (firstExceptT, hoistMaybe)
2018
import Data.Bifunctor (first)

cardano-api/src/Cardano/Api/Crypto/Ed25519Bip32.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ module Cardano.Api.Crypto.Ed25519Bip32
1818
)
1919
where
2020

21-
import Cardano.Prelude hiding (show)
22-
import Prelude (show)
23-
21+
import Control.DeepSeq (NFData)
2422
import Data.ByteArray as BA (ByteArrayAccess, ScrubbedBytes, convert)
23+
import Data.ByteString (ByteString)
2524
import qualified Data.ByteString as BS
25+
import GHC.Generics (Generic)
2626
import NoThunks.Class (InspectHeap (..), NoThunks)
2727

2828
import Cardano.Binary (FromCBOR (..), ToCBOR (..))

cardano-api/src/Cardano/Api/DeserialiseAnyOf.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ module Cardano.Api.DeserialiseAnyOf
1818
, renderSomeAddressVerificationKey
1919
) where
2020

21-
import Prelude
22-
2321
import qualified Data.Aeson as Aeson
2422
import Data.Bifunctor (first)
2523
import Data.ByteString (ByteString)
@@ -42,8 +40,8 @@ import Cardano.Api.SerialiseTextEnvelope
4240

4341
-- TODO: Think about if these belong
4442
import Cardano.Api.Address
45-
import Cardano.Api.Keys.Class
4643
import Cardano.Api.Keys.Byron
44+
import Cardano.Api.Keys.Class
4745
import Cardano.Api.Keys.Praos
4846
import Cardano.Api.Keys.Shelley
4947

cardano-api/src/Cardano/Api/Environment.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ module Cardano.Api.Environment
88
, renderEnvSocketError
99
) where
1010

11-
import Prelude
12-
1311
import Data.Aeson
1412
import Data.Text (Text)
1513
import qualified Data.Text as Text

cardano-api/src/Cardano/Api/EraCast.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ module Cardano.Api.EraCast
77
) where
88

99
import Cardano.Api.Eras (CardanoEra (..), IsCardanoEra)
10-
import Data.Either (Either)
1110
import Data.Kind (Type)
12-
import Text.Show (Show (..))
1311

1412
data EraCastError = forall fromEra toEra value.
1513
( IsCardanoEra fromEra

cardano-api/src/Cardano/Api/Eras.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ module Cardano.Api.Eras
4646
AsByron, AsShelley, AsAllegra, AsMary, AsAlonzo, AsBabbage)
4747
) where
4848

49-
import Prelude
50-
5149
import Cardano.Api.HasTypeProxy
5250

5351
import Control.DeepSeq

cardano-api/src/Cardano/Api/Error.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ module Cardano.Api.Error
1010
, FileError(..)
1111
) where
1212

13-
import Prelude
14-
1513
import Control.Exception (Exception (..), IOException, throwIO)
1614
import System.IO (Handle)
1715

cardano-api/src/Cardano/Api/Fees.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ module Cardano.Api.Fees (
4141
toLedgerEpochInfo,
4242
) where
4343

44-
import Prelude
45-
4644
import qualified Data.Array as Array
4745
import Data.Bifunctor (bimap, first)
4846
import qualified Data.ByteString as BS
@@ -55,8 +53,8 @@ import Data.Set (Set)
5553
import qualified Data.Set as Set
5654
import qualified Data.Text as Text
5755
import GHC.Records (HasField (..))
58-
import Numeric.Natural
5956
import Lens.Micro ((^.))
57+
import Numeric.Natural
6058

6159
import Control.Monad.Trans.Except
6260
import qualified Prettyprinter as PP
@@ -947,7 +945,7 @@ makeTransactionBodyAutoBalance eraInMode systemstart history pparams
947945
-- 4. balance the transaction and update tx change output
948946
txbody0 <-
949947
first TxBodyError $ createAndValidateTransactionBody txbodycontent
950-
{ txOuts = txOuts txbodycontent ++
948+
{ txOuts = txOuts txbodycontent ++
951949
[TxOut changeaddr (lovelaceToTxOutValue 0) TxOutDatumNone ReferenceScriptNone]
952950
--TODO: think about the size of the change output
953951
-- 1,2,4 or 8 bytes?

cardano-api/src/Cardano/Api/Genesis.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ module Cardano.Api.Genesis
66
, shelleyGenesisDefaults
77
) where
88

9-
import Prelude
10-
119
import qualified Data.ListMap as ListMap
1210
import qualified Data.Map.Strict as Map
1311
import Data.Maybe (fromMaybe)

cardano-api/src/Cardano/Api/GenesisParameters.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ module Cardano.Api.GenesisParameters (
1616

1717
) where
1818

19-
import Prelude
20-
2119
import Data.Time (NominalDiffTime, UTCTime)
2220

2321
import Cardano.Slotting.Slot (EpochSize (..))

cardano-api/src/Cardano/Api/IPC.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ module Cardano.Api.IPC (
8080
NodeToClientVersion(..)
8181
) where
8282

83-
import Prelude
84-
8583
import Data.Void (Void)
8684

8785
import Data.Aeson (ToJSON, object, toJSON, (.=))

cardano-api/src/Cardano/Api/IPC/Monad.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,12 @@ module Cardano.Api.IPC.Monad
99
, determineEraExpr
1010
) where
1111

12-
import Control.Applicative
1312
import Control.Concurrent.STM
1413
import Control.Monad
1514
import Control.Monad.IO.Class
1615
import Control.Monad.Reader
1716
import Control.Monad.Trans.Cont
1817
import Data.Bifunctor (first)
19-
import Data.Either
20-
import Data.Function
21-
import Data.Maybe
22-
import System.IO
2318

2419
import Cardano.Ledger.Shelley.Scripts ()
2520
import qualified Ouroboros.Network.Protocol.LocalStateQuery.Client as Net.Query

cardano-api/src/Cardano/Api/IPC/Version.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ module Cardano.Api.IPC.Version
66
, UnsupportedNtcVersionError(..)
77
) where
88

9-
import Data.Eq (Eq)
10-
import Text.Show (Show)
11-
129
import Ouroboros.Network.NodeToClient.Version (NodeToClientVersion (..))
1310

1411
-- | The query 'a' is a versioned query, which means it requires the Node to support a minimum

cardano-api/src/Cardano/Api/InMode.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ module Cardano.Api.InMode (
2424
fromConsensusApplyTxErr,
2525
) where
2626

27-
import Prelude
28-
2927
import Data.SOP.Strict (NS (S, Z))
3028

3129
import qualified Ouroboros.Consensus.Byron.Ledger as Consensus

cardano-api/src/Cardano/Api/Json.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ module Cardano.Api.Json
33
) where
44

55
import Data.Aeson
6-
import Data.Either
7-
import Data.Maybe
86
import Data.Scientific
9-
import GHC.Real
107

118
-- Rationals and JSON are an awkward mix. We cannot convert rationals
129
-- like @1/3@ to JSON numbers. But _most_ of the numbers we want to use

0 commit comments

Comments
 (0)