From 891b1cfc82322f8017f0a4f6b707d6fe52024545 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 3 Sep 2021 21:51:30 -0400 Subject: Unified tuple and record syntax. --- licentia/project.lux | 4 +- licentia/source/program/licentia/document.lux | 5 +- licentia/source/program/licentia/input.lux | 6 +- licentia/source/program/licentia/license.lux | 82 +++++++++++++--------- .../source/program/licentia/license/addendum.lux | 4 +- .../source/program/licentia/license/copyright.lux | 5 +- .../source/program/licentia/license/definition.lux | 9 +-- licentia/source/program/licentia/license/time.lux | 5 +- licentia/source/program/licentia/output.lux | 48 ++++++------- licentia/source/test/licentia.lux | 4 +- 10 files changed, 94 insertions(+), 78 deletions(-) (limited to 'licentia') diff --git a/licentia/project.lux b/licentia/project.lux index 93f43aa47..6560fdf56 100644 --- a/licentia/project.lux +++ b/licentia/project.lux @@ -1,4 +1,4 @@ -{#identity ["com.github.luxlang" "licentia" "0.6.0-SNAPSHOT"] +[#identity ["com.github.luxlang" "licentia" "0.6.0-SNAPSHOT"] #description "A program for producing free/open-source/reciprocal licenses." #deploy_repositories {"snapshots" "https://oss.sonatype.org/content/repositories/snapshots/" @@ -15,4 +15,4 @@ ... #compiler ["com.github.luxlang" "lux-ruby" "0.6.0-SNAPSHOT" "jar"] #program "program/licentia" - #test "test/licentia"} + #test "test/licentia"] diff --git a/licentia/source/program/licentia/document.lux b/licentia/source/program/licentia/document.lux index 7b159b8f5..07a4e2b83 100644 --- a/licentia/source/program/licentia/document.lux +++ b/licentia/source/program/licentia/document.lux @@ -40,8 +40,9 @@ ) (type: .public Section - {#title Text - #content Text}) + (Record + [#title Text + #content Text])) (def: .public (section value) (-> Section Text) diff --git a/licentia/source/program/licentia/input.lux b/licentia/source/program/licentia/input.lux index ede659fcf..f6a438e7f 100644 --- a/licentia/source/program/licentia/input.lux +++ b/licentia/source/program/licentia/input.lux @@ -67,8 +67,8 @@ (do <>.monad [start (.field "start" ..amount) end (.field "end" ..amount) - #let [period {#time.start start - #time.end end}] + #let [period [#time.start start + #time.end end]] _ (<>.assert (exception.construct ..invalid_period [period]) (n.<= end start))] (wrap period)))) @@ -163,6 +163,6 @@ (.field "extension" ..extension) (.field "black-lists" (.array (<>.some ..black_list))) (.field "attribution" (.nullable ..attribution)) - (<>.default {#//.commons_clause? false} + (<>.default [#//.commons_clause? false] (.field "addendum" ..addendum)) ))) diff --git a/licentia/source/program/licentia/license.lux b/licentia/source/program/licentia/license.lux index 9060915a3..052ad1f05 100644 --- a/licentia/source/program/licentia/license.lux +++ b/licentia/source/program/licentia/license.lux @@ -6,58 +6,70 @@ ["#." copyright]]) (type: .public Identification - {#name Text - #version Text}) + (Record + [#name Text + #version Text])) (type: .public Termination - {#patent_retaliation? Bit - #termination_period Days - #grace_period Days}) + (Record + [#patent_retaliation? Bit + #termination_period Days + #grace_period Days])) (type: .public Liability - {#can_accept? Bit - #disclaim_high_risk? Bit}) + (Record + [#can_accept? Bit + #disclaim_high_risk? Bit])) (type: .public Distribution - {#can_re_license? Bit - #can_multi_license? Bit}) + (Record + [#can_re_license? Bit + #can_multi_license? Bit])) (type: .public Commercial - {#can_sell? Bit - #require_contributor_credit? Bit - #allow_contributor_endorsement? Bit}) + (Record + [#can_sell? Bit + #require_contributor_credit? Bit + #allow_contributor_endorsement? Bit])) (type: .public Extension - {#same_license? Bit - #must_be_distinguishable? Bit - #notification_period (Maybe (Period Months)) - #must_describe_modifications? Bit}) + (Record + [#same_license? Bit + #must_be_distinguishable? Bit + #notification_period (Maybe (Period Months)) + #must_describe_modifications? Bit])) -(type: .public Entity Text) +(type: .public Entity + Text) (type: .public Black_List - {#justification (Maybe Text) - #entities (List Entity)}) + (Record + [#justification (Maybe Text) + #entities (List Entity)])) -(type: .public URL Text) +(type: .public URL + Text) (type: .public Attribution - {#copyright_notice Text - #phrase (Maybe Text) - #url URL - #image (Maybe URL)}) + (Record + [#copyright_notice Text + #phrase (Maybe Text) + #url URL + #image (Maybe URL)])) (type: .public Addendum - {#commons_clause? Bit}) + (Record + [#commons_clause? Bit])) (type: .public License - {#copyright_holders (List /copyright.Holder) - #identification (Maybe Identification) - #termination Termination - #liability Liability - #distribution Distribution - #commercial Commercial - #extension Extension - #black_lists (List Black_List) - #attribution (Maybe Attribution) - #addendum Addendum}) + (Record + [#copyright_holders (List /copyright.Holder) + #identification (Maybe Identification) + #termination Termination + #liability Liability + #distribution Distribution + #commercial Commercial + #extension Extension + #black_lists (List Black_List) + #attribution (Maybe Attribution) + #addendum Addendum])) diff --git a/licentia/source/program/licentia/license/addendum.lux b/licentia/source/program/licentia/license/addendum.lux index a3518f68e..1fffda746 100644 --- a/licentia/source/program/licentia/license/addendum.lux +++ b/licentia/source/program/licentia/license/addendum.lux @@ -19,8 +19,8 @@ (-> Addendum Text) (`` (format (~~ (template [ <condition> <content>] [(if <condition> - ($.block ($.section {#$.title <title> - #$.content <content>})) + ($.block ($.section [#$.title <title> + #$.content <content>])) "")] ["“Commons Clause” License Condition v1.0" diff --git a/licentia/source/program/licentia/license/copyright.lux b/licentia/source/program/licentia/license/copyright.lux index 7c2d838c1..3d48653b6 100644 --- a/licentia/source/program/licentia/license/copyright.lux +++ b/licentia/source/program/licentia/license/copyright.lux @@ -5,5 +5,6 @@ [time (#+ Year Period)]]) (type: .public Holder - {#name Text - #period (Period Year)}) + (Record + [#name Text + #period (Period Year)])) diff --git a/licentia/source/program/licentia/license/definition.lux b/licentia/source/program/licentia/license/definition.lux index 81be7ffc6..0765a488f 100644 --- a/licentia/source/program/licentia/license/definition.lux +++ b/licentia/source/program/licentia/license/definition.lux @@ -8,8 +8,9 @@ ["$" document]]) (type: .public Definition - {#term Text - #meaning Text}) + (Record + [#term Text + #meaning Text])) (def: not_a_contribution_notice (format text.double_quote "Not a Contribution" text.double_quote)) @@ -47,8 +48,8 @@ (template [<name> <term> <meaning>] [(def: .public <name> Definition - {#term <term> - #meaning <meaning>})] + [#term <term> + #meaning <meaning>])] [license "This License" ($.paragraph (list (format "the terms and conditions defined in this document")))] diff --git a/licentia/source/program/licentia/license/time.lux b/licentia/source/program/licentia/license/time.lux index de6d613b7..e19f7ef16 100644 --- a/licentia/source/program/licentia/license/time.lux +++ b/licentia/source/program/licentia/license/time.lux @@ -12,5 +12,6 @@ Nat) (type: .public (Period a) - {#start a - #end a}) + (Record + [#start a + #end a])) diff --git a/licentia/source/program/licentia/output.lux b/licentia/source/program/licentia/output.lux index c4dd78214..03380ece9 100644 --- a/licentia/source/program/licentia/output.lux +++ b/licentia/source/program/licentia/output.lux @@ -48,8 +48,8 @@ (def: .public (grant termination) (-> Termination Text) (`` (format (~~ (template [<title> <content>] - [($.block ($.section {#$.title <title> - #$.content <content>}))] + [($.block ($.section [#$.title <title> + #$.content <content>]))] ["Grant of Copyright License" grant.copyright] @@ -70,8 +70,8 @@ (def: .public limitation Text (`` (format (~~ (template [<title> <content>] - [($.block ($.section {#$.title <title> - #$.content <content>}))] + [($.block ($.section [#$.title <title> + #$.content <content>]))] ["Limitations on Grant Scope" limitation.grant] @@ -85,8 +85,8 @@ (def: .public assurance Text (`` (format (~~ (template [<title> <content>] - [($.block ($.section {#$.title <title> - #$.content <content>}))] + [($.block ($.section [#$.title <title> + #$.content <content>]))] ["Representation" assurance.representation] @@ -98,8 +98,8 @@ (-> Liability Text) (`` (format (~~ (template [<title> <condition> <content>] [(if <condition> - ($.block ($.section {#$.title <title> - #$.content <content>})) + ($.block ($.section [#$.title <title> + #$.content <content>])) "")] ["Disclaimer of Warranty" @@ -126,8 +126,8 @@ (-> Distribution Text) (`` (format (~~ (template [<title> <condition> <content>] [(if <condition> - ($.block ($.section {#$.title <title> - #$.content <content>})) + ($.block ($.section [#$.title <title> + #$.content <content>])) "")] [(format "Distribution of a " _.source_code_form) @@ -147,8 +147,8 @@ (-> Commercial Text) (`` (format (~~ (template [<title> <condition> <content>] [(if <condition> - ($.block ($.section {#$.title <title> - #$.content <content>})) + ($.block ($.section [#$.title <title> + #$.content <content>])) "")] ["Non-Commerciality" @@ -174,8 +174,8 @@ [false ""])] (`` (format (~~ (template [<condition> <title> <content>] [(if <condition> - ($.block ($.section {#$.title <title> - #$.content <content>})) + ($.block ($.section [#$.title <title> + #$.content <content>])) "")] [(value@ #license.same_license? value) "License Retention" @@ -216,8 +216,8 @@ (-> Bit Text) (`` (format (~~ (template [<title> <condition> <content>] [(if <condition> - ($.block ($.section {#$.title <title> - #$.content <content>})) + ($.block ($.section [#$.title <title> + #$.content <content>])) "")] ["Entire Agreement" @@ -271,25 +271,25 @@ "" black_lists - ($.block ($.section {#$.title (format "Denial of " _.license) + ($.block ($.section [#$.title (format "Denial of " _.license) #$.content (|> black_lists (list\each black_list.black_list) - (text.interposed ..black_list_spacing))}))) + (text.interposed ..black_list_spacing))]))) - ($.section {#$.title "Definitions" + ($.section [#$.title "Definitions" #$.content (|> definition.all (list\each (|>> ..definition $.block)) - (text.interposed ""))}) + (text.interposed ""))]) - ($.block ($.section {#$.title (format "Acceptance of " _.license) - #$.content limitation.acceptance})) + ($.block ($.section [#$.title (format "Acceptance of " _.license) + #$.content limitation.acceptance])) (..grant (value@ #license.termination value)) ..limitation ..assurance - ($.block ($.section {#$.title (format _.submission " of " ($.plural _.contribution)) - #$.content submission.contribution})) + ($.block ($.section [#$.title (format _.submission " of " ($.plural _.contribution)) + #$.content submission.contribution])) (..liability (value@ #license.liability value)) (..distribution (value@ #license.distribution value)) diff --git a/licentia/source/test/licentia.lux b/licentia/source/test/licentia.lux index e9178a996..7238b6c71 100644 --- a/licentia/source/test/licentia.lux +++ b/licentia/source/test/licentia.lux @@ -53,8 +53,8 @@ end (\ ! each (|>> (n.% wiggle_room) (n.max 1)) random.nat)] - (wrap {#time.start start - #time.end end}))) + (wrap [#time.start start + #time.end end]))) (def: copyright_holder (Random copyright.Holder) -- cgit v1.2.3