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

Transform.Simplify.Spec

Synopsis

Documentation

caseOfCase2 ∷ Term 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.

caseOfCase3 ∷ Term 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).

floatDelay1 ∷ Term Name DefaultUni DefaultFun () Source #

The Delay should be floated into the lambda.

floatDelay2 ∷ Term Name DefaultUni DefaultFun () Source #

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

floatDelay3 ∷ Term 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.

floatDelay4 ∷ Term Name DefaultUni DefaultFun () Source #

The Delay should not be floated into the lambda because the argument to the Delay is not pure.

mkInlinePurityTest ∷ ([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 term together with a list of its 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.

inlinePure1 ∷ Term Name DefaultUni DefaultFun () Source #

A single Var is pure.

inlinePure2 ∷ Term 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.

inlinePure3 ∷ Term 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.

inlinePure4 ∷ Term 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.

inlineImpure2 ∷ Term Name DefaultUni DefaultFun () Source #

force (delay error) is impure.

inlineImpure3 ∷ Term Name DefaultUni DefaultFun () Source #

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

inlineImpure4 ∷ Term Name DefaultUni DefaultFun () Source #

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

callsiteInline ∷ Term 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.

inlineCheckpointUncondOnce ∷ Term Name DefaultUni DefaultFun () Source #

(f -> [(x -> f x) [(u -> u) (y -> y)]])

x is unconditionally inlined. It has one occurrence, so there should be no checkpoint.

inlineCheckpointUncondMany ∷ Term Name DefaultUni DefaultFun () Source #

(f -> [(x -> f x x) [(u -> u) (y -> y)]])

x is unconditionally inlined. It has two occurrences, so there should be a checkpoint.

inlineCheckpointCallsiteOnce ∷ Term Name DefaultUni DefaultFun () Source #

(f -> [(a -> f (a 0 1) a) (p q -> [(u -> u) p])])

a is inlined by callsite inlining. Only one callsite is inlined, so there should be no checkpoint.

inlineCheckpointCallsiteMany ∷ Term Name DefaultUni DefaultFun () Source #

(f -> [(a -> f (a 0 1) (a 2 3)) (p q -> [(u -> u) p])])

a is inlined by callsite inlining. Two callsites are inlined, so there should be a checkpoint.

forceDelaySimple ∷ Term 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.

forceDelayMultiApply ∷ Term 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.

forceDelayMultiForce ∷ Term Name DefaultUni DefaultFun () Source #

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

forceDelayComplex ∷ Term 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.

cse1 ∷ Term Name DefaultUni DefaultFun () Source #

This is the first example in Note [CSE].

cse2 ∷ Term Name DefaultUni DefaultFun () Source #

This is the second example in Note [CSE].

cse3 ∷ Term Name DefaultUni DefaultFun () Source #

This is the third example in Note [CSE].

plus ∷ T → T → T Source #