Last active
June 11, 2022 05:36
-
-
Save ajuggler/55037fe45c588ed7e1c2f219ff53af52 to your computer and use it in GitHub Desktop.
Double Pay (Haskell)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings #-} | |
module Example where | |
import Language.Marlowe.Extended | |
main :: IO () | |
main = printJSON $ contract (Role "Giver1") (Role "Giver2") (Role "Receiver") (ConstantParam "Deposit") (TimeParam "Deadline") | |
contract :: Party -> Party -> Party -> Value -> Timeout -> Contract | |
contract giver1 giver2 receiver amount deadline = | |
When | |
[deposits giver1 giver2, deposits giver2 giver1] | |
deadline | |
Close | |
where | |
pay :: Contract | |
pay = | |
(Pay | |
giver1 | |
(Party receiver) | |
ada | |
(AvailableMoney | |
giver1 | |
ada | |
) | |
(Pay | |
giver2 | |
(Party receiver) | |
ada | |
(AvailableMoney | |
giver2 | |
ada | |
) | |
Close | |
) | |
) | |
deposit :: Party -> Action | |
deposit p = Deposit p p ada $ amount | |
deposits :: Party -> Party -> Case | |
deposits p1 p2 = Case | |
(deposit p1) | |
(When | |
[Case (deposit p2) pay] | |
deadline | |
Close | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"valueParameterInfo":[["Deposit",{"valueParameterFormat":{"contents":[6,""],"tag":"DecimalFormat"},"valueParameterDescription":""}]],"timeParameterDescriptions":[],"roleDescriptions":[],"contractType":"Other","contractShortDescription":"Two payers give to a single recipient.","contractName":"Double pay (haskell)","contractLongDescription":"Two payers give to a single recipient. Exercise in using Haskell.","choiceInfo":[]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment