diff options
31 files changed, 648 insertions, 347 deletions
diff --git a/license.json b/license.json index 488e0ad77..cad63f2c9 100644 --- a/license.json +++ b/license.json @@ -10,7 +10,7 @@ ], "identification": { "name": "Lux License", - "version": "0.1.1" + "version": "0.1.2" }, "termination": { "patent retaliation?": true, diff --git a/license.txt b/license.txt index 361fb2926..c4576a7d1 100644 --- a/license.txt +++ b/license.txt @@ -1,5 +1,5 @@ Lux License -0.1.1 +0.1.2 Copyright (C) 2014-2021 Eduardo Emilio Julián Pereyra @@ -19,56 +19,56 @@ Definitions "Object Form": any form produced by transforming a Source Code Form, including but not limited to compiled code and transpiled code. -"The Work": the work of authorship, whether in a Source Code Form or in an Object Form, made available under This License, as indicated by a copyright notice that is included in or attached to the work of authorship. +"The Licensed Work": the work of authorship, whether in a Source Code Form or in an Object Form, made available under This License, as indicated by a copyright notice that is included in or attached to the work of authorship. -"Derivative Work": any work, whether in a Source Code Form or in an Object Form, that is based on (or derived from) The Work and which represents an original work of authorship. +"Derivative Work": any work, whether in a Source Code Form or in an Object Form, that is based on (or derived from) The Licensed Work and which represents an original work of authorship. -"Submission": any form of electronic, or verbal, or written communication sent to The Licensor, or its representatives, for the purpose of discussing and improving The Work, but excluding communication that is designated in writing by the copyright owner as "Not a Contribution". +"Submission": any form of electronic, or verbal, or written communication sent to The Licensor, or its representatives, for the purpose of discussing and improving The Licensed Work, but excluding communication that is designated in writing by the copyright owner as "Not a Contribution". -"Modification": any addition to, or deletion from, the substance or structure of a file or other storage contained in The Work, or any new file or other storage that contains any part of The Work, or any file or other storage which replaces or otherwise alters the original functionality of The Work at runtime. +"Modification": any addition to, or deletion from, the substance or structure of a file or other storage contained in The Licensed Work, or any new file or other storage that contains any part of The Licensed Work, or any file or other storage which replaces or otherwise alters the original functionality of The Licensed Work at runtime. "Required Component": any text, or program, or script, or schema, or interface definition, or control file, or other work created by Recipient which is required by a third party to successfully install and run a Derivative Work by Recipient. "Extension": any Modification, or Derivative Work, or Required Component. -"Contribution": any work of authorship, including the original version of The Work and any Extension to The Work, that is intentionally communicated as a Submission to The Licensor for inclusion in The Work by the copyright owner, or by a Legal Entity authorized to submit on behalf of the copyright owner. +"Contribution": any work of authorship, including the original version of The Licensed Work and any Extension to The Licensed Work, that is intentionally communicated as a Submission to The Licensor for inclusion in The Licensed Work by the copyright owner, or by a Legal Entity authorized to submit on behalf of the copyright owner. -"Contributor": The Licensor or any Legal Entity on behalf of whom a Contribution has been received by The Licensor, and subsequently incorporated within The Work. +"Contributor": The Licensor or any Legal Entity on behalf of whom a Contribution has been received by The Licensor, and subsequently incorporated within The Licensed Work. "Patent Claim Of A Contributor": any patent claim(s), including without limitation method, and process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of This License, to make, or have made, or use, or offer to sell, or sell, or import, or transfer its Contribution. "Secondary License": any license for which compliance does not imply or require violating the terms of This License. -"Sell": practicing any or all of the rights granted to Recipient under This License to provide to third parties, for a fee or other consideration (including without limitation fees for hosting services, or consulting services, or support services related to The Work), a product or service whose value derives, entirely or substantially, from the functionality of The Work. +"Sell": practicing any or all of the rights granted to Recipient under This License to provide to third parties, for a fee or other consideration (including without limitation fees for hosting services, or consulting services, or support services related to The Licensed Work), a product or service whose value derives, entirely or substantially, from the functionality of The Licensed Work. -"Personal Use": use of The Work by an individual solely for his or her personal, and private, and non-commercial purposes. -An individual's use of The Work in his or her capacity as an officer, or employee, or member, or independent contractor, or agent of a corporation, business or organization (commercial or non-commercial) does not qualify. +"Personal Use": use of The Licensed Work by an individual solely for his or her personal, and private, and non-commercial purposes. +An individual's use of The Licensed Work in his or her capacity as an officer, or employee, or member, or independent contractor, or agent of a corporation, business or organization (commercial or non-commercial) does not qualify. -"Serve": to deliver The Work and/or any Extension by means of a computer network to one or more computers for purposes of execution of The Work, and/or the Extension. +"Serve": to deliver The Licensed Work and/or any Extension by means of a computer network to one or more computers for purposes of execution of The Licensed Work, and/or the Extension. -"Research": investigation or experimentation for the purpose of understanding the nature and limits of The Work and its potential uses. +"Research": investigation or experimentation for the purpose of understanding the nature and limits of The Licensed Work and its potential uses. -"Deploy": to use, or Serve, or sublicense, or distribute The Work other than for internal Research and/or Personal Use by Recipient, and includes without limitation, any and all internal use or distribution of The Work within a business or organization in which Recipient participates, other than for Research and/or Personal Use, as well as direct sublicensing, or indirect sublicensing, or distribution of The Work by Recipient to any third party in any form or manner. +"Deploy": to use, or Serve, or sublicense, or distribute The Licensed Work other than for internal Research and/or Personal Use by Recipient, and includes without limitation, any and all internal use or distribution of The Licensed Work within a business or organization in which Recipient participates, other than for Research and/or Personal Use, as well as direct sublicensing, or indirect sublicensing, or distribution of The Licensed Work by Recipient to any third party in any form or manner. "Electronic Distribution Mechanism": a mechanism generally accepted in the software development community for the electronic transfer of data, such as download from an FTP server or web site, where such mechanism is publicly accessible. Acceptance of This License Recipient is not required to accept This License since Recipient has not signed it. -However, nothing else grants Recipient permission to use, or copy, or distribute, or modify, or create an Extension of either The Work or any Extension created by a Contributor. +However, nothing else grants Recipient permission to use, or copy, or distribute, or modify, or create an Extension of either The Licensed Work or any Extension created by a Contributor. These actions are prohibited by law if Recipient does not accept This License. Therefore, by performing any of these actions, Recipient indicates that Recipient accepts This License, and Recipient agrees to be bound by all its terms and conditions. -If Recipient does not agree with all the terms and conditions of This License, Recipient can not use, or copy, or distribute, or modify, or create an Extension of either The Work or any Extension created by a Contributor. -If it is impossible for Recipient to comply with all the terms and conditions of This License, then Recipient can not use, or copy, or distribute, or modify, or create an Extension of either The Work or any Extension created by a Contributor. +If Recipient does not agree with all the terms and conditions of This License, Recipient can not use, or copy, or distribute, or modify, or create an Extension of either The Licensed Work or any Extension created by a Contributor. +If it is impossible for Recipient to comply with all the terms and conditions of This License, then Recipient can not use, or copy, or distribute, or modify, or create an Extension of either The Licensed Work or any Extension created by a Contributor. Grant of Copyright License -Subject to the terms and conditions of This License, each Contributor hereby grants to Recipient a perpetual, and world-wide, and non-exclusive, and no-charge, and royalty-free, and irrevocable copyright license to use, or reproduce, or display, or perform, or modify, or create an Extension of, or sublicense, or distribute The Work and such an Extension in a Source Code Form or an Object Form. +Subject to the terms and conditions of This License, each Contributor hereby grants to Recipient a perpetual, and world-wide, and non-exclusive, and no-charge, and royalty-free, and irrevocable copyright license to use, or reproduce, or display, or perform, or modify, or create an Extension of, or sublicense, or distribute The Licensed Work and such an Extension in a Source Code Form or an Object Form. Grant of Patent License -Subject to the terms and conditions of This License, each Contributor hereby grants to Recipient a perpetual, and world-wide, and non-exclusive, and no-charge, and royalty-free, and irrevocable patent license to make, or have made, or use, or offer to sell, or sell, or import, or transfer The Work, where such license applies only to any Patent Claim Of A Contributor that is necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with The Work. -If Recipient institutes patent litigation against any Legal Entity (including a cross-claim or counterclaim in a lawsuit) alleging that The Work or a Contribution incorporated within The Work constitutes direct or contributory patent infringement, then any patent licenses granted to Recipient under This License for The Work shall terminate as of the date such litigation is filed. +Subject to the terms and conditions of This License, each Contributor hereby grants to Recipient a perpetual, and world-wide, and non-exclusive, and no-charge, and royalty-free, and irrevocable patent license to make, or have made, or use, or offer to sell, or sell, or import, or transfer The Licensed Work, where such license applies only to any Patent Claim Of A Contributor that is necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with The Licensed Work. +If Recipient institutes patent litigation against any Legal Entity (including a cross-claim or counterclaim in a lawsuit) alleging that The Licensed Work or a Contribution incorporated within The Licensed Work constitutes direct or contributory patent infringement, then any patent licenses granted to Recipient under This License for The Licensed Work shall terminate as of the date such litigation is filed. Effective Date for the Grants @@ -87,16 +87,16 @@ In the event of termination, all end user license agreements (excluding licenses Limitations on Grant Scope The licenses granted in this document are the only rights granted under This License. -No additional rights or licenses will be implied from the distribution or licensing of The Work under This License. -No patent license is granted by a Contributor for any code that the Contributor has removed from The Work. +No additional rights or licenses will be implied from the distribution or licensing of The Licensed Work under This License. +No patent license is granted by a Contributor for any code that the Contributor has removed from The Licensed Work. Limitations on Trademarks -This License does not grant any permission to use the trade names, or trademarks, or service marks, or product names, or logos of any Contributor; except as required for reasonable and customary use in describing the origin of The Work. +This License does not grant any permission to use the trade names, or trademarks, or service marks, or product names, or logos of any Contributor; except as required for reasonable and customary use in describing the origin of The Licensed Work. Limitations on Secondary License(s) -No Contributor makes additional grants as a result of a choice by Recipient to distribute The Work under a under the terms of a Secondary License. +No Contributor makes additional grants as a result of a choice by Recipient to distribute The Licensed Work under a under the terms of a Secondary License. Representation @@ -108,17 +108,17 @@ This License is not intended to limit any rights Recipient has under applicable Submission of Contribution(s) -Unless Recipient explicitly states otherwise, any intentional Submission of a Contribution for inclusion in The Work by Recipient to The Licensor shall be under the terms and conditions of This License, without any additional terms or conditions. +Unless Recipient explicitly states otherwise, any intentional Submission of a Contribution for inclusion in The Licensed Work by Recipient to The Licensor shall be under the terms and conditions of This License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement Recipient may have executed with The Licensor regarding such Contribution. Disclaimer of Warranty -Unless required by applicable law or agreed to in writing, The Licensor provides The Work, and each Contributor provides its Contribution(s) under This License on an "as is" basis, without warranty or condition of any kind, either expressed, or implied, or statutory including, without limitation, any warranties or conditions that The Work is free of defects, or merchantable, or fit for a particular purpose, or non-infringing. -Recipient is solely responsible for determining the appropriateness of using or redistributing The Work. -The entire risk as to the quality and performance of The Work is with Recipient. -Should The Work prove defective in any respect, Recipient, not any Contributor, assumes the cost of any necessary servicing, or repair, or correction. +Unless required by applicable law or agreed to in writing, The Licensor provides The Licensed Work, and each Contributor provides its Contribution(s) under This License on an "as is" basis, without warranty or condition of any kind, either expressed, or implied, or statutory including, without limitation, any warranties or conditions that The Licensed Work is free of defects, or merchantable, or fit for a particular purpose, or non-infringing. +Recipient is solely responsible for determining the appropriateness of using or redistributing The Licensed Work. +The entire risk as to the quality and performance of The Licensed Work is with Recipient. +Should The Licensed Work prove defective in any respect, Recipient, not any Contributor, assumes the cost of any necessary servicing, or repair, or correction. This disclaimer of warranty constitutes an essential part of This License. -No use of The Work is authorized under This License except under this disclaimer. +No use of The Licensed Work is authorized under This License except under this disclaimer. Limitation of Liability @@ -134,29 +134,29 @@ Nothing in this section shall prevent a party’s ability to bring cross-claims High Risk Activities -The Work is not fault tolerant, and is not designed, or manufactured, or intended for use or distribution as on-line control equipment in hazardous environments requiring fail-safe performance, such as in the operation of nuclear facilities, or aircraft navigation, or communications systems, or air traffic control, or direct life support machines, or weapons systems, in which the failure of The Work could lead directly to death, or personal injury, or severe physical damage, or environmental damage. +The Licensed Work is not fault tolerant, and is not designed, or manufactured, or intended for use or distribution as on-line control equipment in hazardous environments requiring fail-safe performance, such as in the operation of nuclear facilities, or aircraft navigation, or communications systems, or air traffic control, or direct life support machines, or weapons systems, in which the failure of The Licensed Work could lead directly to death, or personal injury, or severe physical damage, or environmental damage. The Licensor and every Contributor specifically disclaim any express or implied warranty of fitness for high risk activities. Distribution of a Source Code Form -All distribution of The Work in Source Code Form, including any Contribution(s) that Recipient creates, must be under the terms of This License. -Recipient must inform recipients that the Source Code Form of The Work is governed by the terms of This License, and how they can obtain a copy of This License. +All distribution of The Licensed Work in Source Code Form, including any Contribution(s) that Recipient creates, must be under the terms of This License. +Recipient must inform recipients that the Source Code Form of The Licensed Work is governed by the terms of This License, and how they can obtain a copy of This License. Recipient may not attempt to alter or restrict the recipients’ rights in the Source Code Form, as specified in This License. -Recipient must retain, in the Source Code Form of any Extension that Recipient distributes, all copyright notices, and patent notices, and trademark notices, and attribution notices, and disclaimer of warranty notices, and limitation of liability notices, and other notices from the Source Code Form of The Work, excluding those notices that do not pertain to any part of the Extension, or those notices that contain known factual inaccuracies. +Recipient must retain, in the Source Code Form of any Extension that Recipient distributes, all copyright notices, and patent notices, and trademark notices, and attribution notices, and disclaimer of warranty notices, and limitation of liability notices, and other notices from the Source Code Form of The Licensed Work, excluding those notices that do not pertain to any part of the Extension, or those notices that contain known factual inaccuracies. Recipient may add additional copyright notices, and patent notices, and trademark notices, and attribution notices, and disclaimer of warranty notices, and limitation of liability notices, and other notices within an Extension that Recipient distributes, provided that such additional copyright notices, and patent notices, and trademark notices, and attribution notices, and disclaimer of warranty notices, and limitation of liability notices, and other notices cannot be construed as modifying This License. Distribution of an Object Form -If Recipient distributes The Work in Object Form then The Work must also be made available in Source Code Form, and Recipient must inform recipients of the Object Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient. +If Recipient distributes The Licensed Work in Object Form then The Licensed Work must also be made available in Source Code Form, and Recipient must inform recipients of the Object Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient. Recipient may distribute such Object Form under the terms of This License. Non-Commerciality -Without limiting other conditions in This License, the grant of rights under This License will not include, and does not grant to Recipient, the right to Sell The Work, or any Derivative Work. +Without limiting other conditions in This License, the grant of rights under This License will not include, and does not grant to Recipient, the right to Sell The Licensed Work, or any Derivative Work. Contributor Attribution -All advertising materials mentioning features or use of The Work must include an acknowledgement of the authorship of every Contributor. +All advertising materials mentioning features or use of The Licensed Work must include an acknowledgement of the authorship of every Contributor. Contributor Endorsement @@ -166,9 +166,9 @@ License Retention In consideration of, and as an express condition to, the licenses granted to Recipient under This License, Recipient hereby agrees that any Extension that Recipient creates or to which Recipient contributes are governed by the terms of This License. Recipient may only Deploy an Extension that Recipient creates under the terms of This License. -Recipient hereby grant to The Licensor and all third parties a perpetual, and world-wide, and non-exclusive, and no-charge, and royalty-free, and irrevocable license under those intellectual property rights Recipient owns or controls to use, or reproduce, or display, or perform, or modify, or create an Extension of, or sublicense, or distribute The Work in any form. +Recipient hereby grant to The Licensor and all third parties a perpetual, and world-wide, and non-exclusive, and no-charge, and royalty-free, and irrevocable license under those intellectual property rights Recipient owns or controls to use, or reproduce, or display, or perform, or modify, or create an Extension of, or sublicense, or distribute The Licensed Work in any form. Recipient must include a copy of This License or directions on how to obtain a copy with every copy of an Extension Recipient distributes. -Recipient agrees not to offer or impose any terms on any Source Code Form or Object Form of the The Work, or its Extension that alter or restrict the applicable version of This License or the recipients' rights hereunder. +Recipient agrees not to offer or impose any terms on any Source Code Form or Object Form of the The Licensed Work, or its Extension that alter or restrict the applicable version of This License or the recipients' rights hereunder. Where any portion of an Extension created by Recipient fall under the terms of another license, the terms of that license should be honored. However Recipient must also make the Extension available under This License. If the terms of This License continue to conflict with the terms of the other license, Recipient may write The Licensor for permission to resolve the conflict in a fashion that remains consistent with the intent of This License. @@ -185,13 +185,13 @@ The Source Code Form must remain available via an Electronic Distribution Mechan Recipient is responsible for ensuring that the Source Code Form to each Extension Recipient does Deploy remains available even if the Electronic Distribution Mechanism is maintained by a third party. Recipient may not charge a fee for any copy of the Source Code Form in excess of the actual cost of duplication and distribution of said copy that Recipient incurs. Should such instructions change, Recipient must notify the software community of revised instructions within 1 month(s) of the date of change. -Recipient must provide notification by posting to appropriate news groups, or mailing lists, or weblogs, or other sites where a publicly accessible search engine would reasonably be expected to index a post in relationship to queries regarding The Work and/or an Extension created by Recipient. +Recipient must provide notification by posting to appropriate news groups, or mailing lists, or weblogs, or other sites where a publicly accessible search engine would reasonably be expected to index a post in relationship to queries regarding The Licensed Work and/or an Extension created by Recipient. Description of Modification(s) Recipient must cause any Modification that Recipient creates, or to which Recipient contributes, to be documented in the Source Code Form, clearly describing the additions, and changes, and deletions that Recipient made. -Recipient must include a prominent statement that the Modification is derived, directly or indirectly, from The Work and include the names of The Licensor and any Contributor to The Work in the Source Code Form, and in any notice displayed by The Work Recipient distributes, and in related documentation in which Recipient describes the origin or ownership of The Work. -Recipient may not modify or delete any pre-existing copyright notices, change notices or the text of This License in The Work without written permission of The Licensor or the respective Contributor. +Recipient must include a prominent statement that the Modification is derived, directly or indirectly, from The Licensed Work and include the names of The Licensor and any Contributor to The Licensed Work in the Source Code Form, and in any notice displayed by The Licensed Work Recipient distributes, and in related documentation in which Recipient describes the origin or ownership of The Licensed Work. +Recipient may not modify or delete any pre-existing copyright notices, change notices or the text of This License in The Licensed Work without written permission of The Licensor or the respective Contributor. Attribution Information @@ -221,14 +221,14 @@ Any law or regulation which provides that the language of a contract shall be co Export Restrictions -Recipient may be restricted with respect to downloading, or acquiring, or exporting, or reexporting The Work or any underlying information or technology by applicable laws and regulations. -By downloading, or acquiring, or exporting, or reexporting The Work, Recipient is agreeing to be responsible for compliance with all applicable laws and regulations. +Recipient may be restricted with respect to downloading, or acquiring, or exporting, or reexporting The Licensed Work or any underlying information or technology by applicable laws and regulations. +By downloading, or acquiring, or exporting, or reexporting The Licensed Work, Recipient is agreeing to be responsible for compliance with all applicable laws and regulations. Versions of This License The Licensor may publish, from time to time, revised versions of This License. -Once The Work has been published under a particular version of This License, Recipient may always continue to use it under the terms of that version. -Recipient may also choose to use The Work under the terms of any subsequent version of This License published by The Licensor. -No one other than The Licensor has the right to modify the terms applicable to The Work created under This License. +Once The Licensed Work has been published under a particular version of This License, Recipient may always continue to use it under the terms of that version. +Recipient may also choose to use The Licensed Work under the terms of any subsequent version of This License published by The Licensor. +No one other than The Licensor has the right to modify the terms applicable to The Licensed Work created under This License. -END OF TERMS AND CONDITIONS. +END OF TERMS AND CONDITIONS.
\ No newline at end of file diff --git a/licentia/source/program/licentia.lux b/licentia/source/program/licentia.lux index 44babb828..a3b30a5c2 100644 --- a/licentia/source/program/licentia.lux +++ b/licentia/source/program/licentia.lux @@ -42,7 +42,6 @@ ["#." output]]) (with_expansions [<expiry> "2022-04-01"] - (to_do <expiry> "Replace _.work with _.covered_work or _.licensed_work") (to_do <expiry> "Create a short notice to add as a comment to each file in the _.work")) (import: java/lang/String @@ -57,9 +56,11 @@ (format "Your license has been made!" text.new_line "Check the file " output ".")) -(program: [{input (<cli>.named "--input" <cli>.any)} - {output (parser.default ..default_output_file - (<cli>.named "--output" <cli>.any))}] +(program: [{input (<| (<cli>.named "--input") + <cli>.any)} + {output (<| (parser.default ..default_output_file) + (<cli>.named "--output") + <cli>.any)}] (do io.monad [?done (: (IO (Try Any)) (do (try.with io.monad) diff --git a/licentia/source/program/licentia/license/commercial.lux b/licentia/source/program/licentia/license/commercial.lux index a17acdbb3..3c223b05d 100644 --- a/licentia/source/program/licentia/license/commercial.lux +++ b/licentia/source/program/licentia/license/commercial.lux @@ -12,14 +12,14 @@ (let [preamble (format "Without limiting other conditions in " _.license) direct_condition (format "the grant of rights under " _.license " will not include, and does not grant to " _.recipient - ", the right to " _.sell " " _.work) + ", the right to " _.sell " " _.licensed_work) derivative_condition (format "or any " _.derivative_work)] ($.sentence (format preamble ", " direct_condition ", " derivative_condition)))) (def: #export require_contributor_attribution - ($.sentence (format "All advertising materials mentioning features or use of " _.work + ($.sentence (format "All advertising materials mentioning features or use of " _.licensed_work " must include an acknowledgement of the authorship of every " _.contributor))) (def: #export disallow_contributor_endorsement diff --git a/licentia/source/program/licentia/license/definition.lux b/licentia/source/program/licentia/license/definition.lux index e93230b33..f44a06fdc 100644 --- a/licentia/source/program/licentia/license/definition.lux +++ b/licentia/source/program/licentia/license/definition.lux @@ -74,7 +74,7 @@ [object_form "Object Form" ($.paragraph (list (format "any form produced by transforming a " (get@ #term source_code_form) ", including but not limited to compiled code and transpiled code")))] - [work "The Work" + [licensed_work "The Licensed Work" ($.paragraph (list (format "the " ..covered_work_description ", whether in a " (get@ #term source_code_form) " or in an " (get@ #term object_form) @@ -84,7 +84,7 @@ [derivative_work "Derivative Work" ($.paragraph (list (format "any work, whether in a " (get@ #term source_code_form) " or in an " (get@ #term object_form) - ", that is based on (or derived from) " (get@ #term work) + ", that is based on (or derived from) " (get@ #term licensed_work) " and which represents an original " ..covered_work_description)))] [submission "Submission" @@ -93,16 +93,16 @@ "verbal" "written"))] ($.paragraph (list (format "any form of " ($.or forms_of_communication) " communication sent to " (get@ #term licensor) - ", or its representatives, for the purpose of discussing and improving " (get@ #term work) + ", or its representatives, for the purpose of discussing and improving " (get@ #term licensed_work) ", but excluding communication that is designated in writing by the copyright owner as " not_a_contribution_notice))))] [modification "Modification" (let [alteration "any addition to, or deletion from, the substance or structure of" object "file or other storage" targets (: (List Text) - (list (format "a " object " contained in " (get@ #term work)) - (format "any new " object " that contains any part of " (get@ #term work)) - (format "any " object " which replaces or otherwise alters the original functionality of "(get@ #term work) " at runtime")))] + (list (format "a " object " contained in " (get@ #term licensed_work)) + (format "any new " object " that contains any part of " (get@ #term licensed_work)) + (format "any " object " which replaces or otherwise alters the original functionality of "(get@ #term licensed_work) " at runtime")))] ($.paragraph (list (format alteration " " ($.or targets)))))] [required_component "Required Component" @@ -127,11 +127,11 @@ ($.paragraph (list (format "any " ($.or possibilities)))))] [contribution "Contribution" - ($.paragraph (list (format "any " covered_work_description ", including the original version of " (get@ #term work) - " and any " (get@ #term extension) " to " (get@ #term work) + ($.paragraph (list (format "any " covered_work_description ", including the original version of " (get@ #term licensed_work) + " and any " (get@ #term extension) " to " (get@ #term licensed_work) ", that is intentionally communicated as a " (get@ #term submission) " to " (get@ #term licensor) - " for inclusion in " (get@ #term work) " by the copyright owner" + " for inclusion in " (get@ #term licensed_work) " by the copyright owner" ", or by a " (get@ #term legal_entity) " authorized to submit on behalf of the copyright owner")))] [contributor "Contributor" @@ -139,7 +139,7 @@ " or any " (get@ #term legal_entity) " on behalf of whom a " (get@ #term contribution) " has been received by " (get@ #term licensor) - ", and subsequently incorporated within " (get@ #term work))))] + ", and subsequently incorporated within " (get@ #term licensed_work))))] [patent_claim (format "Patent Claim Of A " (get@ #term contributor)) (let [claim_types (: (List Text) @@ -159,25 +159,25 @@ " under " (get@ #term license) " to provide to third parties, for a fee or other consideration " "(including without limitation fees for " ($.or commercial_services) - " related to "(get@ #term work) ")" - ", a product or service whose value derives, entirely or substantially, from the functionality of " (get@ #term work))))] + " related to "(get@ #term licensed_work) ")" + ", a product or service whose value derives, entirely or substantially, from the functionality of " (get@ #term licensed_work))))] [personal_use "Personal Use" (let [valid_purposes (: (List Text) (list "personal" "private" "non-commercial"))] - ($.paragraph (list (format "use of " (get@ #term work) " by an individual solely for his or her " ($.and valid_purposes) " purposes") - (format "An individual's use of " (get@ #term work) " in his or her capacity as an " ($.or individual_capacities) " does not qualify"))))] + ($.paragraph (list (format "use of " (get@ #term licensed_work) " by an individual solely for his or her " ($.and valid_purposes) " purposes") + (format "An individual's use of " (get@ #term licensed_work) " in his or her capacity as an " ($.or individual_capacities) " does not qualify"))))] [serve "Serve" - ($.paragraph (list (format "to deliver " (get@ #term work) + ($.paragraph (list (format "to deliver " (get@ #term licensed_work) " and/or any " (get@ #term extension) - " by means of a computer network to one or more computers for purposes of execution of " (get@ #term work) + " by means of a computer network to one or more computers for purposes of execution of " (get@ #term licensed_work) ", and/or the " (get@ #term extension))))] [research "Research" - ($.paragraph (list (format "investigation or experimentation for the purpose of understanding the nature and limits of " (get@ #term work) " and its potential uses")))] + ($.paragraph (list (format "investigation or experimentation for the purpose of understanding the nature and limits of " (get@ #term licensed_work) " and its potential uses")))] [deploy "Deploy" (let [deployment_types (: (List Text) @@ -193,11 +193,11 @@ (sub_licensing "indirect") "distribution")) basic_definition (format "to " ($.or deployment_types) - " " (get@ #term work) + " " (get@ #term licensed_work) " other than for internal " (get@ #term research) " and/or " (get@ #term personal_use) " by " (get@ #term recipient)) - examples (format "any and all internal use or distribution of " (get@ #term work) + examples (format "any and all internal use or distribution of " (get@ #term licensed_work) " within a business or organization in which " (get@ #term recipient) " participates") exceptions (format "for " (get@ #term research) " and/or " (get@ #term personal_use))] @@ -205,7 +205,7 @@ ", and includes without limitation, " examples ", other than " exceptions ", as well as " ($.or third_party_interactions) - " of " (get@ #term work) + " of " (get@ #term licensed_work) " by " (get@ #term recipient) " to any third party in any form or manner"))))] @@ -222,7 +222,7 @@ licensor source_code_form object_form - work + licensed_work derivative_work submission modification diff --git a/licentia/source/program/licentia/license/distribution.lux b/licentia/source/program/licentia/license/distribution.lux index 8ec4e9bae..7c736be7a 100644 --- a/licentia/source/program/licentia/license/distribution.lux +++ b/licentia/source/program/licentia/license/distribution.lux @@ -24,7 +24,7 @@ (notices "other")))) (def: #export source_code_form - (let [on_license_propagation (let [coverage (format "All distribution of " _.work " in " _.source_code_form) + (let [on_license_propagation (let [coverage (format "All distribution of " _.licensed_work " in " _.source_code_form) with_contributions (format "including any " ($.plural _.contribution) " that " _.recipient " creates") @@ -32,7 +32,7 @@ (format coverage ", " with_contributions ", " same_license)) on_license_access (let [responsibility_to_inform (format _.recipient " must inform recipients that the " _.source_code_form - " of " _.work + " of " _.licensed_work " is governed by the terms of " _.license) license_copy (format "and how they can obtain a copy of " _.license)] (format responsibility_to_inform ", " license_copy)) @@ -44,7 +44,7 @@ " of any " _.extension " that " _.recipient " distributes") - what (format "all " ($.and notices) " from the " _.source_code_form " of " _.work) + what (format "all " ($.and notices) " from the " _.source_code_form " of " _.licensed_work) exclusion ($.or (list (format "those notices that do not pertain to any part of the " _.extension) "those notices that contain known factual inaccuracies"))] (format obligation ", " location ", " what ", excluding " exclusion)) @@ -63,9 +63,9 @@ (def: #export object_form (let [on_responsibility (let [condition (format "If " _.recipient - " distributes " _.work + " distributes " _.licensed_work " in " _.object_form) - responsibility (let [availability_responsibility (format _.work " must also be made available in " _.source_code_form) + responsibility (let [availability_responsibility (format _.licensed_work " must also be made available in " _.source_code_form) source_code_responsibility (format _.recipient " must inform recipients of the " _.object_form " how they can obtain a copy of such " _.source_code_form) @@ -85,17 +85,17 @@ " chooses") requirement (format _.recipient " also comply with the requirements of " _.license - " for the " _.work)] + " for the " _.licensed_work)] (format can_license ", " "provided that " requirement))) (def: #export allow_multi_licensing - (let [condition (format "the " _.extension " is a combination of " _.work " with a work governed by one or more " ($.plural _.secondary_license)) + (let [condition (format "the " _.extension " is a combination of " _.licensed_work " with a work governed by one or more " ($.plural _.secondary_license)) permission (let [relicensing (format _.license " permits " _.recipient - " to additionally distribute " _.work + " to additionally distribute " _.licensed_work " under the terms of such " ($.plural _.secondary_license)) distribution (format "so that the recipient of the " _.extension - " may, at their option, further distribute " _.work + " may, at their option, further distribute " _.licensed_work " under the terms of either " _.license " or such " ($.plural _.secondary_license))] (format relicensing ", " distribution))] diff --git a/licentia/source/program/licentia/license/extension.lux b/licentia/source/program/licentia/license/extension.lux index c6b368d33..0ed6ca040 100644 --- a/licentia/source/program/licentia/license/extension.lux +++ b/licentia/source/program/licentia/license/extension.lux @@ -31,7 +31,7 @@ " and all third parties a " ($.and grant.grant_characteristics) " license under those intellectual property rights " _.recipient " owns or controls to " ($.or grant.copyright_grant_rights) - " " _.work + " " _.licensed_work " in any form") on_license_propagation (format _.recipient " must include a copy of " _.license @@ -40,7 +40,7 @@ on_license_protection (format _.recipient " agrees not to offer or impose any terms on any " _.source_code_form " or " _.object_form - " of the " _.work + " of the " _.licensed_work ", or its " _.extension " that alter or restrict the applicable version of " _.license " or the recipients' rights hereunder")] @@ -118,7 +118,7 @@ " month(s) of the date of change") on_accesibility (format _.recipient " must provide notification by posting to appropriate " ($.or news_sources) - " where a publicly accessible search engine would reasonably be expected to index a post in relationship to queries regarding " _.work + " where a publicly accessible search engine would reasonably be expected to index a post in relationship to queries regarding " _.licensed_work " and/or an " _.extension " created by " _.recipient)] ($.paragraph (list on_availability @@ -144,21 +144,21 @@ (format basic ", " details)) on_notice_location (let [statement_locations (: (List Text) (list (format "in the " _.source_code_form) - (format "in any notice displayed by " _.work + (format "in any notice displayed by " _.licensed_work " " _.recipient " distributes") (format "in related documentation in which " _.recipient - " describes the origin or ownership of " _.work)))] + " describes the origin or ownership of " _.licensed_work)))] (format _.recipient " must include a prominent statement that the " _.modification - " is derived, directly or indirectly, from " _.work + " is derived, directly or indirectly, from " _.licensed_work " and include the names of " _.licensor " and any " _.contributor - " to " _.work + " to " _.licensed_work " " ($.and statement_locations))) on_notice_preservation (format _.recipient " may not modify or delete any pre-existing copyright notices, change notices or the text of " _.license - " in " _.work + " in " _.licensed_work " without written permission of " _.licensor " or the respective " _.contributor)] ($.paragraph (list on_duty diff --git a/licentia/source/program/licentia/license/grant.lux b/licentia/source/program/licentia/license/grant.lux index c79fcee09..ea7ac399f 100644 --- a/licentia/source/program/licentia/license/grant.lux +++ b/licentia/source/program/licentia/license/grant.lux @@ -38,7 +38,7 @@ (def: #export copyright ($.sentence (format grant_header " a " ($.and ..grant_characteristics) " copyright license to " ($.or ..copyright_grant_rights) - " " _.work + " " _.licensed_work " and such an " _.extension " in a " _.source_code_form " or an " _.object_form))) @@ -47,18 +47,18 @@ (-> Bit Text) (let [grant (format grant_header " a " ($.and ..grant_characteristics) " patent license to " ($.or definition.patent_rights) " " - _.work + _.licensed_work ", where such license applies only to any " _.patent_claim " that is necessarily infringed by their " ($.plural _.contribution) " alone or by combination of their " ($.plural _.contribution) - " with " _.work) + " with " _.licensed_work) retaliation_clause (format "If " _.recipient " institutes patent litigation against any " _.legal_entity " (including a cross-claim or counterclaim in a lawsuit) alleging that " - _.work " or a " _.contribution - " incorporated within " _.work " constitutes direct or contributory patent infringement" + _.licensed_work " or a " _.contribution + " incorporated within " _.licensed_work " constitutes direct or contributory patent infringement" ", then any patent licenses granted to " _.recipient " under " _.license - " for " _.work + " for " _.licensed_work " shall terminate as of the date such litigation is filed")] ($.paragraph (list& grant (if retaliation? diff --git a/licentia/source/program/licentia/license/liability.lux b/licentia/source/program/licentia/license/liability.lux index 1ad88c43d..b4c410444 100644 --- a/licentia/source/program/licentia/license/liability.lux +++ b/licentia/source/program/licentia/license/liability.lux @@ -30,7 +30,7 @@ (def: #export warranty (let [on_basics (let [applicability_escape "Unless required by applicable law or agreed to in writing" work_provisioning (format _.licensor - " provides " _.work + " provides " _.licensed_work ", and each " _.contributor " provides its " ($.plural _.contribution))] (format applicability_escape ", " @@ -38,18 +38,18 @@ " under " _.license " on an " ($.quote "as is") " basis, without warranty or condition of any kind, either " ($.or warranty_communications) - " including, without limitation, any warranties or conditions that " _.work + " including, without limitation, any warranties or conditions that " _.licensed_work " is " ($.or work_disclamers))) on_distribution (format _.recipient - " is solely responsible for determining the appropriateness of using or redistributing " _.work) - on_risk (format "The entire risk as to the quality and performance of " _.work + " is solely responsible for determining the appropriateness of using or redistributing " _.licensed_work) + on_risk (format "The entire risk as to the quality and performance of " _.licensed_work " is with " _.recipient) - on_fixes (format "Should " _.work + on_fixes (format "Should " _.licensed_work " prove defective in any respect, " _.recipient ", not any " _.contributor ", assumes the cost of any necessary " ($.or fixes)) on_importance (format "This disclaimer of warranty constitutes an essential part of "_.license) - on_authorization (format "No use of "_.work + on_authorization (format "No use of "_.licensed_work " is authorized under " _.license " except under this disclaimer")] ($.paragraph (list on_basics @@ -108,7 +108,7 @@ (format "rights consistent with " _.license))) (def: #export can_accept - (let [on_acceptance_of_liability (let [condition (format "While redistributing " _.work " or " ($.plural _.extension) " thereof") + (let [on_acceptance_of_liability (let [condition (format "While redistributing " _.licensed_work " or " ($.plural _.extension) " thereof") right (format _.recipient " may choose to offer, and charge a fee for, acceptance of " ($.and/or ..liability_obligations))] (format condition ", " right)) on_responsibility (let [but "However, in accepting such obligations" @@ -146,11 +146,11 @@ "personal injury" "severe physical damage" "environmental damage")) - disclaim (format _.work " is not fault tolerant" + disclaim (format _.licensed_work " is not fault tolerant" ", and is not " ($.or intentions) " as on-line control equipment in hazardous environments requiring fail-safe performance") examples (format "such as in the operation of " ($.or hazardous_environments)) - further (format "in which the failure of " _.work " could lead directly to " ($.or consequences))] + further (format "in which the failure of " _.licensed_work " could lead directly to " ($.or consequences))] (format disclaim ", " examples ", " further)) on_contributors (let [claim "any express or implied warranty of fitness for high risk activities"] (format _.licensor diff --git a/licentia/source/program/licentia/license/limitation.lux b/licentia/source/program/licentia/license/limitation.lux index 046e60a55..77611d3a6 100644 --- a/licentia/source/program/licentia/license/limitation.lux +++ b/licentia/source/program/licentia/license/limitation.lux @@ -15,7 +15,7 @@ "distribute" "modify" (format "create an " _.extension - " of either " _.work + " of either " _.licensed_work " or any " _.extension " created by a " _.contributor))) acknowledgement (format _.recipient @@ -48,11 +48,11 @@ (def: #export grant ($.paragraph (list (format "The licenses granted in this document are the only rights granted under " _.license) - (format "No additional rights or licenses will be implied from the distribution or licensing of " _.work + (format "No additional rights or licenses will be implied from the distribution or licensing of " _.licensed_work " under " _.license) (format "No patent license is granted by a " _.contributor " for any code that the " _.contributor - " has removed from " _.work)))) + " has removed from " _.licensed_work)))) (def: identifiers (List Text) @@ -66,10 +66,10 @@ ($.paragraph (list (format _.license " does not grant any permission to use the " ($.or ..identifiers) " of any " _.contributor "; except as required for reasonable and customary use in describing the origin of " - _.work)))) + _.licensed_work)))) (def: #export secondary_licenses ($.paragraph (list (format "No " _.contributor " makes additional grants as a result of a choice by " _.recipient - " to distribute " _.work + " to distribute " _.licensed_work " under a under the terms of a " _.secondary_license)))) diff --git a/licentia/source/program/licentia/license/miscellaneous.lux b/licentia/source/program/licentia/license/miscellaneous.lux index 0fbc96982..3e4371fe1 100644 --- a/licentia/source/program/licentia/license/miscellaneous.lux +++ b/licentia/source/program/licentia/license/miscellaneous.lux @@ -77,9 +77,9 @@ "reexporting")) on_circumstances (let [limitation (format _.recipient " may be restricted with respect to " ($.or limited)) - target (format _.work " or any underlying information or technology")] + target (format _.licensed_work " or any underlying information or technology")] (format limitation " " target " by " limiter)) - on_acceptance_of_responsibility (let [trigger (format "By " ($.or limited) " " _.work) + on_acceptance_of_responsibility (let [trigger (format "By " ($.or limited) " " _.licensed_work) agreement (format _.recipient " is agreeing to be responsible for compliance with all " limiter)] (format trigger ", " agreement))] @@ -90,15 +90,15 @@ (let [on_publishing (let [when ", from time to time," what (format "revised versions of " _.license)] (format _.licensor " may publish" when " " what)) - on_published_version_validity (let [condition (format _.work " has been published under a particular version of " _.license) + on_published_version_validity (let [condition (format _.licensed_work " has been published under a particular version of " _.license) effect (format _.recipient " may always continue to use it under the terms of that version")] (format "Once " condition ", " effect)) on_license_upgrading (format _.recipient - " may also choose to use " _.work + " may also choose to use " _.licensed_work " under the terms of any subsequent version of " _.license " published by " _.licensor) on_licensor_privilege (format "No one other than " _.licensor - " has the right to modify the terms applicable to " _.work + " has the right to modify the terms applicable to " _.licensed_work " created under " _.license)] ($.paragraph (list on_publishing on_published_version_validity diff --git a/licentia/source/program/licentia/license/submission.lux b/licentia/source/program/licentia/license/submission.lux index 855141690..284deb88b 100644 --- a/licentia/source/program/licentia/license/submission.lux +++ b/licentia/source/program/licentia/license/submission.lux @@ -11,7 +11,7 @@ (def: #export contribution (let [on-submissions (let [exception (format "Unless " _.recipient " explicitly states otherwise") general-case (format "any intentional " _.submission " of a " _.contribution - " for inclusion in " _.work + " for inclusion in " _.licensed_work " by " _.recipient " to " _.licensor " shall be under the terms and conditions of " _.license) diff --git a/licentia/source/program/licentia/license/term.lux b/licentia/source/program/licentia/license/term.lux index c9db7fa5a..cd42b569f 100644 --- a/licentia/source/program/licentia/license/term.lux +++ b/licentia/source/program/licentia/license/term.lux @@ -15,7 +15,7 @@ [legal_entity //definition.legal_entity] [recipient //definition.recipient] [licensor //definition.licensor] - [work //definition.work] + [licensed_work //definition.licensed_work] [derivative_work //definition.derivative_work] [submission //definition.submission] [modification //definition.modification] diff --git a/licentia/source/test/licentia.lux b/licentia/source/test/licentia.lux index bf0f4929e..5ae86cfdb 100644 --- a/licentia/source/test/licentia.lux +++ b/licentia/source/test/licentia.lux @@ -5,7 +5,7 @@ [abstract [monad (#+ do)]] [control - [io (#+ io)]] + ["." io]] [data ["." bit ("#\." equivalence)] ["." maybe ("#\." functor)] @@ -16,33 +16,32 @@ ["." random (#+ Random)] [number ["n" nat ("#\." interval)]]]] - {#program - [/ - ["." license (#+ Identification - Termination - Liability - Distribution - Commercial - Extension - Entity Black_List - URL Attribution - Addendum - License) - ["." time (#+ Period)] - ["." copyright] - ["." notice] - ["." definition] - ["." grant] - ["." limitation] - ["." submission] - ["." liability] - ["." distribution] - ["." commercial] - ["." extension] - ["." miscellaneous] - ["." black_list] - ["." addendum]] - ["." output]]}) + [\\program + ["." license (#+ Identification + Termination + Liability + Distribution + Commercial + Extension + Entity Black_List + URL Attribution + Addendum + License) + ["." time (#+ Period)] + ["." copyright] + ["." notice] + ["." definition] + ["." grant] + ["." limitation] + ["." submission] + ["." liability] + ["." distribution] + ["." commercial] + ["." extension] + ["." miscellaneous] + ["." black_list] + ["." addendum]] + ["." output]]) (def: period (Random (Period Nat)) @@ -364,5 +363,7 @@ ))) (program: args - (io (_.run! (<| (_.times 100) - ..test)))) + (<| io.io + _.run! + (_.times 100) + ..test)) diff --git a/stdlib/source/lux/ffi.jvm.lux b/stdlib/source/lux/ffi.jvm.lux index b9f1a3b7e..8e58c5e50 100644 --- a/stdlib/source/lux/ffi.jvm.lux +++ b/stdlib/source/lux/ffi.jvm.lux @@ -54,7 +54,9 @@ (|>> type.reflection reflection.reflection)) (template [<name> <class>] - [(def: #export <name> .Type (#.Primitive <class> #.Nil))] + [(def: #export <name> + .Type + (#.Primitive <class> #.Nil))] [Boolean box.boolean] [Byte box.byte] @@ -67,7 +69,9 @@ ) (template [<name> <class>] - [(def: #export <name> .Type (#.Primitive (reflection.reflection <class>) #.Nil))] + [(def: #export <name> + .Type + (#.Primitive (reflection.reflection <class>) #.Nil))] ## Primitives [boolean reflection.boolean] @@ -161,7 +165,22 @@ [char_to_long "jvm conversion char-to-long" ..Character ..Long] ) -(def: constructor_method_name "<init>") +(template [<name> <from> <to> <0> <1>] + [(template: #export (<name> value) + {#.doc (doc "Type converter." + (: <to> + (<name> (: <from> foo))))} + (|> value <0> <1>))] + + [long_to_char ..Long ..Character ..long_to_int ..int_to_char] + [byte_to_int ..Byte ..Integer ..byte_to_long ..long_to_int] + [short_to_int ..Short ..Integer ..short_to_long ..long_to_int] + [byte_to_char ..Byte ..Character ..byte_to_int ..int_to_char] + [short_to_char ..Short ..Character ..short_to_int ..int_to_char] + ) + +(def: constructor_method_name + "<init>") (type: Primitive_Mode #ManualPrM @@ -526,21 +545,16 @@ (<>.assert (exception.construct exception payload) test)) -(def: (assert_valid_class_name type_vars name) - (-> (List (Type Var)) External (Parser Any)) - (do <>.monad - [_ (..assert ..class_names_cannot_contain_periods [name] - (not (text.contains? name.external_separator name)))] - (..assert ..class_name_cannot_be_a_type_variable [name type_vars] - (not (list.member? text.equivalence - (list\map parser.name type_vars) - name))))) - (def: (valid_class_name type_vars) (-> (List (Type Var)) (Parser External)) (do <>.monad [name <code>.local_identifier - _ (assert_valid_class_name type_vars name)] + _ (..assert ..class_names_cannot_contain_periods [name] + (not (text.contains? name.external_separator name))) + _ (..assert ..class_name_cannot_be_a_type_variable [name type_vars] + (not (list.member? text.equivalence + (list\map parser.name type_vars) + name)))] (wrap name))) (def: (class^' parameter^ type_vars) @@ -659,9 +673,9 @@ (Parser (Type Declaration)) (do <>.monad [[name variables] (: (Parser [External (List (Type Var))]) - (<>.either (<>.and (valid_class_name (list)) + (<>.either (<>.and (..valid_class_name (list)) (<>\wrap (list))) - (<code>.form (<>.and (valid_class_name (list)) + (<code>.form (<>.and (..valid_class_name (list)) (<>.some var^))) ))] (wrap (type.declaration name variables)))) @@ -1448,7 +1462,8 @@ [decorate_return_io #import_member_io? (` ((~! io.io) (~ return_term)))] ) -(def: $String (type.class "java.lang.String" (list))) +(def: $String + (type.class "java.lang.String" (list))) (template [<input?> <name> <unbox/box> <special+>] [(def: (<name> mode [unboxed raw]) @@ -1806,7 +1821,7 @@ (with_expansions [<failure> (as_is (meta.fail (exception.construct ..cannot_convert_to_jvm_type [type])))] (def: (lux_type->jvm_type type) (-> .Type (Meta (Type Value))) - (if (lux_type\= Any type) + (if (lux_type\= .Any type) (\ meta.monad wrap $Object) (case type (#.Primitive name params) @@ -2013,7 +2028,7 @@ (wrap (list (` ("jvm object class" (~ (code.text (..reflection type)))))))) (syntax: #export (type {type (..type^ (list))}) - (wrap (list (value_type #ManualPrM type)))) + (wrap (list (..value_type #ManualPrM type)))) (exception: #export (cannot_cast_to_non_object {type (Type Value)}) (exception.report diff --git a/stdlib/source/lux/time/date.lux b/stdlib/source/lux/time/date.lux index 2b7d657d0..b8b483cca 100644 --- a/stdlib/source/lux/time/date.lux +++ b/stdlib/source/lux/time/date.lux @@ -34,7 +34,8 @@ (dictionary.new n.hash) //month.year)) -(def: minimum_day 1) +(def: minimum_day + 1) (def: (month_days year month) (-> Year Month Nat) diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux index 66ef65e71..0d67b2224 100644 --- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -951,8 +951,7 @@ (recur [next_name nextT]) #.Nil - (/////analysis.throw ..cannot_cast [fromT toT fromC])) - )))))))] + (wrap false)))))))))] (if can_cast? (wrap (#/////analysis.Extension extension_name (list (/////analysis.text from_name) (/////analysis.text to_name) diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux index f5ec4caf2..4cfc376d3 100644 --- a/stdlib/source/program/aedifex.lux +++ b/stdlib/source/program/aedifex.lux @@ -31,7 +31,7 @@ [lux ["." syntax]]]]] [world - ["." shell (#+ Shell)] + ["." shell (#+ Exit Shell)] ["." console (#+ Console)] ["." program (#+ Program)] ["." file (#+ Path) @@ -72,7 +72,7 @@ (def: (with_dependencies program console command profile) (All [a] (-> (Program Promise) (Console Promise) - (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command a)) + (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Exit a])) (Command a))) (do /action.monad [resolution (/command/deps.do! console @@ -80,8 +80,17 @@ (..repositories profile) (|>> (/repository/remote.repository http.default #.None) /repository.async) - profile)] - ((command console program (file.async file.default) (shell.async shell.default) resolution) profile))) + profile) + [exit_code output] ((command console program (file.async file.default) (shell.async shell.default) resolution) profile) + _ (case exit_code + (^ (static shell.normal)) + (wrap []) + + _ + (do promise.monad + [_ (\ program exit exit_code)] + (wrap (#try.Failure ""))))] + (wrap output))) (exception: (cannot_find_repository {repository Text} {options (Dictionary Text Address)}) diff --git a/stdlib/source/program/aedifex/command/auto.lux b/stdlib/source/program/aedifex/command/auto.lux index 398fb26cf..ee2ab4bbd 100644 --- a/stdlib/source/program/aedifex/command/auto.lux +++ b/stdlib/source/program/aedifex/command/auto.lux @@ -12,7 +12,7 @@ ["." set]]] [world [program (#+ Program)] - [shell (#+ Shell)] + [shell (#+ Exit Shell)] [console (#+ Console)] ["." file ["." watch (#+ Watcher)]]]] @@ -45,8 +45,8 @@ (def: #export (do! delay watcher command) (All [a] (-> Nat (Watcher Promise) - (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command a)) - (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command Any)))) + (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Exit a])) + (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Exit Any])))) (function (_ console program fs shell resolution) (function (_ profile) (with_expansions [<call> ((command console program fs shell resolution) profile)] diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux index 2f603dbc1..34351f636 100644 --- a/stdlib/source/program/aedifex/command/build.lux +++ b/stdlib/source/program/aedifex/command/build.lux @@ -23,7 +23,7 @@ [world ["." program (#+ Program)] ["." file (#+ Path)] - ["." shell (#+ Process Shell)] + ["." shell (#+ Exit Process Shell)] ["." console (#+ Console)] [net ["." uri]]]] @@ -169,7 +169,7 @@ ) (def: #export (do! console program fs shell resolution) - (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Compiler Path])) + (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Exit Compiler Path])) (function (_ profile) (let [target (get@ #///.target profile)] (case (get@ #///.program profile) @@ -186,13 +186,14 @@ #let [[[command compiler_params] output] (case compiler (^template [<tag> <runtime> <program>] [(<tag> dependency) - [(<runtime> (..path fs home dependency)) + [(///runtime.for (get@ <runtime> profile) + (..path fs home dependency)) <program>]]) - ([#JVM ///runtime.java "program.jar"] - [#JS ///runtime.node "program.js"] - [#Python ///runtime.java "program.py"] - [#Lua ///runtime.java "program.lua"] - [#Ruby ///runtime.java "program.rb"])) + ([#JVM #///.java "program.jar"] + [#JS #///.js "program.js"] + [#Python #///.java "program.py"] + [#Lua #///.java "program.lua"] + [#Ruby #///.java "program.rb"])) / (\ fs separator) cache_directory (format working_directory / target)] _ (console.write_line ..start console) @@ -212,5 +213,6 @@ ..success ..failure) console)] - (wrap [compiler + (wrap [exit + compiler (format cache_directory / output)]))))))) diff --git a/stdlib/source/program/aedifex/command/test.lux b/stdlib/source/program/aedifex/command/test.lux index 0ccc0cfb2..55614ba80 100644 --- a/stdlib/source/program/aedifex/command/test.lux +++ b/stdlib/source/program/aedifex/command/test.lux @@ -14,7 +14,7 @@ [world ["." program (#+ Program)] ["." file] - ["." shell (#+ Shell)] + ["." shell (#+ Exit Shell)] ["." console (#+ Console)]]] ["." // #_ ["#." build] @@ -31,32 +31,35 @@ (def: #export failure "[TEST FAILED]") (def: #export (do! console program fs shell resolution profile) - (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command Any)) + (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Exit Any])) (do promise.monad [environment (program.environment promise.monad program) #let [working_directory (\ program directory)]] - (do ///action.monad - [[compiler program] (//build.do! console program fs shell resolution - (set@ #///.program (get@ #///.test profile) profile)) - _ (console.write_line ..start console) - #let [[compiler_command compiler_parameters] (case compiler - (^template [<tag> <runtime>] - [(<tag> artifact) - (<runtime> program)]) - ([#//build.JVM ///runtime.java] - [#//build.JS ///runtime.node] - [#//build.Python ///runtime.python] - [#//build.Lua ///runtime.lua] - [#//build.Ruby ///runtime.ruby]))] - process (\ shell execute [environment - working_directory - compiler_command - compiler_parameters]) - _ (//build.log_output! console process) - _ (//build.log_error! console process) - exit (\ process await []) - _ (console.write_line (if (i.= shell.normal exit) - ..success - ..failure) - console)] - (wrap [])))) + (do {! ///action.monad} + [[build_exit compiler program] (//build.do! console program fs shell resolution + (set@ #///.program (get@ #///.test profile) profile))] + (if (i.= shell.normal build_exit) + (do ! + [_ (console.write_line ..start console) + #let [[compiler_command compiler_parameters] (case compiler + (^template [<tag> <runtime>] + [(<tag> artifact) + (///runtime.for (get@ <runtime> profile) program)]) + ([#//build.JVM #///.java] + [#//build.JS #///.js] + [#//build.Python #///.python] + [#//build.Lua #///.lua] + [#//build.Ruby #///.ruby]))] + process (\ shell execute [environment + working_directory + compiler_command + compiler_parameters]) + _ (//build.log_output! console process) + _ (//build.log_error! console process) + exit (\ process await []) + _ (console.write_line (if (i.= shell.normal exit) + ..success + ..failure) + console)] + (wrap [exit []])) + (wrap [build_exit []]))))) diff --git a/stdlib/source/program/aedifex/format.lux b/stdlib/source/program/aedifex/format.lux index 9b44eced5..c7fc93b5a 100644 --- a/stdlib/source/program/aedifex/format.lux +++ b/stdlib/source/program/aedifex/format.lux @@ -7,9 +7,11 @@ ["." list ("#\." functor)] ["." set (#+ Set)]]] [macro - ["." code]]] + ["." code] + ["." template]]] ["." // #_ ["/" profile] + ["#." runtime (#+ Runtime)] ["#." project (#+ Project)] ["#." dependency (#+ Dependency)] ["#." artifact (#+ Artifact) @@ -131,21 +133,34 @@ (` [(~+ (..artifact' artifact)) (~ (code.text type))]))) +(def: (runtime [program parameters]) + (Format Runtime) + (` [(~ (code.text program)) + (~+ (list\map code.text parameters))])) + (def: #export (profile value) (Format /.Profile) - (|> ..empty - (..on_list "parents" (get@ #/.parents value) code.text) - (..on_maybe "identity" (get@ #/.identity value) ..artifact) - (..on_maybe "info" (get@ #/.info value) ..info) - (..on_set "repositories" (get@ #/.repositories value) code.text) - (..on_set "dependencies" (get@ #/.dependencies value) ..dependency) - (dictionary.put "compiler" (..dependency (get@ #/.compiler value))) - (..on_set "sources" (get@ #/.sources value) code.text) - (dictionary.put "target" (code.text (get@ #/.target value))) - (..on_maybe "program" (get@ #/.program value) code.text) - (..on_maybe "test" (get@ #/.test value) code.text) - (..on_dictionary "deploy_repositories" (get@ #/.deploy_repositories value) code.text code.text) - ..aggregate)) + (`` (|> ..empty + (..on_list "parents" (get@ #/.parents value) code.text) + (..on_maybe "identity" (get@ #/.identity value) ..artifact) + (..on_maybe "info" (get@ #/.info value) ..info) + (..on_set "repositories" (get@ #/.repositories value) code.text) + (..on_set "dependencies" (get@ #/.dependencies value) ..dependency) + (dictionary.put "compiler" (..dependency (get@ #/.compiler value))) + (..on_set "sources" (get@ #/.sources value) code.text) + (dictionary.put "target" (code.text (get@ #/.target value))) + (..on_maybe "program" (get@ #/.program value) code.text) + (..on_maybe "test" (get@ #/.test value) code.text) + (..on_dictionary "deploy_repositories" (get@ #/.deploy_repositories value) code.text code.text) + (~~ (template [<tag>] + [(dictionary.put (template.text [<tag>]) (..runtime (get@ <tag> value)))] + + [#/.java] + [#/.js] + [#/.python] + [#/.lua] + [#/.ruby])) + ..aggregate))) (def: #export project (Format Project) diff --git a/stdlib/source/program/aedifex/parser.lux b/stdlib/source/program/aedifex/parser.lux index 8d0fcdf73..6374f8807 100644 --- a/stdlib/source/program/aedifex/parser.lux +++ b/stdlib/source/program/aedifex/parser.lux @@ -19,6 +19,7 @@ [net (#+ URL)]]] ["." // #_ ["/" profile] + ["#." runtime (#+ Runtime)] ["#." project (#+ Project)] ["#." dependency] ["#." repository #_ @@ -171,6 +172,11 @@ (<>.and <code>.text ..repository)))) +(def: runtime + (Parser Runtime) + (<code>.tuple (<>.and <code>.text + (<>.some <code>.text)))) + (def: profile (Parser /.Profile) (do {! <>.monad} @@ -216,7 +222,22 @@ ^deploy_repositories (: (Parser (Dictionary Text //repository.Address)) (<| (\ ! map (dictionary.from_list text.hash)) (<>.default (list)) - (..singular input "deploy_repositories" ..deploy_repository)))]] + (..singular input "deploy_repositories" ..deploy_repository))) + ^java (|> ..runtime + (..singular input "java") + (<>.default //runtime.default_java)) + ^js (|> ..runtime + (..singular input "js") + (<>.default //runtime.default_js)) + ^python (|> ..runtime + (..singular input "python") + (<>.default //runtime.default_python)) + ^lua (|> ..runtime + (..singular input "lua") + (<>.default //runtime.default_lua)) + ^ruby (|> ..runtime + (..singular input "ruby") + (<>.default //runtime.default_ruby))]] ($_ <>.and ^parents ^identity @@ -229,6 +250,11 @@ ^program ^test ^deploy_repositories + ^java + ^js + ^python + ^lua + ^ruby ))) (def: #export project diff --git a/stdlib/source/program/aedifex/profile.lux b/stdlib/source/program/aedifex/profile.lux index d31d0aca9..9fe05b10b 100644 --- a/stdlib/source/program/aedifex/profile.lux +++ b/stdlib/source/program/aedifex/profile.lux @@ -13,6 +13,8 @@ ["." dictionary (#+ Dictionary)] ["." list ("#\." monoid)] ["." set (#+ Set)]]] + [macro + ["." template]] [world [net (#+ URL)] [file (#+ Path)]] @@ -22,6 +24,7 @@ [archive [descriptor (#+ Module)]]]]]] [// + ["." runtime (#+ Runtime) ("#\." equivalence)] ["." dependency (#+ Dependency) ("#\." equivalence)] ["." artifact (#+ Artifact) ["." type]] @@ -160,7 +163,12 @@ #target Target #program (Maybe Module) #test (Maybe Module) - #deploy_repositories (Dictionary Text Address)}) + #deploy_repositories (Dictionary Text Address) + #java Runtime + #js Runtime + #python Runtime + #lua Runtime + #ruby Runtime}) (def: #export equivalence (Equivalence Profile) @@ -186,7 +194,17 @@ ## #test (maybe.equivalence text.equivalence) ## #deploy_repositories - (dictionary.equivalence text.equivalence))) + (dictionary.equivalence text.equivalence) + ## #java + runtime.equivalence + ## #js + runtime.equivalence + ## #python + runtime.equivalence + ## #lua + runtime.equivalence + ## #ruby + runtime.equivalence)) (implementation: #export monoid (Monoid Profile) @@ -202,23 +220,37 @@ #target ..default_target #program #.None #test #.None - #deploy_repositories (dictionary.new text.hash)}) + #deploy_repositories (dictionary.new text.hash) + #java runtime.default_java + #js runtime.default_js + #python runtime.default_python + #lua runtime.default_lua + #ruby runtime.default_ruby}) (def: (compose override baseline) - {#parents (list\compose (get@ #parents baseline) (get@ #parents override)) - #identity (maybe\compose (get@ #identity override) (get@ #identity baseline)) - #info (maybe\compose (get@ #info override) (get@ #info baseline)) - #repositories (set.union (get@ #repositories baseline) (get@ #repositories override)) - #dependencies (set.union (get@ #dependencies baseline) (get@ #dependencies override)) - #compiler (if (dependency\= ..default_compiler (get@ #compiler override)) - (get@ #compiler baseline) - (get@ #compiler override)) - #sources (set.union (get@ #sources baseline) (get@ #sources override)) - #target (if (text\= ..default_target (get@ #target baseline)) - (get@ #target override) - (get@ #target baseline)) - #program (maybe\compose (get@ #program override) (get@ #program baseline)) - #test (maybe\compose (get@ #test override) (get@ #test baseline)) - #deploy_repositories (dictionary.merge (get@ #deploy_repositories override) (get@ #deploy_repositories baseline))})) + (template.let [(!runtime <tag> <runtime>) + [(if (runtime\= <runtime> (get@ <tag> override)) + (get@ <tag> baseline) + (get@ <tag> override))]] + {#parents (list\compose (get@ #parents baseline) (get@ #parents override)) + #identity (maybe\compose (get@ #identity override) (get@ #identity baseline)) + #info (maybe\compose (get@ #info override) (get@ #info baseline)) + #repositories (set.union (get@ #repositories baseline) (get@ #repositories override)) + #dependencies (set.union (get@ #dependencies baseline) (get@ #dependencies override)) + #compiler (if (dependency\= ..default_compiler (get@ #compiler override)) + (get@ #compiler baseline) + (get@ #compiler override)) + #sources (set.union (get@ #sources baseline) (get@ #sources override)) + #target (if (text\= ..default_target (get@ #target baseline)) + (get@ #target override) + (get@ #target baseline)) + #program (maybe\compose (get@ #program override) (get@ #program baseline)) + #test (maybe\compose (get@ #test override) (get@ #test baseline)) + #deploy_repositories (dictionary.merge (get@ #deploy_repositories override) (get@ #deploy_repositories baseline)) + #java (!runtime #java runtime.default_java) + #js (!runtime #js runtime.default_js) + #python (!runtime #python runtime.default_python) + #lua (!runtime #lua runtime.default_lua) + #ruby (!runtime #ruby runtime.default_ruby)}))) (exception: #export no_identity) diff --git a/stdlib/source/program/aedifex/runtime.lux b/stdlib/source/program/aedifex/runtime.lux index e3f5a4e92..571a9fc43 100644 --- a/stdlib/source/program/aedifex/runtime.lux +++ b/stdlib/source/program/aedifex/runtime.lux @@ -1,22 +1,44 @@ (.module: - [lux #* + [lux (#- for) + [abstract + [equivalence (#+ Equivalence)]] [data - [text - ["%" format (#+ format)]]] + ["." product] + ["." text + ["%" format (#+ format)]] + [collection + ["." list ("#\." monoid)]]] [macro ["." template]] [world - [file (#+ Path)] - [shell (#+ Command)]]]) + ["." file]]]) + +(type: #export Runtime + {#program Text + #parameters (List Text)}) + +(def: #export equivalence + (Equivalence Runtime) + (product.equivalence + text.equivalence + (list.equivalence text.equivalence))) (template [<name> <command> <parameters>] - [(def: #export (<name> path) - (-> Path [Text (List Text)]) - (`` (format [<command> (list (~~ (template.splice <parameters>)) path)])))] + [(def: #export <name> + Runtime + {#program <command> + #parameters (`` (list (~~ (template.splice <parameters>))))})] - [java "java" ["-jar"]] - [node "node" ["--stack_size=8192"]] - [python "python3" []] - [lua "lua" []] - [ruby "RUBY_THREAD_VM_STACK_SIZE=15700000 ruby" []] + [default_java "java" ["-jar"]] + [default_js "node" ["--stack_size=8192"]] + [default_python "python3" []] + [default_lua "lua" []] + [default_ruby "RUBY_THREAD_VM_STACK_SIZE=15700000 ruby" []] ) + +(def: #export (for runtime path) + (-> Runtime file.Path Runtime) + (update@ #parameters + (function (_ parameters) + (list\compose parameters (list path))) + runtime)) diff --git a/stdlib/source/test/aedifex/command/auto.lux b/stdlib/source/test/aedifex/command/auto.lux index dfb4dc672..193a5b8d8 100644 --- a/stdlib/source/test/aedifex/command/auto.lux +++ b/stdlib/source/test/aedifex/command/auto.lux @@ -27,7 +27,7 @@ ["." instant]] [world [console (#+ Console)] - ["." shell (#+ Shell)] + ["." shell (#+ Exit Shell)] ["." program (#+ Program)] ["." file ["." watch]]]] @@ -46,7 +46,7 @@ (def: (command expected_runs end_signal fs dummy_file) (-> Nat Text (file.System Promise) file.Path [(Atom Nat) - (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command Any))]) + (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Exit Any]))]) (let [@runs (: (Atom Nat) (atom.atom 0))] [@runs @@ -56,10 +56,11 @@ (if (n.= expected_runs actual_runs) (wrap (#try.Failure end_signal)) (do (try.with !) - [_ (\ fs write (\ utf8.codec encode (%.nat actual_runs)) dummy_file)] - (\ fs modify - (|> actual_runs .int instant.from_millis) - dummy_file)))))])) + [_ (\ fs write (\ utf8.codec encode (%.nat actual_runs)) dummy_file) + _ (\ fs modify + (|> actual_runs .int instant.from_millis) + dummy_file)] + (wrap [shell.normal []])))))])) (def: #export test Test diff --git a/stdlib/source/test/aedifex/profile.lux b/stdlib/source/test/aedifex/profile.lux index d4cbb958a..e7e3f50ac 100644 --- a/stdlib/source/test/aedifex/profile.lux +++ b/stdlib/source/test/aedifex/profile.lux @@ -27,6 +27,7 @@ [\\program ["." / ["/#" // #_ + ["#." runtime] ["#." dependency (#+ Dependency)] ["#." format] [repository @@ -129,6 +130,11 @@ (random.maybe (random.ascii/alpha 1)) (random.maybe (random.ascii/alpha 1)) (..dictionary_of text.hash (random.ascii/alpha 1) ..repository) + (random\wrap //runtime.default_java) + (random\wrap //runtime.default_js) + (random\wrap //runtime.default_python) + (random\wrap //runtime.default_lua) + (random\wrap //runtime.default_ruby) )) (def: #export test diff --git a/stdlib/source/test/aedifex/runtime.lux b/stdlib/source/test/aedifex/runtime.lux index 968e753f8..e75a9297e 100644 --- a/stdlib/source/test/aedifex/runtime.lux +++ b/stdlib/source/test/aedifex/runtime.lux @@ -4,26 +4,57 @@ [abstract [monad (#+ do)]] [data - ["." text]] + ["." maybe ("#\." functor)] + ["." text ("#\." equivalence)] + [collection + ["." list ("#\." functor)] + ["." set]]] [math - ["." random]]] + ["." random (#+ Random) ("#\." monad)] + [number + ["n" nat]]]] [\\program ["." /]]) +(def: #export random + (Random /.Runtime) + ($_ random.either + (random\wrap /.default_java) + (random\wrap /.default_js) + (random\wrap /.default_python) + (random\wrap /.default_lua) + (random\wrap /.default_ruby) + )) + (def: #export test Test (<| (_.covering /._) + (_.for [/.Runtime]) (do random.monad - [path (random.ascii/alpha 5)] + [path (random.ascii/alpha 5) + runtime ..random] (`` ($_ _.and (~~ (template [<command>] - [(_.cover [<command>] - (let [command (text.join_with " " (#.Cons (<command> path))) - pure_command (text.join_with " " (#.Cons (<command> "")))] - (and (text.starts_with? pure_command command) - (text.ends_with? path command))))] + [(_.cover [/.default_java /.default_js /.default_python /.default_lua /.default_ruby] + (let [listing (|> (list /.default_java /.default_js /.default_python /.default_lua /.default_ruby) + (list\map (get@ #/.program))) + unique (set.from_list text.hash listing)] + (n.= (list.size listing) + (set.size unique))))] - [/.java] - [/.node] + [/.default_java] + [/.default_js] + [/.default_python] + [/.default_lua] + [/.default_ruby] )) + (_.cover [/.for] + (let [runtime' (/.for runtime path)] + (and (text\= (get@ #/.program runtime) + (get@ #/.program runtime')) + (|> runtime' + (get@ #/.parameters) + list.last + (maybe\map (text\= path)) + (maybe.default false))))) ))))) diff --git a/stdlib/source/test/lux/data/text/format.lux b/stdlib/source/test/lux/data/text/format.lux index db1615631..54176cda3 100644 --- a/stdlib/source/test/lux/data/text/format.lux +++ b/stdlib/source/test/lux/data/text/format.lux @@ -19,6 +19,8 @@ [collection ["." list ("#\." functor)]]] ["." time + ["." day] + ["." month] ["." instant] ["." duration] ["." date]] @@ -102,6 +104,8 @@ [/.name name.codec ($///name.random 5 5)] [/.xml xml.codec $///xml.random] [/.json json.codec $///json.random] + [/.day day.codec random.day] + [/.month month.codec random.month] [/.instant instant.codec random.instant] [/.duration duration.codec random.duration] [/.date date.codec random.date] @@ -152,6 +156,16 @@ (text.join_with " ") list (/.list (|>>)))))) + (do random.monad + [sample (random.maybe random.nat)] + (_.cover [/.maybe] + (case sample + #.None + true + + (#.Some value) + (text.contains? (/.nat value) + (/.maybe /.nat sample))))) (do {! random.monad} [modulus (random.one (|>> modulus.modulus try.to_maybe) diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux index 86e43a9f3..7baa32fa2 100644 --- a/stdlib/source/test/lux/ffi.jvm.lux +++ b/stdlib/source/test/lux/ffi.jvm.lux @@ -1,16 +1,28 @@ (.module: [lux #* - [abstract/monad (#+ Monad do)] + ["_" test (#+ Test)] + ["." type ("#\." equivalence)] + ["." meta] + [abstract + [monad (#+ do)]] [control - pipe] + [pipe (#+ case>)] + ["." try] + ["." exception]] [data - ["." text ("#\." equivalence)]] + ["." bit ("#\." equivalence)] + ["." text ("#\." equivalence)] + [collection + ["." array (#+ Array)]]] + ["." macro + [syntax (#+ syntax:)] + ["." code]] [math - ["r" random] + ["." random] [number ["n" nat] - ["i" int]]] - ["_" test (#+ Test)]] + ["i" int ("#\." equivalence)] + ["f" frac ("#\." equivalence)]]]] [\\ ["." /]]) @@ -74,78 +86,184 @@ ## (/.interface: TestInterface ## ([] foo [boolean java/lang/String] void #throws [java/lang/Exception])) +(template [<name> <type> <conversion> <lux> <=>] + [(def: (<name> left right) + (-> <type> <type> Bit) + (<=> (:as <lux> (<conversion> left)) + (:as <lux> (<conversion> right))))] + + [boolean\= /.Boolean <| Bit bit\=] + [byte\= /.Byte /.byte_to_long Int i\=] + [short\= /.Short /.short_to_long Int i\=] + [integer\= /.Integer /.int_to_long Int i\=] + [long\= /.Long <| Int i\=] + [float\= /.Float /.float_to_double Frac f\=] + [double\= /.Double <| Frac f\=] + [character\= /.Character /.char_to_long Int i\=] + ) + +(syntax: (macro_error expression) + (function (_ lux) + (|> (macro.expand_once expression) + (meta.run lux) + (case> (#try.Success expansion) + (#try.Failure "OOPS!") + + (#try.Failure error) + (#try.Success [lux (list (code.text error))]))))) + (def: conversions Test - (do r.monad - [sample r.int] + (do {! random.monad} + [long (\ ! map (|>> (:as /.Long)) random.int) + integer (\ ! map (|>> (:as /.Long) /.long_to_int) random.int) + byte (\ ! map (|>> (:as /.Long) /.long_to_byte) random.int) + short (\ ! map (|>> (:as /.Long) /.long_to_short) random.int) + float (\ ! map (|>> (:as /.Double) /.double_to_float) random.frac)] (`` ($_ _.and - (~~ (template [<to> <from> <message>] - [(_.test <message> - (or (|> sample (:as java/lang/Long) <to> <from> (:as Int) (i.= sample)) - (let [capped_sample (|> sample (:as java/lang/Long) <to> <from>)] - (|> capped_sample <to> <from> (:as Int) (i.= (:as Int capped_sample))))))] - - [/.long_to_byte /.byte_to_long "Can succesfully convert to/from byte."] - [/.long_to_short /.short_to_long "Can succesfully convert to/from short."] - [/.long_to_int /.int_to_long "Can succesfully convert to/from int."] - [/.long_to_float /.float_to_long "Can succesfully convert to/from float."] - [/.long_to_double /.double_to_long "Can succesfully convert to/from double."] - [(<| /.int_to_char /.long_to_int) (<| /.int_to_long /.char_to_int) "Can succesfully convert to/from char."] - )) - )))) + (~~ (template [<sample> <=> <to> <from>] + [(_.cover [<to> <from>] + (or (|> <sample> <to> <from> (<=> <sample>)) + (let [capped (|> <sample> <to> <from>)] + (|> capped <to> <from> (<=> capped)))))] -(def: miscellaneous - Test - (do {! r.monad} - [sample (\ ! map (|>> (:as java/lang/Object)) - (r.ascii 1))] - ($_ _.and - (_.test "Can check if an object is of a certain class." - (and (case (/.check java/lang/String sample) (#.Some _) true #.None false) - (case (/.check java/lang/Long sample) (#.Some _) false #.None true) - (case (/.check java/lang/Object sample) (#.Some _) true #.None false) - (case (/.check java/lang/Object (/.null)) (#.Some _) false #.None true))) - - (_.test "Can run code in a 'synchronized' block." - (/.synchronized sample #1)) - - (_.test "Can access Class instances." - (text\= "java.lang.Class" (java/lang/Class::getName (/.class_for java/lang/Class)))) - - (_.test "Can check if a value is null." - (and (/.null? (/.null)) - (not (/.null? sample)))) - - (_.test "Can safely convert nullable references into Maybe values." - (and (|> (: (Maybe java/lang/Object) (/.??? (/.null))) - (case> #.None #1 - _ #0)) - (|> (: (Maybe java/lang/Object) (/.??? sample)) - (case> (#.Some _) #1 - _ #0)))) - ))) + [long long\= /.long_to_byte /.byte_to_long] + [long long\= /.long_to_short /.short_to_long] + [long long\= /.long_to_int /.int_to_long] + [long long\= /.long_to_float /.float_to_long] + [long long\= /.long_to_double /.double_to_long] + [long long\= /.long_to_char /.char_to_long] + + [integer integer\= /.int_to_double /.double_to_int] + [integer integer\= /.int_to_float /.float_to_int] + [integer integer\= /.int_to_char /.char_to_int] + + [byte byte\= /.byte_to_int /.int_to_byte] + [short short\= /.short_to_int /.int_to_short] + [byte byte\= /.byte_to_char /.char_to_byte] + [short short\= /.short_to_char /.char_to_short] + [float float\= /.float_to_double /.double_to_float] + )))))) (def: arrays Test - (do {! r.monad} - [size (|> r.nat (\ ! map (|>> (n.% 100) (n.max 1)))) - idx (|> r.nat (\ ! map (n.% size))) - value (\ ! map (|>> (:as java/lang/Long)) r.int)] + (do {! random.monad} + [size (|> random.nat (\ ! map (|>> (n.% 100) (n.max 1)))) + idx (|> random.nat (\ ! map (n.% size))) + value (\ ! map (|>> (:as java/lang/Long)) random.int)] ($_ _.and - (_.test "Can create arrays of some length." - (n.= size (/.array_length (/.array java/lang/Long size)))) + (_.cover [/.array /.array_length] + (|> size + (/.array java/lang/Long) + /.array_length + (n.= size))) + (_.cover [/.array_write /.array_read] + (|> (/.array java/lang/Long size) + (/.array_write idx value) + (/.array_read idx) + (:as Int) + (i.= (:as Int value)))) + (_.cover [/.cannot_convert_to_jvm_type] + (let [array (:as (Array Nothing) + (array.new 1))] + (|> array + /.array_length + ..macro_error + (text.contains? (get@ #exception.label /.cannot_convert_to_jvm_type)))))))) - (_.test "Can set and get array values." - (let [arr (/.array java/lang/Long size)] - (exec (/.array_write idx value arr) - (i.= (:as Int value) - (:as Int (/.array_read idx arr))))))))) +(def: miscellaneous + Test + (`` (do {! random.monad} + [sample (\ ! map (|>> (:as java/lang/Object)) + (random.ascii 1)) + boolean (\ ! map (|>> (:as /.Boolean)) random.bit) + byte (\ ! map (|>> (:as /.Long) /.long_to_byte) random.int) + short (\ ! map (|>> (:as /.Long) /.long_to_short) random.int) + integer (\ ! map (|>> (:as /.Long) /.long_to_int) random.int) + long (\ ! map (|>> (:as /.Long)) random.int) + float (\ ! map (|>> (:as /.Double) /.double_to_float) random.frac) + double (\ ! map (|>> (:as /.Double)) random.frac) + character (\ ! map (|>> (:as /.Long) /.long_to_int /.int_to_char) random.int) + string (\ ! map (|>> (:as java/lang/String)) + (random.ascii 1))] + ($_ _.and + (_.cover [/.check] + (and (case (/.check java/lang/String sample) (#.Some _) true #.None false) + (case (/.check java/lang/Long sample) (#.Some _) false #.None true) + (case (/.check java/lang/Object sample) (#.Some _) true #.None false) + (case (/.check java/lang/Object (/.null)) (#.Some _) false #.None true))) + (_.cover [/.synchronized] + (/.synchronized sample #1)) + (_.cover [/.class_for] + (text\= "java.lang.Class" (java/lang/Class::getName (/.class_for java/lang/Class)))) + (_.cover [/.null /.null?] + (and (/.null? (/.null)) + (not (/.null? sample)))) + (_.cover [/.???] + (and (|> (/.??? (/.null)) + (: (Maybe java/lang/Object)) + (case> #.None #1 + (#.Some _) #0)) + (|> (/.??? sample) + (: (Maybe java/lang/Object)) + (case> (#.Some _) #1 + #.None #0)))) + (_.cover [/.!!!] + (and (|> (/.??? (/.null)) + /.!!! + /.null?) + (|> (/.??? sample) + /.!!! + /.null? + not))) + (~~ (template [<object> <primitive> <value> <=>] + [(|> <value> + (: <object>) + "jvm object cast" + (: <primitive>) + "jvm object cast" + (: <object>) + (<=> <value>) + (_.cover [<object> <primitive>]))] + + [/.Boolean /.boolean boolean boolean\=] + [/.Byte /.byte byte byte\=] + [/.Short /.short short short\=] + [/.Integer /.int integer integer\=] + [/.Long /.long long long\=] + [/.Float /.float float float\=] + [/.Double /.double double double\=] + [/.Character /.char character character\=] + )) + (_.cover [/.cannot_cast_to_non_object] + (text.contains? (get@ #exception.label /.cannot_cast_to_non_object) + (macro_error (/.:cast boolean (: /.Boolean boolean))))) + (_.cover [/.:cast] + (|> string + (/.:cast java/lang/Object) + (is? (:as java/lang/Object string)))) + (_.cover [/.type] + (and (and (type\= /.Boolean (/.type java/lang/Boolean)) + (type\= /.Boolean (/.type boolean))) + (and (type\= /.Byte (/.type java/lang/Byte)) + (type\= /.Byte (/.type byte))) + (and (type\= /.Short (/.type java/lang/Short)) + (type\= /.Short (/.type short))) + (and (type\= /.Integer (/.type java/lang/Integer)) + (type\= /.Integer (/.type int))) + (and (type\= /.Long (/.type java/lang/Long)) + (type\= /.Long (/.type long))) + (and (type\= /.Float (/.type java/lang/Float)) + (type\= /.Float (/.type float))) + (and (type\= /.Double (/.type java/lang/Double)) + (type\= /.Double (/.type double))) + (and (type\= /.Character (/.type java/lang/Character)) + (type\= /.Character (/.type char))))) + )))) (def: #export test - ($_ _.and - (<| (_.context "Conversions.") - ..conversions) - (<| (_.context "Miscellaneous.") - ..miscellaneous) - (<| (_.context "Arrays.") - ..arrays))) + (<| (_.covering /._) + ($_ _.and + ..conversions + ..arrays + ..miscellaneous))) diff --git a/stdlib/source/test/lux/time/date.lux b/stdlib/source/test/lux/time/date.lux index b8813ba77..fdf78d535 100644 --- a/stdlib/source/test/lux/time/date.lux +++ b/stdlib/source/test/lux/time/date.lux @@ -19,7 +19,8 @@ [math ["." random (#+ Random)] [number - ["n" nat]]]] + ["n" nat] + ["i" int]]]] [\\ ["." /]]) @@ -63,6 +64,10 @@ /.to_days /.from_days (\ /.equivalence = expected)))) + (_.cover [/.epoch] + (|> /.epoch + /.to_days + (i.= +0))) (do random.monad [expected random.date] (_.cover [/.parser] |