Hot answers tagged

11 votes
Accepted

What does @ prefix means?

It means type application. In this case, the function is polymorphic with the following type: logInfo :: forall a effs. Member (LogMsg a) effs => a -> Eff effs () by using TypeApplications ...
user avatar
  • 477
8 votes
Accepted

How can I find the Haskell source code for the sqrt function?

By entering :i sqrt using ghci, we can see that sqrt is -- Defined in ‘GHC.Float’ A quick google shows that the source code repo is on https://gitlab.haskell.org/ghc/ghc. Entering sqrt in the search ...
user avatar
  • 1,488
5 votes

Logging in validator

You're running into trouble because logInfo is meant to be used inside the Contract monad. The Wallet code uses the Contract monad but the validator code doesn't. If you're not familiar with how ...
user avatar
5 votes
Accepted

Meaning of <$> notation

It's a functor map which is essentially an fmap function for the functor class. This might be of some use: https://www.fpcomplete.com/haskell/tutorial/operators/
user avatar
4 votes
Accepted

Understanding do notation with Monads in Plutus Pioneer Week 04

The 'secret' is in the bindWriter function that drive the Writer monad. instance Monad Writer where return a = Writer a [] (>>=) = bindWriter It is the bindWriter function that ...
user avatar
  • 460
4 votes

Is there documentation on the Prerequisites for Plutus Pioneer code?

There are instructions on the official input-output-hk/plutus-pioneer-program repo in the exercises chapter here: https://github.com/input-output-hk/plutus-pioneer-program#exercises I think you may be ...
user avatar
  • 3,026
4 votes
Accepted

What do unusual symbols "@" and ".\/" in off-chain code mean?

@String is from TypeApplications. logInfo has type logInfo :: forall a effs. Member (LogMsg a) effs => a -> Eff effs (), so logInfo @String fixes a to be String. (That this is needed here is ...
user avatar
3 votes
Accepted

Insufficient funds when trying to use script unspent output

expected: Value (Map [(,Map [(\\\"\\\",3242)])])\")" Try adding a few zeros to the starting balances. It's saying it doesn't have enough to pay the fees. I'm surprised that the ...
user avatar
3 votes
Accepted

Pioneer Lecture 4 recursion - how is it not infinite?

payContract blocks on the first line of the do block until the pay endpoint is invoked. The input of the invocation is put in pp. pp <- endpoint @"pay" It then executes the endpoint ...
user avatar
  • 460
3 votes
Accepted

Haskell IDE INLINABLE error help

The way HLS is enabled without plugin errors is discussed here: https://github.com/input-output-hk/plutus-starter/pull/23 https://github.com/input-output-hk/plutus-starter/pull/29 https://github.com/...
user avatar
3 votes

Haskell IDE INLINABLE error help

The pragma {-# LANGUAGE NoImplicitPrelude #-} and import PlutusTx.Prelude might help. It replaces the implicitly defined functions in Haskell by inlinable alternatives. Here is an example for Boolean ...
user avatar
3 votes

What does two consecutive apostrophes mean in Haskell and Plutus?

The apostrophe(s) in Haskell (and thus Plutus) are part of the name; they do not hold any specific meaning. Haskell as a functional programming language borrows from mathematical notation. An ...
user avatar
  • 1,488
3 votes
Accepted

How can I convert `Slot` to `TokenName`

I've just run this in the REPL with success. Not sure if it is the best way, though. TokenName { unTokenName = Data.ByteString.Char8.pack $ show (toInteger (getSlot 1)) }
user avatar
  • 494
3 votes

haskell-language-server used in VSCode Haskell extension produces spurious INLINABLE compilation error message

I found a workaround that is sufficient to get my IDE usable. **WORKAROUND: ** By comparing the cabal files for Plutus week10 (which compiles OK in IDE) with week07 (error), I discovered that adding ...
user avatar
  • 161
3 votes

Type instance syntax

This code is implementing the ValidatorTypes "Typeclass" for the Auctioning datatype. Typeclasses are Haskell's way of handling polymorphism, like abstract classes in an OO language. In this ...
user avatar
3 votes
Accepted

The PAB is no longer working after upgrading the Plutus version

Plutus is still in active development, so changes in the API can occur every week. For your case, go look at a similar example in the PAB. In your specific case, you'll need to change your handlers ...
user avatar
  • 355
3 votes
Accepted

Where is the Haskell course mentioned by Lars?

Lars's courses are spread around various Youtube channels. I think that the one you are referring to is "Crypto Mongolia". Here it is: https://youtube.com/playlist?list=...
user avatar
3 votes

Meaning of <$> notation

For Haskell questions of this sort Hoogle is the ultimate resource. For operators like <$> you need to enclose them in parenthesis eg (<$>).
user avatar
3 votes
Accepted

Lesson 3 - unsure how "sigs" is created or where txInfoSignatories comes from or how it works

TxInfo is a Record type and one of the fields of the TxInfo-record is txInfoSignatories. The fields in the records work as "getters". You may refer e.g. to learnyouhaskell-records for an ...
user avatar
3 votes
Accepted

What's the difference between Ledger.CurrencySymbol and Plutus.V1.Ledger.Value.CurrencySymbol?

If you look at the source of Ledger, you will see that it reexports CurrencySymbol from the Value module, so yes, they are the same: module Ledger ( module Export, AssetClass, ...
user avatar
3 votes

Continue to be utterly disoriented as to where these magic words come from and how they might be connected

I am very familiar with the Haskell language (of which Plutus is a dialect) but not super familiar with this course. The message Data constructor not in scope: EmulatorTrace means you are using an ...
user avatar
3 votes
Accepted

What is a library stanza?

I recommend you this article: https://vrom911.github.io/blog/common-stanzas Take into account that stanzas is a cabal thing (not Haskell, not Plutus). However Plutus projects can be created using ...
user avatar
  • 1,114
3 votes
Accepted

Empty TokenName Literal Overloading in Week05 Homework2

After digging into Plutus source, I think I've found why tn == "" crashes at runtime. The problem might be that the instance of TokenName IsString doesn't use the INLINABLE pragma in the ...
user avatar
  • 1,114
2 votes
Accepted

How to get the funds available at a script using Plutus?

If you are trying to do this in your offchain code, I would suggest using Plutus.Contract.utxoAt instead. Here is an example of it being used in the gift code.
user avatar
2 votes

Pioneer Lecture 4 recursion - how is it not infinite?

Simply put, it could recurse infinitely. Haskell doesn't have loops, so this is the equivalent of a while loop or something, where the exit case is the Contract monad throwing an error. If you want to ...
user avatar
2 votes

Is there documentation on the Prerequisites for Plutus Pioneer code?

I am running the Plutus Pioneer code in a nixos/nix based Docker container and it works a treat. I use the nix-shell as recommended in the pioneer program repo and I only needed to set up the IOHK ...
user avatar
  • 460
2 votes
Accepted

What does it mean for a contract to "stop"?

The line of interest is: pp <- endpoint @"pay" Which is essentially blocking until someone hits the "pay" endpoint and then returning whatever PayParams the caller included (...
user avatar
2 votes

Error with cabal build using plutus-starter-devcontainer on macOS Big Sur

This issue was resolved by updating VSCode to August 2021 release (v1.60.0) and increasing Docker Memory to 6GB.
user avatar
  • 51
2 votes

How can I find the Haskell source code for the sqrt function?

API docs for the core libraries are maintained at haskell.org as well. There's an index link in the upper right where you can look up specific functions and then, on each module's documentation page, ...
user avatar
  • 121

Only top scored, non community-wiki answers of a minimum length are eligible