Skip to content

Commit e49cb6f

Browse files
author
Evgenii Akentev
authored
Turn on NoImplicitPrelude in PlutusTx and reduce the number of Prelude imports (IntersectMBO#3955)
* Turn on NoImplicitPrelude in PlutusTx and reduce the number of Prelude imports. * Add qualified imports. Remove monad functions. * Get monad functions back * fix plutus-contract and update test data * Add PlutusTx.Base comment.
1 parent 8ce0d58 commit e49cb6f

File tree

53 files changed

+727
-915
lines changed

Some content is hidden

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

53 files changed

+727
-915
lines changed

nix/pkgs/haskell/materialized-darwin/.plan.nix/plutus-tx.nix

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/pkgs/haskell/materialized-linux/.plan.nix/plutus-tx.nix

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/pkgs/haskell/materialized-windows/.plan.nix/plutus-tx.nix

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plutus-contract/src/Plutus/Contract/Secrets.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Data.Aeson as Aeson (FromJSON (..), ToJSON (.
1515
import Data.Aeson.Encoding.Internal (string)
1616
import Data.String
1717
import PlutusTx.Prelude as PlutusTx
18-
import Prelude as Haskell
18+
import qualified Prelude as Haskell
1919

2020
-- | A secret value. A value of type `Secret a` can't leak onto
2121
-- the blockchain in plain-text unless you use an unsafe function.
@@ -54,7 +54,7 @@ newtype Secret a = MkSecret a
5454
-- bypassed by safe code.
5555
data SecretArgument a = UserSide a
5656
| EndpointSide (Secret a)
57-
deriving Show
57+
deriving Haskell.Show
5858

5959
{- Note [Secret arguments]
6060
When we write endpoint code we would like to specify the argument type
@@ -89,9 +89,9 @@ instance ToJSON a => ToJSON (SecretArgument a) where
8989
toEncoding (EndpointSide _) = string "EndpointSide *****"
9090

9191
instance FromJSON a => FromJSON (SecretArgument a) where
92-
parseJSON = liftM (EndpointSide . mkSecret) . parseJSON
92+
parseJSON = liftM (EndpointSide Haskell.. mkSecret) Haskell.. parseJSON
9393

94-
instance Show (Secret a) where
94+
instance Haskell.Show (Secret a) where
9595
show (MkSecret _) = "*****"
9696

9797
instance Haskell.Functor Secret where

plutus-ledger-api/src/Plutus/V1/Ledger/Scripts.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ instance Flat.Flat a => Serialise (SerialiseViaFlat a) where
123123
bs <- decodeBytes
124124
case Flat.unflat bs of
125125
Left err -> Haskell.fail (Haskell.show err)
126-
Right v -> return (SerialiseViaFlat v)
126+
Right v -> Haskell.return (SerialiseViaFlat v)
127127

128128
{- Note [Eq and Ord for Scripts]
129129
We need `Eq` and `Ord` instances for `Script`s mostly so we can put them in `Set`s.
@@ -194,7 +194,7 @@ mkTermToEvaluate (Script (UPLC.Program a v t)) =
194194
evaluateScript :: forall m . (MonadError ScriptError m) => Script -> m (PLC.ExBudget, [Text])
195195
evaluateScript s = do
196196
p <- case mkTermToEvaluate s of
197-
Right p -> return p
197+
Right p -> Haskell.return p
198198
Left e -> throwError $ MalformedScript $ Haskell.show e
199199
let (logOut, UPLC.TallyingSt _ budget, result) = evaluateCekTrace p
200200
case result of
@@ -220,7 +220,7 @@ instance FromJSON Script where
220220
-- See note [JSON instances for Script]
221221
parseJSON v = do
222222
(SerialiseViaFlat p) <- JSON.decodeSerialise v
223-
return $ Script p
223+
Haskell.return $ Script p
224224

225225
deriving via (JSON.JSONViaSerialise PLC.Data) instance ToJSON (PLC.Data)
226226
deriving via (JSON.JSONViaSerialise PLC.Data) instance FromJSON (PLC.Data)

plutus-ledger-api/src/Plutus/V1/Ledger/Time.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ newtype POSIXTime = POSIXTime { getPOSIXTime :: Integer }
5858
instance FromJSON POSIXTime where
5959
parseJSON v@(Number n) =
6060
either (\_ -> prependFailure "parsing POSIXTime failed, " (typeMismatch "Integer" v))
61-
(return . POSIXTime)
61+
(Haskell.return . POSIXTime)
6262
(floatingOrInteger n :: Either Haskell.Double Integer)
6363
parseJSON invalid =
6464
prependFailure "parsing POSIXTime failed, " (typeMismatch "Number" invalid)

plutus-tx-plugin/test/Plugin/Typeclasses/concatTest.plc.golden

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -164,34 +164,6 @@
164164
)
165165
fFoldableNil_cfoldMap
166166
)
167-
(termbind
168-
(strict)
169-
(vardecl
170-
bad_name
171-
(all
172-
b
173-
(type)
174-
(all
175-
c
176-
(type)
177-
(all a (type) (fun (fun b c) (fun (fun a b) (fun a c))))
178-
)
179-
)
180-
)
181-
(abs
182-
b
183-
(type)
184-
(abs
185-
c
186-
(type)
187-
(abs
188-
a
189-
(type)
190-
(lam f (fun b c) (lam g (fun a b) (lam x a [ f [ g x ] ])))
191-
)
192-
)
193-
)
194-
)
195167
(termbind
196168
(strict)
197169
(vardecl
@@ -215,9 +187,7 @@
215187
ds
216188
[ (lam a (type) (fun a a)) a ]
217189
(lam
218-
ds
219-
[ (lam a (type) (fun a a)) a ]
220-
[ [ { { { bad_name a } a } a } ds ] ds ]
190+
ds [ (lam a (type) (fun a a)) a ] (lam x a [ ds [ ds x ] ])
221191
)
222192
)
223193
)
@@ -245,6 +215,29 @@
245215
]
246216
)
247217
)
218+
(termbind
219+
(strict)
220+
(vardecl
221+
appEndo
222+
(all
223+
a
224+
(type)
225+
(fun
226+
[ (lam a (type) (fun a a)) a ]
227+
[ (lam a (type) (fun a a)) a ]
228+
)
229+
)
230+
)
231+
(abs a (type) (lam ds [ (lam a (type) (fun a a)) a ] ds))
232+
)
233+
(termbind
234+
(nonstrict)
235+
(vardecl
236+
appEndo
237+
(all a (type) (fun [ (lam a (type) (fun a a)) a ] (fun a a)))
238+
)
239+
appEndo
240+
)
248241
(termbind
249242
(strict)
250243
(vardecl
@@ -339,48 +332,57 @@
339332
b
340333
[
341334
[
335+
{ appEndo b }
342336
[
343337
[
344-
{
338+
[
345339
{
346-
dFoldable
347-
[ (lam a (type) (fun a a)) b ]
340+
{
341+
dFoldable
342+
[ (lam a (type) (fun a a)) b ]
343+
}
344+
[ List a ]
348345
}
349-
[ List a ]
350-
}
351-
{ fMonoidEndo b }
352-
]
353-
(lam
354-
x
355-
[ List a ]
346+
{ fMonoidEndo b }
347+
]
356348
(lam
357-
y
358-
b
359-
[
349+
x
350+
[ List a ]
351+
(lam
352+
y
353+
b
360354
[
361355
[
356+
{ appEndo b }
362357
[
363-
{
364-
{
365-
fFoldableNil_cfoldMap
366-
[
367-
(lam a (type) (fun a a)) b
368-
]
369-
}
370-
a
371-
}
372-
{ fMonoidEndo b }
358+
[
359+
[
360+
{
361+
{
362+
fFoldableNil_cfoldMap
363+
[
364+
(lam
365+
a (type) (fun a a)
366+
)
367+
b
368+
]
369+
}
370+
a
371+
}
372+
{ fMonoidEndo b }
373+
]
374+
c
375+
]
376+
x
373377
]
374-
c
375378
]
376-
x
379+
y
377380
]
378-
y
379-
]
381+
)
380382
)
381-
)
383+
]
384+
xs
382385
]
383-
xs
384386
]
385387
n
386388
]

plutus-tx/plutus-tx.cabal

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ common lang
2323
default-extensions: ExplicitForAll ScopedTypeVariables
2424
DeriveGeneric StandaloneDeriving DeriveLift
2525
GeneralizedNewtypeDeriving DeriveFunctor DeriveFoldable
26-
DeriveTraversable
26+
DeriveTraversable NoImplicitPrelude
2727
ghc-options: -Wall -Wnoncanonical-monad-instances -Wunused-packages
2828
-Wincomplete-uni-patterns -Wincomplete-record-updates
2929
-Wredundant-constraints -Widentities
@@ -40,6 +40,7 @@ library
4040
PlutusTx.Prelude
4141
PlutusTx.Evaluation
4242
PlutusTx.Applicative
43+
PlutusTx.Base
4344
PlutusTx.Bool
4445
PlutusTx.IsData
4546
PlutusTx.IsData.Class
@@ -52,6 +53,7 @@ library
5253
PlutusTx.Lattice
5354
PlutusTx.List
5455
PlutusTx.Ord
56+
PlutusTx.Integer
5557
PlutusTx.Maybe
5658
PlutusTx.Monoid
5759
PlutusTx.Numeric

plutus-tx/src/PlutusTx/Applicative.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
{-# LANGUAGE NoImplicitPrelude #-}
21
{-# OPTIONS_GHC -fno-omit-interface-pragmas #-}
32
module PlutusTx.Applicative where
43

54
import Control.Applicative (Const (..))
65
import Data.Functor.Identity (Identity (..))
6+
import PlutusTx.Base
7+
import PlutusTx.Bool (Bool)
8+
import PlutusTx.Either (Either (..))
79
import PlutusTx.Functor
10+
import PlutusTx.Maybe (Maybe (..))
811
import PlutusTx.Monoid (Monoid (..), mappend)
9-
import Prelude (Bool, Either (..), Maybe (..))
1012

1113
{- HLINT ignore -}
1214

plutus-tx/src/PlutusTx/AssocMap.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
{-# LANGUAGE LambdaCase #-}
66
{-# LANGUAGE MonoLocalBinds #-}
77
{-# LANGUAGE MultiParamTypeClasses #-}
8-
{-# LANGUAGE NoImplicitPrelude #-}
98
{-# LANGUAGE TemplateHaskell #-}
109
{-# LANGUAGE TupleSections #-}
1110
{-# LANGUAGE UndecidableInstances #-}

0 commit comments

Comments
 (0)