Last active
January 12, 2021 21:00
-
-
Save brunjlar/43ede88e93a3848a7859b3c5ae8f6261 to your computer and use it in GitHub Desktop.
joint payment
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 | |
main :: IO () | |
main = print . pretty $ contract "Alice" "Bob" "Charlie" 100 | |
{- Define a contract, Close is the simplest contract which just ends the contract straight away | |
-} | |
contract :: Party -> Party -> Party -> Integer -> Contract | |
contract alice bob charlie amount = | |
When | |
[ Case (deposit alice) $ | |
When | |
[ Case (deposit bob) pay | |
] 2 Close | |
, Case (deposit bob) $ | |
When | |
[ Case (deposit alice) pay | |
] 2 Close | |
] 1 Close | |
where | |
a :: Value Observation | |
a = Constant amount | |
deposit :: Party -> Action | |
deposit p = Deposit p p ada a | |
pay :: Contract | |
pay = Pay alice (Party charlie) ada a $ | |
Pay bob (Party charlie) ada a | |
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
When | |
[Case | |
(Deposit | |
(Role "Alice") | |
(Role "Alice") | |
(Token "" "") | |
(Constant 100) | |
) | |
(When | |
[Case | |
(Deposit | |
(Role "Bob") | |
(Role "Bob") | |
(Token "" "") | |
(Constant 100) | |
) | |
(Pay | |
(Role "Alice") | |
(Party (Role "Charlie")) | |
(Token "" "") | |
(Constant 100) | |
(Pay | |
(Role "Bob") | |
(Party (Role "Charlie")) | |
(Token "" "") | |
(Constant 100) | |
Close | |
) | |
)] | |
2 Close | |
), Case | |
(Deposit | |
(Role "Bob") | |
(Role "Bob") | |
(Token "" "") | |
(Constant 100) | |
) | |
(When | |
[Case | |
(Deposit | |
(Role "Alice") | |
(Role "Alice") | |
(Token "" "") | |
(Constant 100) | |
) | |
(Pay | |
(Role "Alice") | |
(Party (Role "Charlie")) | |
(Token "" "") | |
(Constant 100) | |
(Pay | |
(Role "Bob") | |
(Party (Role "Charlie")) | |
(Token "" "") | |
(Constant 100) | |
Close | |
) | |
)] | |
2 Close | |
)] | |
1 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
{} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment