From b065041298ef5809dffaa1bd2695d5b8a1896fcc Mon Sep 17 00:00:00 2001 From: Marty Stumpf Date: Fri, 26 May 2023 07:26:08 -0700 Subject: [PATCH] Make pure. --- .../plutus-ir/src/PlutusIR/Compiler.hs | 2 +- .../src/PlutusIR/Transform/CommuteConst.hs | 26 +++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/plutus-core/plutus-ir/src/PlutusIR/Compiler.hs b/plutus-core/plutus-ir/src/PlutusIR/Compiler.hs index b1d3b50536a..b229daa4046 100644 --- a/plutus-core/plutus-ir/src/PlutusIR/Compiler.hs +++ b/plutus-core/plutus-ir/src/PlutusIR/Compiler.hs @@ -127,7 +127,7 @@ availablePasses = ver <- view ccBuiltinVer Inline.inline hints ver t ) - , Pass "commuteConst" (onOption coDoSimplifiercommuteConst) CommuteConst.commuteConst + , Pass "commuteConst" (onOption coDoSimplifiercommuteConst) (pure . CommuteConst.commuteConst) ] -- | Actual simplifier diff --git a/plutus-core/plutus-ir/src/PlutusIR/Transform/CommuteConst.hs b/plutus-core/plutus-ir/src/PlutusIR/Transform/CommuteConst.hs index fe178e80af6..ff6ca0a9b87 100644 --- a/plutus-core/plutus-ir/src/PlutusIR/Transform/CommuteConst.hs +++ b/plutus-core/plutus-ir/src/PlutusIR/Transform/CommuteConst.hs @@ -33,25 +33,23 @@ the one that will benefit the most. Plutonomy only commutes `EqualsInteger`. -} commuteConstDefault :: - forall m tyname name uni a. - ( PLC.MonadQuote m - ) => Term tyname name uni PLC.DefaultFun a -> - m (Term tyname name uni PLC.DefaultFun a) + forall tyname name uni a. + Term tyname name uni PLC.DefaultFun a -> + Term tyname name uni PLC.DefaultFun a commuteConstDefault (Apply ann (Builtin annB PLC.EqualsInteger) (Apply ann1 x y@(Constant{}))) = - pure $ Apply ann (Builtin annB PLC.EqualsInteger) (Apply ann1 y x) + Apply ann (Builtin annB PLC.EqualsInteger) (Apply ann1 y x) commuteConstDefault (Apply ann (Builtin annB PLC.EqualsByteString) (Apply ann1 x y@(Constant{}))) = - pure $ Apply ann (Builtin annB PLC.EqualsByteString) (Apply ann1 y x) + Apply ann (Builtin annB PLC.EqualsByteString) (Apply ann1 y x) commuteConstDefault (Apply ann (Builtin annB PLC.EqualsString) (Apply ann1 x y@(Constant{}))) = - pure $ Apply ann (Builtin annB PLC.EqualsString) (Apply ann1 y x) + Apply ann (Builtin annB PLC.EqualsString) (Apply ann1 y x) commuteConstDefault (Apply ann (Builtin annB PLC.AddInteger) (Apply ann1 x y@(Constant{}))) = - pure $ Apply ann (Builtin annB PLC.AddInteger) (Apply ann1 y x) + Apply ann (Builtin annB PLC.AddInteger) (Apply ann1 y x) commuteConstDefault (Apply ann (Builtin annB PLC.MultiplyInteger) (Apply ann1 x y@(Constant{}))) = - pure $ Apply ann (Builtin annB PLC.MultiplyInteger) (Apply ann1 y x) -commuteConstDefault tm = pure tm + Apply ann (Builtin annB PLC.MultiplyInteger) (Apply ann1 y x) +commuteConstDefault tm = tm -commuteConst :: forall m tyname name uni fun a. - ( PLC.MonadQuote m, Typeable fun - ) => Term tyname name uni fun a -> m (Term tyname name uni fun a) +commuteConst :: forall tyname name uni fun a. Typeable fun => + Term tyname name uni fun a -> Term tyname name uni fun a commuteConst = case eqT @fun @PLC.DefaultFun of Just Refl -> commuteConstDefault - Nothing -> \x -> pure x + Nothing -> id