Tech white paper: update example from Sofus

This commit is contained in:
Mike Hearn 2016-11-28 14:22:11 +00:00
parent 536b79a5f2
commit 6c8996fb5e
2 changed files with 9 additions and 6 deletions

View File

@ -11,7 +11,8 @@
breaklines,% breaklines,%
autogobble,% autogobble,%
frame=lines,% frame=lines,%
framesep=2\fboxsep% framesep=2\fboxsep,%
fontsize=\footnotesize%
} }
\usepackage{color} \usepackage{color}
\usepackage{epigraph} \usepackage{epigraph}
@ -1184,13 +1185,15 @@ experimental \emph{universal contract} that builds on the language extension fea
language. To avoid linguistic confusion it refers to the combined code/data bundle as an `arrangement' rather language. To avoid linguistic confusion it refers to the combined code/data bundle as an `arrangement' rather
than a contract. A European FX call option expressed in this language looks like this: than a contract. A European FX call option expressed in this language looks like this:
\newpage
\begin{kotlincode} \begin{kotlincode}
val european_fx_option = arrange { val european_fx_option = arrange {
actions { actions {
acmeCorp.may { acmeCorp may {
"exercise".anytime { "exercise" anytime {
actions { actions {
(acmeCorp or highStreetBank).may { (acmeCorp or highStreetBank) may {
"execute".givenThat(after("2017-09-01")) { "execute".givenThat(after("2017-09-01")) {
highStreetBank.owes(acmeCorp, 1.M, EUR) highStreetBank.owes(acmeCorp, 1.M, EUR)
acmeCorp.owes(highStreetBank, 1200.K, USD) acmeCorp.owes(highStreetBank, 1200.K, USD)
@ -1199,7 +1202,7 @@ than a contract. A European FX call option expressed in this language looks like
} }
} }
} }
highStreetBank.may { highStreetBank may {
"expire".givenThat(after("2017-09-01")) { "expire".givenThat(after("2017-09-01")) {
zero zero
} }

View File

@ -158,7 +158,7 @@ class ActionBuilder(val actors: Set<Party>) {
} }
} }
fun String.anytime(init: ContractBuilder.() -> Unit): Action { infix fun String.anytime(init: ContractBuilder.() -> Unit): Action {
val b = ContractBuilder() val b = ContractBuilder()
b.init() b.init()
val a = Action(this, const(true), actors, b.final()) val a = Action(this, const(true), actors, b.final())