After re-reading the docs and some thinking I think I can answer my own question. The main point seems to be the difference between methods and functions.
The use of methods and functions becomes confusing because Haskell doesn’t have proper method syntax as opposed to function syntax, unlike some other languages.
Here we have methods and corresponding functions, expressed by the same name, with the same syntax, but with a different number of arguments. The “method syntax” is that we simply omit the receiver (I guess it’s inferred from the context).
In the interface definition I declare the give
method signature in the following way:
give : Party -> Update (ContractId Giveable)
If I hover over give
in VSCode, in the popup I can see the type signature for the corresponding function:
give : Giveable -> Party -> Update (ContractId Giveable)
In the Give interface choice definition in the do block I use the give
function:
give this newOwner
In the interface instance declaration, that is in the interface instance Giveable for Token where
block I declare the give
method like this:
give newOwner = do
tokenCid <- create this with tokenOwner = newOwner
return $ toInterfaceContractId tokenCid
If I hover here over give
in VSCode, in the popup I can see the method type signature: : Party -> Update (ContractId Giveable)
.
Is the answer that when I declare, I use the method syntax, and when I use, I use the function syntax?
This might be the case, but the way how VSCode displays the function signature for the method declaration in one place, and the method signature for the method declaration in another place, is still confusing.