Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More examples please #5

Open
blamario opened this issue Dec 1, 2021 · 3 comments
Open

More examples please #5

blamario opened this issue Dec 1, 2021 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@blamario
Copy link

blamario commented Dec 1, 2021

A side-by-side example of Plutus output and an equivalent hand-written Pluto expression could go a long way to justify the project.

@srid
Copy link
Member

srid commented Dec 1, 2021

For the record, you can get the UPLC for examples/hello.pluto by running cabal run pluto -- run examples/hello.pluto -v in nix-shell.

For following pluto program,

-- Hello world
let 
  defaultGreeting = "Hello";
  greet = (\greeting name -> 
    (greeting +s ", ") +s name
  )
in 
  greet defaultGreeting "world"

translates to UPLC:

Program
  ()
  (Version () 1 0 0)
  (Apply
     ()
     (LamAbs
        ()
        (DeBruijn {dbnIndex = 0})
        (Apply
           ()
           (LamAbs
              ()
              (DeBruijn {dbnIndex = 0})
              (Apply
                 ()
                 (Apply
                    ()
                    (Var () (DeBruijn {dbnIndex = 2}))
                    (Var () (DeBruijn {dbnIndex = 1})))
                 (Constant () (Some (ValueOf string "world")))))
           (Constant () (Some (ValueOf string "Hello")))))
     (LamAbs
        ()
        (DeBruijn {dbnIndex = 0})
        (LamAbs
           ()
           (DeBruijn {dbnIndex = 0})
           (Apply
              ()
              (Apply
                 ()
                 (Builtin () AppendString)
                 (Apply
                    ()
                    (Apply
                       ()
                       (Builtin () AppendString)
                       (Var () (DeBruijn {dbnIndex = 2})))
                    (Constant () (Some (ValueOf string ", ")))))
              (Var () (DeBruijn {dbnIndex = 1}))))))

@blamario
Copy link
Author

blamario commented Dec 1, 2021

The benefit of this comparison is the whole justification for the project, so you want to put it up front. Sure anybody with a Plutus repo clone can get the same output but it takes some effort to produce it and visually compare to the hand-written Pluto expression. Speaking of which, do you plan to write a disassembler?

@blamario
Copy link
Author

blamario commented Dec 1, 2021

Never mind the last question, I opened issue #4 about that.

@srid srid added the documentation Improvements or additions to documentation label Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants