Basic Questions
App Development2 posts224 views3 likesLast activity Dec 2022
KA
kanika_kapoorOP
Dec 2022I created sample app, create-daml-app mentioned in the documentation.
Added one sample file:
create-daml-app/daml/Refer.daml with below content:
module Refer where
I have few questions:
- Why we add module where
- Can’t I run any sample script directly… do I need to have UI app in place.
- Can we have daml app which is has no UI, simaply a backend app with a simple script.
- Do I need a create a project just to execute basic script say which concatenates two lists
- Daml supports React by default-- Any support for Angular
- Is there support for third party API calls… by using rest client or so…
- Is it possible to declare global variables and use them anywhere in a script.
- in the code below why script keyword is missing before do
cash_balance_test = do
accountant ← allocateParty “Bob”
How above code different from below one:
cash_balance_test = script do
accountant ← allocateParty “Bob”
owner ← allocateParty “Alice”
owner ← allocateParty “Alice”
GA
Gary_Verhaegen
Dec 2022Hi @kanika_kapoor,
In general, it is best to open separate threads for separate questions. Asking so many questions at once can lead to very fragmented conversations, making the thread hard to follow.
Here’s my attempts at answering your questions:
- That’s just syntax we inherit from Haskell. Most languages have some equivalent module / package / namespace declaration at the top of their files.
- You do not need a UI app to run a script, especially a Daml Script.
- Yes. See the
quickstart-javatemplate for a terse example. - In the Daml world, “script” is usually taken to mean “Daml Script”, which does indeed require a project: to run a Daml Script, you need to have a DAR flle, and to get a DAR file you need a project. Alternatively, you can run
daml repland play with the language one line at a time, with no project required. - No, we do not have official support for any other frontend framework than React. Note that our JavaScript support is offered in three separate libraries:
@daml/types,@daml/ledger, and@daml/react. The last one is a thin compatibility layer between React and@daml/ledger;@daml/ledgerdoes not know anything about React (or the browser) and can be used in other environments (Angular, NodeJS, etc.). I don’t know much about Angular myself but if you do, it should be possible to just use@daml/ledgerin your Angular application. - The Daml system itself cannot make external API calls. External systems can interact with a Daml Ledger either directly through gRPC or through the JSON API Service (which runs as a separate component and, itself, connects to the gRPC endpoint). If you need to bridge a Daml Ledger to an external API, you’ll have to build your own application that talks to both.
- It is not possible to declare variables in Daml: the language is pure. You can bind symbols to immutable values, and you can shadow these bindings for a llimited scope. You can bind a value globally, but it’s still not going to be variable.
- The
donotation is very flexible and can mean any number of things. The compiler needs thatscriptcall to know what to do with thedoblock. Think of thedoblock as being an argument to thescriptfunction.