Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add definition for DAML #620

Merged
merged 12 commits into from
Sep 4, 2020
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ CSharp
CShell
Css
D
DAML
Dart
DeviceTree
Dhall
Expand Down
7 changes: 7 additions & 0 deletions languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@
"nested_comments": [["/+", "+/"]],
"extensions": ["d"]
},
"Daml": {
"name": "DAML",
"nested": true,
"line_comment": ["-- "],
"multi_line_comments": [["{-", "-}"]],
"extensions": ["daml"]
},
"Dart": {
"line_comment": ["//"],
"multi_line_comments": [["/*", "*/"]],
Expand Down
42 changes: 42 additions & 0 deletions tests/data/Daml.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
-- ! 42 lines 24 code 9 comments 9 blanks

{-
This code is derived from https://github.com/digital-asset/ex-secure-daml-infra/blob/master/daml/BobTrigger.daml
-- Haskell/DAML support nested comments
{- including nested
block comments
-}
-}


module BobTrigger where

-- import DA.Action
import DA.Foldable
import DA.Next.Map (Map)
import Daml.Trigger
import Main

(--$) :: a -> b -> String
a --$ b = "Not a comment"

rejectTrigger : Trigger () = Trigger with
initialize = \_ -> ()
updateState = \_ _ () -> ()
rule = rejectRule
registeredTemplates = AllInDar
heartbeat = None
testNotAComment = 1
--$ 2 == "Not a comment"


rejectRule : Party -> ACS -> Time -> Map CommandId [Command] -> () -> TriggerA ()
rejectRule p acs _ _ _ = do
let assets = getContracts @Asset acs
let bobAssets = filter (\(_,a) -> a.owner == p) assets
let configs = getContracts @DonorConfig acs
let Some (_,bobConfig) = find (\(_,c) -> c.owner == p) configs

forA_ bobAssets $ \(_cid, c) -> do
debug "Ran rejectRule"
emitCommands [exerciseCmd _cid Give with newOwner = bobConfig.donateTo] [toAnyContractId _cid]