Created
July 12, 2022 16:43
-
-
Save danicuki/57be728587f15a6ababc4e98bac062dd to your computer and use it in GitHub Desktop.
Homework - 2 givers - 1 receiver - 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.V1 | |
main :: IO () | |
main = printJSON $ contract | |
{- Define a contract, Close is the simplest contract which just ends the contract straight away | |
-} | |
contract :: Contract | |
contract = | |
When | |
[deposits "Giver1" "Giver2", deposits "Giver2" "Giver1"] | |
(TimeParam "Deadline") | |
Close | |
where | |
pay :: Contract | |
pay = Pay | |
(Role "Giver1") | |
(Party (Role "Receiver")) | |
(Token "" "") | |
(ConstantParam "Deposit") | |
(Pay | |
(Role "Giver2") | |
(Party (Role "Receiver")) | |
(Token "" "") | |
(ConstantParam "Deposit") | |
Close | |
) | |
deposit :: Party -> Action | |
deposit p = Deposit p p ada (ConstantParam "Deposit") | |
deposits :: Party -> Party -> Case | |
deposits p1 p2 = | |
Case | |
(deposit p1) | |
(When | |
[Case | |
(deposit p2) | |
pay] | |
(TimeParam "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":"Unknown","contractName":"Unknown","contractLongDescription":"We couldn't find information about this contract","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