3

I'm a little confused about the following code(from EnglishAuction.hs):

auctionInstance :: Scripts.ScriptInstance Auctioning
auctionInstance = Scripts.validator @Auctioning
    $$(PlutusTx.compile [|| mkAuctionValidator ||])
    $$(PlutusTx.compile [|| wrap ||])                                                                                                                         
  where
    wrap = Scripts.wrapValidator @AuctionDatum @AuctionAction

What does "@" means? and what does Scripts.validator do? Why did it use two $$ instead of one?

2
  • If you want to learn more about Haskell (which Plutus is based on) you can have a look here: learnyouahaskell.com
    – eddex
    Commented Jun 8, 2021 at 10:06
  • I have already learned Haskell from learnyouahaskell.com. But it doesn't include template haskell.
    – mackie
    Commented Jun 8, 2021 at 10:11

2 Answers 2

1

This is part of Template Haskell. It is the way to have Haskell compiled at runtime basically.

This link may help https://downloads.haskell.org/~ghc/7.8.4/docs/html/users_guide/template-haskell.html

$$ is considered a typed expression splice. It also talks about [|| ... ||] which is a typed expression quotation.

0

The purpose of the code is to produce compiled Plutus-Core code which can be used as a validator. It is (more-or-less) boilerplate, so nearly the same for every program.

@ means we are giving types, not values

$$ is completely different to $ and it is used here to "splice" code into the program i.e. it inserts the compiled code 'syntax' into the program at this point.

See docs here : https://plutus.readthedocs.io/en/latest/plutus/tutorials/plutus-tx.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.