Add a script helper to DAML Script (#7272)

Factored out from #7264

We have enough cases of scenarios that don’t actually do ledger
operations and need some hint for type inference. While adding type
annotations works, this is a bit easier at least for the migration and
some people might prefer it.

No test, since this seems a bit excessive here :)

changelog_begin

- [DAML Script] Add a `script` function to aid type inference. This
  is the equivalent of `scenario`.

changelog_end
This commit is contained in:
Moritz Kiefer 2020-08-31 13:24:58 +02:00 committed by GitHub
parent 6743bf5b9b
commit 11a477244a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,6 +25,7 @@ module Daml.Script
, getTime
, setTime
, sleep
, script
) where
import DA.Functor
@ -311,3 +312,11 @@ lift : Free ScriptF a -> Script a
lift m = Script $ \s -> do
a <- m
pure (a, s)
-- | Convenience helper to declare you are writing a Script.
--
-- This is only useful for readability and to improve type inference.
-- Any expression of type `Script a` is a valid script regardless of whether
-- it is implemented using `script` or not.
script : Script a -> Script a
script = identity