plutus-core-1.45.0.0: Language library for Plutus Core
Safe HaskellSafe-Inferred
LanguageHaskell2010

Transform.Simplify

Synopsis

Documentation

caseOfCase2Term Name DefaultUni DefaultFun () Source #

This should not simplify, because one of the branches of ifThenElse is not a Constr. Unless both branches are known constructors, the case-of-case transformation may increase the program size.

caseOfCase3Term Name DefaultUni DefaultFun () Source #

Similar to caseOfCase1, but the type of the true and false branches is [Integer] rather than Bool (note that Constr 0 has two parameters, x and xs).

floatDelay1Term Name DefaultUni DefaultFun () Source #

The Delay should be floated into the lambda.

floatDelay2Term Name DefaultUni DefaultFun () Source #

The Delay should not be floated into the lambda, because the argument (1 + 2) is not work-free.

floatDelay3Term Name DefaultUni DefaultFun () Source #

The Delay should not be floated into the lambda in the first simplifier iteration, because one of the occurrences of a is not under Force. It should be floated into the lambda in the second simplifier iteration, after b is inlined.

mkInlinePurityTestQuote ([Name], Term Name DefaultUni DefaultFun ()) → Term Name DefaultUni DefaultFun () Source #

A helper function to create a term which tests whether the inliner behaves as expected for a given pure or impure term. It receives a Quote that produces a term together with a list of free variables. The free variables are bound at the top level of the final term in order to ensure that the produced final term is well-scoped.

inlinePure1Term Name DefaultUni DefaultFun () Source #

A single Var is pure.

inlinePure2Term Name DefaultUni DefaultFun () Source #

force (delay a) is pure.

Note that this relies on forceDelayCancel to cancel the force and the delay, otherwise the inliner would treat the term as impure.

inlinePure3Term Name DefaultUni DefaultFun () Source #

[(x -> y -> [x x]) (con integer 1)] is pure.

Note that the (con integer 1) won't get inlined: it isn't pre-inlined because x occurs twice, and it isn't post-inlined because costIsAcceptable Constant{} = False. However, the entire term will be inlined since it is pure.

inlinePure4Term Name DefaultUni DefaultFun () Source #

force ([(x -> delay (y -> [x x])) (delay ([error (con integer 1)]))]) is pure, but it is very tricky to see so. It requires us to match up a force and a delay through several steps of intervening computation.

inlineImpure2Term Name DefaultUni DefaultFun () Source #

force (delay error) is impure.

inlineImpure3Term Name DefaultUni DefaultFun () Source #

force (force (force (delay (delay (delay (error)))))) is impure, since it is the same as error.

inlineImpure4Term Name DefaultUni DefaultFun () Source #

force (force (force (delay (delay a)))) is impure, since a may expand to an impure term such as error.

callsiteInlineTerm Name DefaultUni DefaultFun () Source #

(a -> f (a 0 1) (a 2)) (x y -> g x y)

The first occurrence of a should be inlined because doing so does not increase the size or the cost.

The second occurrence of a should be unconditionally inlined in the second simplifier iteration, but in this test we are only running one iteration.

forceDelaySimpleTerm Name DefaultUni DefaultFun () Source #

The UPLC term in this test should come from the following TPLC term after erasing its types:

(/\(p :: *) -> \(x : p) -> /\(q :: *) -> \(y : q) -> /\(r :: *) -> \(z : r) -> z)
  Int 1 Int 2 Int 3

This case is simple in the sense that each type abstraction is followed by a single term abstraction.

forceDelayMultiApplyTerm Name DefaultUni DefaultFun () Source #

A test for the case when there are multiple applications between the Force at the top and the Delay at the top of the term inside the abstractions/applications.

forceDelayMultiForceTerm Name DefaultUni DefaultFun () Source #

A test for the case when there are multiple type abstractions over a single term abstraction/application.

forceDelayComplexTerm Name DefaultUni DefaultFun () Source #

The UPLC term in this test should come from the following TPLC term after erasing its types:

(/\(p1 :: *) (p2 :: *) -> \(x : p2) ->
  /\(q1 :: *) (q2 :: *) (q3 :: *) -> \(y1 : q1) (y2 : q2) (y3 : String) ->
    /\(r :: *) -> \(z1 : r) -> \(z2 : r) ->
      /\(t :: *) -> \(f : p1 -> q1 -> q2 -> String -> r -> r -> String) ->
        f x y1 y2 y3 z1 z2
) Int Int 1 Int String Int 2 "foo" "bar" Int 3 3 ByteString
(funcVar : Int -> Int -> String -> String -> Int -> String)

Note this term has multiple interleaved type and term instantiations/applications.

cse1Term Name DefaultUni DefaultFun () Source #

This is the first example in Note [CSE].

cse2Term Name DefaultUni DefaultFun () Source #

This is the second example in Note [CSE].

cse3Term Name DefaultUni DefaultFun () Source #

This is the third example in Note [CSE].