Skip to content

Removing extra bindings for function type argument #7205

@SeungheonOh

Description

@SeungheonOh

Check: #7199 (comment)

The plugin will create extra binding to ensure evaluation of all the argument of a given function currently. However, this is not necessary for arguments whose types are function. This can be fixed by either/or of these two approaches: Changing plutus-tx-plugin to not generate binding when it compiles Haskell code into pir or having an extra optimization path that will take out bindings of function-typed function argument.

Example:

foo :: (Integer -> a) -> a
foo f = f 10

-- Compiles into (pseudocode) 
foo = /\a -> \(f: Integer -> a) -> 
  let !f = f
  in f 10  

-- here we don't need this extra binding, it can simply be
foo = /\a -> \(f: Integer -> a) -> f 10

More complicated example can be found here: https://github.com/IntersectMBO/plutus/pull/7199/files#r2202044342

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions