From 48c326a1c155be44b67a366241eb29c80e3beed2 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Wed, 15 Feb 2023 14:29:42 +0000 Subject: [PATCH] Remove annotation from Version (#5148) It's not useful, we don't need a position for it or any other kind of annotation really. --- ...227_michael.peyton-jones_no_ann_version.md | 4 ++ .../src/PlutusCore/Executable/Common.hs | 6 +-- plutus-core/plutus-core.cabal | 1 + plutus-core/plutus-core/src/PlutusCore.hs | 2 +- .../PlutusCore/Core/Instance/Pretty/Common.hs | 4 +- .../src/PlutusCore/Core/Instance/Scoping.hs | 2 +- .../plutus-core/src/PlutusCore/Core/Type.hs | 36 ++----------- .../plutus-core/src/PlutusCore/Flat.hs | 6 +-- .../src/PlutusCore/Parser/ParserCommon.hs | 13 +---- .../plutus-core/src/PlutusCore/Version.hs | 53 +++++++++++++++++++ .../PlutusCore/Generators/Hedgehog/AST.hs | 4 +- .../PlutusCore/Generators/Hedgehog/Test.hs | 2 +- plutus-core/testlib/PlutusIR/Test.hs | 2 +- .../src/UntypedPlutusCore.hs | 4 +- .../src/UntypedPlutusCore/Core/Type.hs | 2 +- .../src/UntypedPlutusCore/Parser.hs | 2 +- .../src/PlutusLedgerApi/Common/Eval.hs | 4 +- plutus-ledger-api/test/Spec/Versions.hs | 4 +- .../testlib/PlutusLedgerApi/Test/Examples.hs | 6 +-- plutus-tx-plugin/src/PlutusTx/Plugin.hs | 6 +-- plutus-tx-plugin/test/IsData/Spec.hs | 6 +-- plutus-tx/src/PlutusTx/Lift.hs | 4 +- 22 files changed, 96 insertions(+), 77 deletions(-) create mode 100644 plutus-core/changelog.d/20230215_132227_michael.peyton-jones_no_ann_version.md create mode 100644 plutus-core/plutus-core/src/PlutusCore/Version.hs diff --git a/plutus-core/changelog.d/20230215_132227_michael.peyton-jones_no_ann_version.md b/plutus-core/changelog.d/20230215_132227_michael.peyton-jones_no_ann_version.md new file mode 100644 index 00000000000..e8b42837418 --- /dev/null +++ b/plutus-core/changelog.d/20230215_132227_michael.peyton-jones_no_ann_version.md @@ -0,0 +1,4 @@ +### Changed + +- `Version` no longer has an annotation, as this was entirely unused. + diff --git a/plutus-core/executables/src/PlutusCore/Executable/Common.hs b/plutus-core/executables/src/PlutusCore/Executable/Common.hs index 6c746fdebdd..1e1f9fc4e92 100644 --- a/plutus-core/executables/src/PlutusCore/Executable/Common.hs +++ b/plutus-core/executables/src/PlutusCore/Executable/Common.hs @@ -521,15 +521,15 @@ prettyExample = \case SomeTypedExample (SomeTypeExample (TypeExample _ ty)) -> PP.prettyPlcDef ty SomeTypedExample (SomeTypedTermExample (TypedTermExample _ term)) -> - PP.prettyPlcDef $ PLC.Program () (PLC.defaultVersion ()) term + PP.prettyPlcDef $ PLC.Program () (PLC.defaultVersion) term SomeUntypedExample (SomeUntypedTermExample (UntypedTermExample term)) -> - PP.prettyPlcDef $ UPLC.Program () (PLC.defaultVersion ()) term + PP.prettyPlcDef $ UPLC.Program () (PLC.defaultVersion) term toTypedTermExample :: PLC.Term PLC.TyName PLC.Name PLC.DefaultUni PLC.DefaultFun () -> TypedTermExample toTypedTermExample term = TypedTermExample ty term where - program = PLC.Program () (PLC.defaultVersion ()) term + program = PLC.Program () (PLC.defaultVersion) term errOrTy = PLC.runQuote . runExceptT $ do tcConfig <- PLC.getDefTypeCheckConfig () PLC.inferTypeOfProgram tcConfig program diff --git a/plutus-core/plutus-core.cabal b/plutus-core/plutus-core.cabal index fbfd21deea4..e890cc9caed 100644 --- a/plutus-core/plutus-core.cabal +++ b/plutus-core/plutus-core.cabal @@ -141,6 +141,7 @@ library PlutusCore.Subst PlutusCore.TypeCheck PlutusCore.TypeCheck.Internal + PlutusCore.Version PlutusIR PlutusIR.Analysis.RetainedSize PlutusIR.Compiler diff --git a/plutus-core/plutus-core/src/PlutusCore.hs b/plutus-core/plutus-core/src/PlutusCore.hs index f40fbbd0b82..bd0a519f8f7 100644 --- a/plutus-core/plutus-core/src/PlutusCore.hs +++ b/plutus-core/plutus-core/src/PlutusCore.hs @@ -149,4 +149,4 @@ applyProgram -- TODO: 'mappend' annotations, ignore versions and return the default one (whatever that means), -- what a mess. Needs to be fixed. applyProgram (Program a1 _ t1) (Program a2 _ t2) = - Program (a1 <> a2) (defaultVersion mempty) (Apply mempty t1 t2) + Program (a1 <> a2) defaultVersion (Apply mempty t1 t2) diff --git a/plutus-core/plutus-core/src/PlutusCore/Core/Instance/Pretty/Common.hs b/plutus-core/plutus-core/src/PlutusCore/Core/Instance/Pretty/Common.hs index e0a782daf3d..dac09d9430f 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Core/Instance/Pretty/Common.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Core/Instance/Pretty/Common.hs @@ -8,5 +8,5 @@ import PlutusPrelude import PlutusCore.Core.Type -instance Pretty (Version ann) where - pretty (Version _ i j k) = pretty i <> "." <> pretty j <> "." <> pretty k +instance Pretty Version where + pretty (Version i j k) = pretty i <> "." <> pretty j <> "." <> pretty k diff --git a/plutus-core/plutus-core/src/PlutusCore/Core/Instance/Scoping.hs b/plutus-core/plutus-core/src/PlutusCore/Core/Instance/Scoping.hs index 54322ec2320..f9e3be48b79 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Core/Instance/Scoping.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Core/Instance/Scoping.hs @@ -71,7 +71,7 @@ instance (tyname ~ TyName, name ~ Name) => EstablishScoping (Term tyname name un instance (tyname ~ TyName, name ~ Name) => EstablishScoping (Program tyname name uni fun) where establishScoping (Program _ ver term) = - Program NotAName (NotAName <$ ver) <$> establishScoping term + Program NotAName ver <$> establishScoping term instance tyname ~ TyName => CollectScopeInfo (Type tyname uni) where collectScopeInfo (TyLam ann name kind ty) = diff --git a/plutus-core/plutus-core/src/PlutusCore/Core/Type.hs b/plutus-core/plutus-core/src/PlutusCore/Core/Type.hs index 359f11d5741..db0596ed015 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Core/Type.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Core/Type.hs @@ -23,7 +23,6 @@ module PlutusCore.Core.Type , argsFunKind , Type (..) , Term (..) - , Version (..) , Program (..) , UniOf , Normalized (..) @@ -33,7 +32,7 @@ module PlutusCore.Core.Type , tyDeclVar , HasUniques , Binder (..) - , defaultVersion + , module Export -- * Helper functions , termAnn , typeAnn @@ -57,6 +56,7 @@ import PlutusPrelude import PlutusCore.Evaluation.Machine.ExMemory import PlutusCore.Name +import PlutusCore.Version as Export import Control.Lens import Data.Hashable @@ -120,36 +120,10 @@ data Term tyname name uni fun ann instance ExMemoryUsage (Term tyname name uni fun ann) where memoryUsage = error "Internal error: 'memoryUsage' for Core 'Term' is not supposed to be forced" -{- | -The version of Plutus Core used by this program. - -The intention is to convey different levels of backwards compatibility for existing scripts: -- Major version changes are backwards-incompatible -- Minor version changes are backwards-compatible -- Patch version changes should be entirely invisible (and we will likely not use this level) - -The version used should be changed only when the /language itself/ changes. -For example, adding a new kind of term to the language would require a minor -version bump; removing a kind of term would require a major version bump. - -Similarly, changing the semantics of the language will require a version bump, -typically a major one. This is the main reason why the version is actually -tracked in the AST: we can have two language versions with identical ASTs but -different semantics, so we need to track the version explicitly. - -Compatibility is about compatibility for specific scripts, not about e.g. tools which consume scripts. -Adding a new kind of term does not change how existing scripts behave, but does change what -tools would need to do to process scripts. --} -data Version ann - = Version ann Natural Natural Natural - deriving stock (Eq, Show, Functor, Generic) - deriving anyclass (NFData, Hashable) - -- | A 'Program' is simply a 'Term' coupled with a 'Version' of the core language. data Program tyname name uni fun ann = Program { _progAnn :: ann - , _progVer :: Version ann + , _progVer :: Version , _progTerm :: Term tyname name uni fun ann } deriving stock (Show, Functor, Generic) @@ -211,10 +185,6 @@ type instance HasUniques (Term tyname name uni fun ann) = type instance HasUniques (Program tyname name uni fun ann) = HasUniques (Term tyname name uni fun ann) --- | The default version of Plutus Core supported by this library. -defaultVersion :: ann -> Version ann -defaultVersion ann = Version ann 1 0 0 - typeAnn :: Type tyname uni ann -> ann typeAnn (TyVar ann _ ) = ann typeAnn (TyFun ann _ _ ) = ann diff --git a/plutus-core/plutus-core/src/PlutusCore/Flat.hs b/plutus-core/plutus-core/src/PlutusCore/Flat.hs index 6e41faca8aa..cb53bbec82e 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Flat.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Flat.hs @@ -186,9 +186,9 @@ instance Flat Name where deriving newtype instance Flat TyName -- via Name -instance Flat ann => Flat (Version ann) where - encode (Version ann n n' n'') = encode ann <> encode n <> encode n' <> encode n'' - decode = Version <$> decode <*> decode <*> decode <*> decode +instance Flat Version where + encode (Version n n' n'') = encode n <> encode n' <> encode n'' + decode = Version <$> decode <*> decode <*> decode -- | Use 1 bit to encode kind tags. kindTagWidth :: NumBits diff --git a/plutus-core/plutus-core/src/PlutusCore/Parser/ParserCommon.hs b/plutus-core/plutus-core/src/PlutusCore/Parser/ParserCommon.hs index be588968cae..fe67b89fb29 100644 --- a/plutus-core/plutus-core/src/PlutusCore/Parser/ParserCommon.hs +++ b/plutus-core/plutus-core/src/PlutusCore/Parser/ParserCommon.hs @@ -144,22 +144,13 @@ toSrcSpan start end = , srcSpanECol = unPos (sourceColumn end) } -version :: Parser (Version SourcePos) +version :: Parser Version version = lexeme $ do - p <- getSourcePos x <- Lex.decimal void $ char '.' y <- Lex.decimal void $ char '.' - Version p x y <$> Lex.decimal - -version' :: Parser (Version SrcSpan) -version' = withSpan $ \sp -> do - x <- Lex.decimal - void $ char '.' - y <- Lex.decimal - void $ char '.' - Version sp x y <$> Lex.decimal + Version x y <$> Lex.decimal name :: Parser Name name = lexeme $ try $ do diff --git a/plutus-core/plutus-core/src/PlutusCore/Version.hs b/plutus-core/plutus-core/src/PlutusCore/Version.hs new file mode 100644 index 00000000000..32635c69e7b --- /dev/null +++ b/plutus-core/plutus-core/src/PlutusCore/Version.hs @@ -0,0 +1,53 @@ +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE TemplateHaskell #-} + +module PlutusCore.Version ( + Version(..) + , versionMajor + , versionMinor + , versionPatch + , defaultVersion) where + +import PlutusPrelude + +import Control.Lens +import Data.Hashable +import Instances.TH.Lift () + +{- | +The version of Plutus Core used by this program. + +The intention is to convey different levels of backwards compatibility for existing scripts: +- Major version changes are backwards-incompatible +- Minor version changes are backwards-compatible +- Patch version changes should be entirely invisible (and we will likely not use this level) + +The version used should be changed only when the /language itself/ changes. +For example, adding a new kind of term to the language would require a minor +version bump; removing a kind of term would require a major version bump. + +Similarly, changing the semantics of the language will require a version bump, +typically a major one. This is the main reason why the version is actually +tracked in the AST: we can have two language versions with identical ASTs but +different semantics, so we need to track the version explicitly. + +Compatibility is about compatibility for specific scripts, not about e.g. tools which consume +scripts. Adding a new kind of term does not change how existing scripts behave, but does +change what tools would need to do to process scripts. +-} +data Version + = Version { _versionMajor :: Natural, _versionMinor :: Natural, _versionPatch :: Natural } + deriving stock (Eq, Show, Generic) + deriving anyclass (NFData, Hashable) + +makeLenses ''Version + +-- This is probably what the derived version would do, but better to be explicit since it's +-- important +instance Ord Version where + compare (Version major1 minor1 patch1) (Version major2 minor2 patch2) = + compare major1 major2 <> compare minor1 minor2 <> compare patch1 patch2 + +-- | The default version of Plutus Core supported by this library. +defaultVersion :: Version +defaultVersion = Version 1 0 0 diff --git a/plutus-core/testlib/PlutusCore/Generators/Hedgehog/AST.hs b/plutus-core/testlib/PlutusCore/Generators/Hedgehog/AST.hs index 09ab3f773a8..aefaae0d66a 100644 --- a/plutus-core/testlib/PlutusCore/Generators/Hedgehog/AST.hs +++ b/plutus-core/testlib/PlutusCore/Generators/Hedgehog/AST.hs @@ -51,8 +51,8 @@ runAstGen a = do names <- genNames Gen.fromGenT $ hoist (return . flip runReader names) a -genVersion :: MonadGen m => m (Version ()) -genVersion = Version () <$> int' <*> int' <*> int' where +genVersion :: MonadGen m => m Version +genVersion = Version <$> int' <*> int' <*> int' where int' = Gen.integral_ $ Range.linear 0 10 -- | Generate a fixed set of names which we will use, of only up to a short size to make it diff --git a/plutus-core/testlib/PlutusCore/Generators/Hedgehog/Test.hs b/plutus-core/testlib/PlutusCore/Generators/Hedgehog/Test.hs index d97d007973d..d432aed4eb2 100644 --- a/plutus-core/testlib/PlutusCore/Generators/Hedgehog/Test.hs +++ b/plutus-core/testlib/PlutusCore/Generators/Hedgehog/Test.hs @@ -54,7 +54,7 @@ getSampleProgramAndValue => TermGen a -> IO (Program TyName Name uni fun (), EvaluationResult (Term TyName Name uni fun ())) getSampleProgramAndValue genTerm = getSampleTermValue genTerm <&> \(TermOf term result) -> - (Program () (defaultVersion ()) term, result) + (Program () (defaultVersion) term, result) -- | Generate a program using a given generator, check that it's well-typed and evaluates correctly -- and pretty-print it to stdout using the default pretty-printing mode. diff --git a/plutus-core/testlib/PlutusIR/Test.hs b/plutus-core/testlib/PlutusIR/Test.hs index b86f45eb233..b0ca024cf89 100644 --- a/plutus-core/testlib/PlutusIR/Test.hs +++ b/plutus-core/testlib/PlutusIR/Test.hs @@ -43,7 +43,7 @@ instance ( PLC.Pretty (PLC.SomeTypeIn uni), PLC.GEq uni, PLC.Typecheckable uni f , PLC.Closed uni, uni `PLC.Everywhere` PrettyConst, Pretty fun, Pretty a , Typeable a, Ord a ) => ToTPlc (PIR.Term TyName Name uni fun a) uni fun where - toTPlc = asIfThrown . fmap (PLC.Program () (PLC.defaultVersion ()) . void) . compileAndMaybeTypecheck True + toTPlc = asIfThrown . fmap (PLC.Program () (PLC.defaultVersion) . void) . compileAndMaybeTypecheck True instance ( PLC.Pretty (PLC.SomeTypeIn uni), PLC.GEq uni, PLC.Typecheckable uni fun , PLC.Closed uni, uni `PLC.Everywhere` PrettyConst, Pretty fun, Pretty a diff --git a/plutus-core/untyped-plutus-core/src/UntypedPlutusCore.hs b/plutus-core/untyped-plutus-core/src/UntypedPlutusCore.hs index 008f4160c87..cebcc1719f8 100644 --- a/plutus-core/untyped-plutus-core/src/UntypedPlutusCore.hs +++ b/plutus-core/untyped-plutus-core/src/UntypedPlutusCore.hs @@ -28,10 +28,10 @@ applyProgram :: Program name uni fun a -> Program name uni fun a applyProgram (Program a1 _ t1) (Program a2 _ t2) = - Program (a1 <> a2) (PLC.defaultVersion mempty) (Apply (termAnn t1 <> termAnn t2) t1 t2) + Program (a1 <> a2) PLC.defaultVersion (Apply (termAnn t1 <> termAnn t2) t1 t2) {- | DON'T USE, we'll be getting rid of `defaultVersion`. Turn a UPLC term to a UPLC program with the default version. -} mkDefaultProg :: Term name uni fun () -> Program name uni fun () -mkDefaultProg = Program () (PLC.defaultVersion ()) +mkDefaultProg = Program () PLC.defaultVersion diff --git a/plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Core/Type.hs b/plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Core/Type.hs index 6cf97a7deee..923885f2a99 100644 --- a/plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Core/Type.hs +++ b/plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Core/Type.hs @@ -86,7 +86,7 @@ data Term name uni fun ann -- | A 'Program' is simply a 'Term' coupled with a 'Version' of the core language. data Program name uni fun ann = Program { _progAnn :: ann - , _progVer :: TPLC.Version ann + , _progVer :: TPLC.Version , _progTerm :: Term name uni fun ann } deriving stock (Show, Functor, Generic) diff --git a/plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Parser.hs b/plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Parser.hs index 748dd8bd0ff..e176cbc9b3f 100644 --- a/plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Parser.hs +++ b/plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Parser.hs @@ -88,7 +88,7 @@ program :: Parser (UPLC.Program PLC.Name PLC.DefaultUni PLC.DefaultFun SrcSpan) program = do whitespace prog <- withSpan $ \sp -> - inParens' $ UPLC.Program sp <$> (symbol "program" *> version') <*> term + inParens' $ UPLC.Program sp <$> (symbol "program" *> version) <*> term notFollowedBy anySingle pure prog diff --git a/plutus-ledger-api/src/PlutusLedgerApi/Common/Eval.hs b/plutus-ledger-api/src/PlutusLedgerApi/Common/Eval.hs index b7d382c9191..aca93d4277a 100644 --- a/plutus-ledger-api/src/PlutusLedgerApi/Common/Eval.hs +++ b/plutus-ledger-api/src/PlutusLedgerApi/Common/Eval.hs @@ -48,7 +48,7 @@ data EvaluationError = CekError !(UPLC.CekEvaluationException NamedDeBruijn DefaultUni DefaultFun) -- ^ An error from the evaluator itself | DeBruijnError !FreeVariableError -- ^ An error in the pre-evaluation step of converting from de-Bruijn indices | CodecError !ScriptDecodeError -- ^ A deserialisation error - | IncompatibleVersionError !(ScriptPlutus.Version ()) -- ^ An error indicating a version tag that we don't support + | IncompatibleVersionError !ScriptPlutus.Version -- ^ An error indicating a version tag that we don't support -- TODO: make this error more informative when we have more information about what went wrong | CostModelParameterMismatch -- ^ An error indicating that the cost model parameters didn't match what we expected deriving stock (Show, Eq) @@ -95,7 +95,7 @@ mkTermToEvaluate mkTermToEvaluate lv pv bs args = do -- It decodes the program through the optimized ScriptForExecution. See `ScriptForExecution`. ScriptForExecution (UPLC.Program _ v t) <- fromSerialisedScript lv pv bs - unless (v == ScriptPlutus.defaultVersion ()) $ throwError $ IncompatibleVersionError v + unless (v == ScriptPlutus.defaultVersion) $ throwError $ IncompatibleVersionError v let termArgs = fmap (UPLC.mkConstant ()) args appliedT = UPLC.mkIterApp () t termArgs diff --git a/plutus-ledger-api/test/Spec/Versions.hs b/plutus-ledger-api/test/Spec/Versions.hs index e4a679aa9e5..8ceeff3a0eb 100644 --- a/plutus-ledger-api/test/Spec/Versions.hs +++ b/plutus-ledger-api/test/Spec/Versions.hs @@ -28,13 +28,13 @@ import Test.Tasty.QuickCheck serialiseDataExScript :: SerialisedScript serialiseDataExScript = serialiseUPLC serialiseDataEx where - serialiseDataEx = UPLC.Program () (PLC.defaultVersion ()) $ + serialiseDataEx = UPLC.Program () (PLC.defaultVersion) $ UPLC.Apply () (UPLC.Builtin () PLC.SerialiseData) (PLC.mkConstant () $ I 1) errorScript :: SerialisedScript errorScript = serialiseUPLC errorEx where - errorEx = UPLC.Program () (PLC.defaultVersion ()) $ UPLC.Error () + errorEx = UPLC.Program () (PLC.defaultVersion) $ UPLC.Error () tests :: TestTree tests = testGroup "versions" diff --git a/plutus-ledger-api/testlib/PlutusLedgerApi/Test/Examples.hs b/plutus-ledger-api/testlib/PlutusLedgerApi/Test/Examples.hs index 76794461276..fdc41886ee4 100644 --- a/plutus-ledger-api/testlib/PlutusLedgerApi/Test/Examples.hs +++ b/plutus-ledger-api/testlib/PlutusLedgerApi/Test/Examples.hs @@ -19,7 +19,7 @@ It seems better therefore to avoid depending on Plutus Tx in any "core" projects -- | Creates a script which has N arguments, and always succeeds. alwaysSucceedingNAryFunction :: Natural -> SerialisedScript -alwaysSucceedingNAryFunction n = serialiseUPLC $ UPLC.Program () (PLC.defaultVersion ()) (body n) +alwaysSucceedingNAryFunction n = serialiseUPLC $ UPLC.Program () PLC.defaultVersion (body n) where -- No more arguments! The body can be anything that doesn't fail, so we return `\x . x` body i | i == 0 = UPLC.LamAbs() (UPLC.DeBruijn 0) $ UPLC.Var () (UPLC.DeBruijn 1) @@ -28,7 +28,7 @@ alwaysSucceedingNAryFunction n = serialiseUPLC $ UPLC.Program () (PLC.defaultVer -- | Creates a script which has N arguments, and always fails. alwaysFailingNAryFunction :: Natural -> SerialisedScript -alwaysFailingNAryFunction n = serialiseUPLC $ UPLC.Program () (PLC.defaultVersion ()) (body n) +alwaysFailingNAryFunction n = serialiseUPLC $ UPLC.Program () PLC.defaultVersion (body n) where -- No more arguments! The body should be error. body i | i == 0 = UPLC.Error () @@ -36,7 +36,7 @@ alwaysFailingNAryFunction n = serialiseUPLC $ UPLC.Program () (PLC.defaultVersio body i = UPLC.LamAbs () (UPLC.DeBruijn 0) $ body (i-1) summingFunction :: SerialisedScript -summingFunction = serialiseUPLC $ UPLC.Program () (PLC.defaultVersion ()) body +summingFunction = serialiseUPLC $ UPLC.Program () PLC.defaultVersion body where body = UPLC.Apply () (UPLC.Apply () (UPLC.Builtin () PLC.AddInteger) (PLC.mkConstant @Integer () 1)) (PLC.mkConstant @Integer () 2) diff --git a/plutus-tx-plugin/src/PlutusTx/Plugin.hs b/plutus-tx-plugin/src/PlutusTx/Plugin.hs index fe74e59b307..13d5edc3467 100644 --- a/plutus-tx-plugin/src/PlutusTx/Plugin.hs +++ b/plutus-tx-plugin/src/PlutusTx/Plugin.hs @@ -422,7 +422,7 @@ runCompiler moduleName opts expr = do -- (Simplified) Pir -> Plc translation. plcT <- flip runReaderT pirCtx $ PIR.compileReadableToPlc spirT - let plcP = PLC.Program () (PLC.defaultVersion ()) $ void plcT + let plcP = PLC.Program () (PLC.defaultVersion) $ void plcT when (_posDumpPlc opts) . liftIO $ dumpFlat plcP "typed PLC program" (moduleName ++ ".plc.flat") -- We do this after dumping the programs so that if we fail typechecking we still get the dump. @@ -431,8 +431,8 @@ runCompiler moduleName opts expr = do uplcT <- flip runReaderT plcOpts $ PLC.compileTerm plcT dbT <- liftExcept $ UPLC.deBruijnTerm uplcT - let uplcPNoAnn = UPLC.Program () (PLC.defaultVersion ()) $ void dbT - uplcP = UPLC.Program mempty (PLC.defaultVersion mempty) . fmap getSrcSpans $ dbT + let uplcPNoAnn = UPLC.Program () (PLC.defaultVersion) $ void dbT + uplcP = UPLC.Program mempty (PLC.defaultVersion) . fmap getSrcSpans $ dbT when (_posDumpUPlc opts) . liftIO $ dumpFlat uplcPNoAnn "untyped PLC program" (moduleName ++ ".uplc.flat") pure (spirP, uplcP) diff --git a/plutus-tx-plugin/test/IsData/Spec.hs b/plutus-tx-plugin/test/IsData/Spec.hs index c6be4c6f49d..f3059ab3b2d 100644 --- a/plutus-tx-plugin/test/IsData/Spec.hs +++ b/plutus-tx-plugin/test/IsData/Spec.hs @@ -73,14 +73,14 @@ tests = testNested "IsData" [ , goldenUEval "tuple" [plc (Proxy @"tuple") (isDataRoundtrip (1::Integer, 2::Integer))] , goldenUEval "tupleInterop" [ getPlcNoAnn (plc (Proxy @"tupleInterop") (\(d :: P.BuiltinData) -> case IsData.fromBuiltinData d of { Just t -> t P.== (1::Integer, 2::Integer); Nothing -> False})) - , UPLC.Program () (PLC.defaultVersion ()) (PLC.mkConstant () (IsData.toData (1::Integer, 2::Integer)))] + , UPLC.Program () (PLC.defaultVersion) (PLC.mkConstant () (IsData.toData (1::Integer, 2::Integer)))] , goldenUEval "unsafeTupleInterop" [ getPlcNoAnn (plc (Proxy @"unsafeTupleInterop") (\(d :: P.BuiltinData) -> IsData.unsafeFromBuiltinData d P.== (1::Integer, 2::Integer))) - , UPLC.Program () (PLC.defaultVersion ()) (PLC.mkConstant () (IsData.toData (1::Integer, 2::Integer)))] + , UPLC.Program () (PLC.defaultVersion) (PLC.mkConstant () (IsData.toData (1::Integer, 2::Integer)))] , goldenUEval "unit" [plc (Proxy @"unit") (isDataRoundtrip ())] , goldenUEval "unitInterop" [ getPlcNoAnn (plc (Proxy @"unitInterop") (\(d :: P.BuiltinData) -> case IsData.fromBuiltinData d of { Just t -> t P.== (); Nothing -> False})) - , UPLC.Program () (PLC.defaultVersion ()) (PLC.mkConstant () (IsData.toData ()))] + , UPLC.Program () (PLC.defaultVersion) (PLC.mkConstant () (IsData.toData ()))] , goldenUEval "mono" [plc (Proxy @"mono") (isDataRoundtrip (Mono2 2))] , goldenUEval "poly" [plc (Proxy @"poly") (isDataRoundtrip (Poly1 (1::Integer) (2::Integer)))] , goldenUEval "record" [plc (Proxy @"record") (isDataRoundtrip (MyMonoRecord 1 2))] diff --git a/plutus-tx/src/PlutusTx/Lift.hs b/plutus-tx/src/PlutusTx/Lift.hs index 2b885de9dbc..669e379f14f 100644 --- a/plutus-tx/src/PlutusTx/Lift.hs +++ b/plutus-tx/src/PlutusTx/Lift.hs @@ -91,7 +91,7 @@ safeLiftProgram , PrettyPrintable uni fun ) => a -> m (UPLC.Program UPLC.NamedDeBruijn uni fun ()) -safeLiftProgram x = UPLC.Program () (PLC.defaultVersion ()) <$> safeLift x +safeLiftProgram x = UPLC.Program () (PLC.defaultVersion) <$> safeLift x safeLiftCode :: (Lift.Lift uni a @@ -128,7 +128,7 @@ lift a = unsafely $ safeLift a liftProgram :: (Lift.Lift uni a, Throwable uni fun, PLC.Typecheckable uni fun) => a -> UPLC.Program UPLC.NamedDeBruijn uni fun () -liftProgram x = UPLC.Program () (PLC.defaultVersion ()) $ lift x +liftProgram x = UPLC.Program () (PLC.defaultVersion) $ lift x -- | Get a Plutus Core program in the default universe corresponding to the given value, throwing any errors that occur as exceptions and ignoring fresh names. liftProgramDef