packages feed

lorentz 0.2.0 → 0.3.0

raw patch · 93 files changed

+828/−978 lines, 93 files

Files

CHANGES.md view
@@ -1,6 +1,30 @@+<!--+SPDX-FileCopyrightText: 2020 Tocqueville Group++SPDX-License-Identifier: LicenseRef-MIT-TQ+-->+ Unreleased ========== <!-- Append new entries here -->++0.3.0+=====+* [!417](https://gitlab.com/morley-framework/morley/-/merge_requests/417)+Change the license to MIT.+* [!360](https://gitlab.com/morley-framework/morley/-/merge_requests/360)+  + Add `compileLorentzWithOptions` function that accepts optional Michelson+  optimizer configuration and string transformer function. Changed `compileLorentz` to call the+  optimizer with the default configuration.+  + Add `Lorentz.Contract` data type as a wrapper for `Lorentz.ContractCode` and+    `Lorentz.CompilationOptions`. Require that all contracts are wrapped in this data type.+* [!354](https://gitlab.com/morley-framework/morley/-/merge_requests/354)+  + Add `constructStack` function that constructs a datatype from fields on the stack.+  + Add `deconstruct` function that deconstructs a datatype to its fields on the stack.+* [!358](https://gitlab.com/morley-framework/morley/-/merge_requests/358)+  Removed deprecated `STEPS_TO_QUOTA` instruction.+* [!337](https://gitlab.com/morley-framework/morley/-/merge_requests/337)+  Added `comment`, `commentAroundFun` and `commentAroundStmt` to generate comments in Michelson code.  0.2.0 =====
LICENSE view
@@ -1,662 +1,19 @@-                    GNU AFFERO GENERAL PUBLIC LICENSE-                       Version 3, 19 November 2007-- Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>- Everyone is permitted to copy and distribute verbatim copies- of this license document, but changing it is not allowed.--                            Preamble--  The GNU Affero General Public License is a free, copyleft license for-software and other kinds of works, specifically designed to ensure-cooperation with the community in the case of network server software.--  The licenses for most software and other practical works are designed-to take away your freedom to share and change the works.  By contrast,-our General Public Licenses are intended to guarantee your freedom to-share and change all versions of a program--to make sure it remains free-software for all its users.--  When we speak of free software, we are referring to freedom, not-price.  Our General Public Licenses are designed to make sure that you-have the freedom to distribute copies of free software (and charge for-them if you wish), that you receive source code or can get it if you-want it, that you can change the software or use pieces of it in new-free programs, and that you know you can do these things.--  Developers that use our General Public Licenses protect your rights-with two steps: (1) assert copyright on the software, and (2) offer-you this License which gives you legal permission to copy, distribute-and/or modify the software.--  A secondary benefit of defending all users' freedom is that-improvements made in alternate versions of the program, if they-receive widespread use, become available for other developers to-incorporate.  Many developers of free software are heartened and-encouraged by the resulting cooperation.  However, in the case of-software used on network servers, this result may fail to come about.-The GNU General Public License permits making a modified version and-letting the public access it on a server without ever releasing its-source code to the public.--  The GNU Affero General Public License is designed specifically to-ensure that, in such cases, the modified source code becomes available-to the community.  It requires the operator of a network server to-provide the source code of the modified version running there to the-users of that server.  Therefore, public use of a modified version, on-a publicly accessible server, gives the public access to the source-code of the modified version.--  An older license, called the Affero General Public License and-published by Affero, was designed to accomplish similar goals.  This is-a different license, not a version of the Affero GPL, but Affero has-released a new version of the Affero GPL which permits relicensing under-this license.--  The precise terms and conditions for copying, distribution and-modification follow.--                       TERMS AND CONDITIONS--  0. Definitions.--  "This License" refers to version 3 of the GNU Affero General Public License.--  "Copyright" also means copyright-like laws that apply to other kinds of-works, such as semiconductor masks.--  "The Program" refers to any copyrightable work licensed under this-License.  Each licensee is addressed as "you".  "Licensees" and-"recipients" may be individuals or organizations.--  To "modify" a work means to copy from or adapt all or part of the work-in a fashion requiring copyright permission, other than the making of an-exact copy.  The resulting work is called a "modified version" of the-earlier work or a work "based on" the earlier work.--  A "covered work" means either the unmodified Program or a work based-on the Program.--  To "propagate" a work means to do anything with it that, without-permission, would make you directly or secondarily liable for-infringement under applicable copyright law, except executing it on a-computer or modifying a private copy.  Propagation includes copying,-distribution (with or without modification), making available to the-public, and in some countries other activities as well.--  To "convey" a work means any kind of propagation that enables other-parties to make or receive copies.  Mere interaction with a user through-a computer network, with no transfer of a copy, is not conveying.--  An interactive user interface displays "Appropriate Legal Notices"-to the extent that it includes a convenient and prominently visible-feature that (1) displays an appropriate copyright notice, and (2)-tells the user that there is no warranty for the work (except to the-extent that warranties are provided), that licensees may convey the-work under this License, and how to view a copy of this License.  If-the interface presents a list of user commands or options, such as a-menu, a prominent item in the list meets this criterion.--  1. Source Code.--  The "source code" for a work means the preferred form of the work-for making modifications to it.  "Object code" means any non-source-form of a work.--  A "Standard Interface" means an interface that either is an official-standard defined by a recognized standards body, or, in the case of-interfaces specified for a particular programming language, one that-is widely used among developers working in that language.--  The "System Libraries" of an executable work include anything, other-than the work as a whole, that (a) is included in the normal form of-packaging a Major Component, but which is not part of that Major-Component, and (b) serves only to enable use of the work with that-Major Component, or to implement a Standard Interface for which an-implementation is available to the public in source code form.  A-"Major Component", in this context, means a major essential component-(kernel, window system, and so on) of the specific operating system-(if any) on which the executable work runs, or a compiler used to-produce the work, or an object code interpreter used to run it.--  The "Corresponding Source" for a work in object code form means all-the source code needed to generate, install, and (for an executable-work) run the object code and to modify the work, including scripts to-control those activities.  However, it does not include the work's-System Libraries, or general-purpose tools or generally available free-programs which are used unmodified in performing those activities but-which are not part of the work.  For example, Corresponding Source-includes interface definition files associated with source files for-the work, and the source code for shared libraries and dynamically-linked subprograms that the work is specifically designed to require,-such as by intimate data communication or control flow between those-subprograms and other parts of the work.--  The Corresponding Source need not include anything that users-can regenerate automatically from other parts of the Corresponding-Source.--  The Corresponding Source for a work in source code form is that-same work.--  2. Basic Permissions.--  All rights granted under this License are granted for the term of-copyright on the Program, and are irrevocable provided the stated-conditions are met.  This License explicitly affirms your unlimited-permission to run the unmodified Program.  The output from running a-covered work is covered by this License only if the output, given its-content, constitutes a covered work.  This License acknowledges your-rights of fair use or other equivalent, as provided by copyright law.--  You may make, run and propagate covered works that you do not-convey, without conditions so long as your license otherwise remains-in force.  You may convey covered works to others for the sole purpose-of having them make modifications exclusively for you, or provide you-with facilities for running those works, provided that you comply with-the terms of this License in conveying all material for which you do-not control copyright.  Those thus making or running the covered works-for you must do so exclusively on your behalf, under your direction-and control, on terms that prohibit them from making any copies of-your copyrighted material outside their relationship with you.--  Conveying under any other circumstances is permitted solely under-the conditions stated below.  Sublicensing is not allowed; section 10-makes it unnecessary.--  3. Protecting Users' Legal Rights From Anti-Circumvention Law.--  No covered work shall be deemed part of an effective technological-measure under any applicable law fulfilling obligations under article-11 of the WIPO copyright treaty adopted on 20 December 1996, or-similar laws prohibiting or restricting circumvention of such-measures.--  When you convey a covered work, you waive any legal power to forbid-circumvention of technological measures to the extent such circumvention-is effected by exercising rights under this License with respect to-the covered work, and you disclaim any intention to limit operation or-modification of the work as a means of enforcing, against the work's-users, your or third parties' legal rights to forbid circumvention of-technological measures.--  4. Conveying Verbatim Copies.--  You may convey verbatim copies of the Program's source code as you-receive it, in any medium, provided that you conspicuously and-appropriately publish on each copy an appropriate copyright notice;-keep intact all notices stating that this License and any-non-permissive terms added in accord with section 7 apply to the code;-keep intact all notices of the absence of any warranty; and give all-recipients a copy of this License along with the Program.--  You may charge any price or no price for each copy that you convey,-and you may offer support or warranty protection for a fee.--  5. Conveying Modified Source Versions.--  You may convey a work based on the Program, or the modifications to-produce it from the Program, in the form of source code under the-terms of section 4, provided that you also meet all of these conditions:--    a) The work must carry prominent notices stating that you modified-    it, and giving a relevant date.--    b) The work must carry prominent notices stating that it is-    released under this License and any conditions added under section-    7.  This requirement modifies the requirement in section 4 to-    "keep intact all notices".--    c) You must license the entire work, as a whole, under this-    License to anyone who comes into possession of a copy.  This-    License will therefore apply, along with any applicable section 7-    additional terms, to the whole of the work, and all its parts,-    regardless of how they are packaged.  This License gives no-    permission to license the work in any other way, but it does not-    invalidate such permission if you have separately received it.--    d) If the work has interactive user interfaces, each must display-    Appropriate Legal Notices; however, if the Program has interactive-    interfaces that do not display Appropriate Legal Notices, your-    work need not make them do so.--  A compilation of a covered work with other separate and independent-works, which are not by their nature extensions of the covered work,-and which are not combined with it such as to form a larger program,-in or on a volume of a storage or distribution medium, is called an-"aggregate" if the compilation and its resulting copyright are not-used to limit the access or legal rights of the compilation's users-beyond what the individual works permit.  Inclusion of a covered work-in an aggregate does not cause this License to apply to the other-parts of the aggregate.--  6. Conveying Non-Source Forms.--  You may convey a covered work in object code form under the terms-of sections 4 and 5, provided that you also convey the-machine-readable Corresponding Source under the terms of this License,-in one of these ways:--    a) Convey the object code in, or embodied in, a physical product-    (including a physical distribution medium), accompanied by the-    Corresponding Source fixed on a durable physical medium-    customarily used for software interchange.--    b) Convey the object code in, or embodied in, a physical product-    (including a physical distribution medium), accompanied by a-    written offer, valid for at least three years and valid for as-    long as you offer spare parts or customer support for that product-    model, to give anyone who possesses the object code either (1) a-    copy of the Corresponding Source for all the software in the-    product that is covered by this License, on a durable physical-    medium customarily used for software interchange, for a price no-    more than your reasonable cost of physically performing this-    conveying of source, or (2) access to copy the-    Corresponding Source from a network server at no charge.--    c) Convey individual copies of the object code with a copy of the-    written offer to provide the Corresponding Source.  This-    alternative is allowed only occasionally and noncommercially, and-    only if you received the object code with such an offer, in accord-    with subsection 6b.--    d) Convey the object code by offering access from a designated-    place (gratis or for a charge), and offer equivalent access to the-    Corresponding Source in the same way through the same place at no-    further charge.  You need not require recipients to copy the-    Corresponding Source along with the object code.  If the place to-    copy the object code is a network server, the Corresponding Source-    may be on a different server (operated by you or a third party)-    that supports equivalent copying facilities, provided you maintain-    clear directions next to the object code saying where to find the-    Corresponding Source.  Regardless of what server hosts the-    Corresponding Source, you remain obligated to ensure that it is-    available for as long as needed to satisfy these requirements.--    e) Convey the object code using peer-to-peer transmission, provided-    you inform other peers where the object code and Corresponding-    Source of the work are being offered to the general public at no-    charge under subsection 6d.--  A separable portion of the object code, whose source code is excluded-from the Corresponding Source as a System Library, need not be-included in conveying the object code work.--  A "User Product" is either (1) a "consumer product", which means any-tangible personal property which is normally used for personal, family,-or household purposes, or (2) anything designed or sold for incorporation-into a dwelling.  In determining whether a product is a consumer product,-doubtful cases shall be resolved in favor of coverage.  For a particular-product received by a particular user, "normally used" refers to a-typical or common use of that class of product, regardless of the status-of the particular user or of the way in which the particular user-actually uses, or expects or is expected to use, the product.  A product-is a consumer product regardless of whether the product has substantial-commercial, industrial or non-consumer uses, unless such uses represent-the only significant mode of use of the product.--  "Installation Information" for a User Product means any methods,-procedures, authorization keys, or other information required to install-and execute modified versions of a covered work in that User Product from-a modified version of its Corresponding Source.  The information must-suffice to ensure that the continued functioning of the modified object-code is in no case prevented or interfered with solely because-modification has been made.--  If you convey an object code work under this section in, or with, or-specifically for use in, a User Product, and the conveying occurs as-part of a transaction in which the right of possession and use of the-User Product is transferred to the recipient in perpetuity or for a-fixed term (regardless of how the transaction is characterized), the-Corresponding Source conveyed under this section must be accompanied-by the Installation Information.  But this requirement does not apply-if neither you nor any third party retains the ability to install-modified object code on the User Product (for example, the work has-been installed in ROM).--  The requirement to provide Installation Information does not include a-requirement to continue to provide support service, warranty, or updates-for a work that has been modified or installed by the recipient, or for-the User Product in which it has been modified or installed.  Access to a-network may be denied when the modification itself materially and-adversely affects the operation of the network or violates the rules and-protocols for communication across the network.--  Corresponding Source conveyed, and Installation Information provided,-in accord with this section must be in a format that is publicly-documented (and with an implementation available to the public in-source code form), and must require no special password or key for-unpacking, reading or copying.--  7. Additional Terms.--  "Additional permissions" are terms that supplement the terms of this-License by making exceptions from one or more of its conditions.-Additional permissions that are applicable to the entire Program shall-be treated as though they were included in this License, to the extent-that they are valid under applicable law.  If additional permissions-apply only to part of the Program, that part may be used separately-under those permissions, but the entire Program remains governed by-this License without regard to the additional permissions.--  When you convey a copy of a covered work, you may at your option-remove any additional permissions from that copy, or from any part of-it.  (Additional permissions may be written to require their own-removal in certain cases when you modify the work.)  You may place-additional permissions on material, added by you to a covered work,-for which you have or can give appropriate copyright permission.--  Notwithstanding any other provision of this License, for material you-add to a covered work, you may (if authorized by the copyright holders of-that material) supplement the terms of this License with terms:--    a) Disclaiming warranty or limiting liability differently from the-    terms of sections 15 and 16 of this License; or--    b) Requiring preservation of specified reasonable legal notices or-    author attributions in that material or in the Appropriate Legal-    Notices displayed by works containing it; or--    c) Prohibiting misrepresentation of the origin of that material, or-    requiring that modified versions of such material be marked in-    reasonable ways as different from the original version; or--    d) Limiting the use for publicity purposes of names of licensors or-    authors of the material; or--    e) Declining to grant rights under trademark law for use of some-    trade names, trademarks, or service marks; or--    f) Requiring indemnification of licensors and authors of that-    material by anyone who conveys the material (or modified versions of-    it) with contractual assumptions of liability to the recipient, for-    any liability that these contractual assumptions directly impose on-    those licensors and authors.--  All other non-permissive additional terms are considered "further-restrictions" within the meaning of section 10.  If the Program as you-received it, or any part of it, contains a notice stating that it is-governed by this License along with a term that is a further-restriction, you may remove that term.  If a license document contains-a further restriction but permits relicensing or conveying under this-License, you may add to a covered work material governed by the terms-of that license document, provided that the further restriction does-not survive such relicensing or conveying.--  If you add terms to a covered work in accord with this section, you-must place, in the relevant source files, a statement of the-additional terms that apply to those files, or a notice indicating-where to find the applicable terms.--  Additional terms, permissive or non-permissive, may be stated in the-form of a separately written license, or stated as exceptions;-the above requirements apply either way.--  8. Termination.--  You may not propagate or modify a covered work except as expressly-provided under this License.  Any attempt otherwise to propagate or-modify it is void, and will automatically terminate your rights under-this License (including any patent licenses granted under the third-paragraph of section 11).--  However, if you cease all violation of this License, then your-license from a particular copyright holder is reinstated (a)-provisionally, unless and until the copyright holder explicitly and-finally terminates your license, and (b) permanently, if the copyright-holder fails to notify you of the violation by some reasonable means-prior to 60 days after the cessation.--  Moreover, your license from a particular copyright holder is-reinstated permanently if the copyright holder notifies you of the-violation by some reasonable means, this is the first time you have-received notice of violation of this License (for any work) from that-copyright holder, and you cure the violation prior to 30 days after-your receipt of the notice.--  Termination of your rights under this section does not terminate the-licenses of parties who have received copies or rights from you under-this License.  If your rights have been terminated and not permanently-reinstated, you do not qualify to receive new licenses for the same-material under section 10.--  9. Acceptance Not Required for Having Copies.--  You are not required to accept this License in order to receive or-run a copy of the Program.  Ancillary propagation of a covered work-occurring solely as a consequence of using peer-to-peer transmission-to receive a copy likewise does not require acceptance.  However,-nothing other than this License grants you permission to propagate or-modify any covered work.  These actions infringe copyright if you do-not accept this License.  Therefore, by modifying or propagating a-covered work, you indicate your acceptance of this License to do so.--  10. Automatic Licensing of Downstream Recipients.--  Each time you convey a covered work, the recipient automatically-receives a license from the original licensors, to run, modify and-propagate that work, subject to this License.  You are not responsible-for enforcing compliance by third parties with this License.--  An "entity transaction" is a transaction transferring control of an-organization, or substantially all assets of one, or subdividing an-organization, or merging organizations.  If propagation of a covered-work results from an entity transaction, each party to that-transaction who receives a copy of the work also receives whatever-licenses to the work the party's predecessor in interest had or could-give under the previous paragraph, plus a right to possession of the-Corresponding Source of the work from the predecessor in interest, if-the predecessor has it or can get it with reasonable efforts.--  You may not impose any further restrictions on the exercise of the-rights granted or affirmed under this License.  For example, you may-not impose a license fee, royalty, or other charge for exercise of-rights granted under this License, and you may not initiate litigation-(including a cross-claim or counterclaim in a lawsuit) alleging that-any patent claim is infringed by making, using, selling, offering for-sale, or importing the Program or any portion of it.--  11. Patents.--  A "contributor" is a copyright holder who authorizes use under this-License of the Program or a work on which the Program is based.  The-work thus licensed is called the contributor's "contributor version".--  A contributor's "essential patent claims" are all patent claims-owned or controlled by the contributor, whether already acquired or-hereafter acquired, that would be infringed by some manner, permitted-by this License, of making, using, or selling its contributor version,-but do not include claims that would be infringed only as a-consequence of further modification of the contributor version.  For-purposes of this definition, "control" includes the right to grant-patent sublicenses in a manner consistent with the requirements of-this License.--  Each contributor grants you a non-exclusive, worldwide, royalty-free-patent license under the contributor's essential patent claims, to-make, use, sell, offer for sale, import and otherwise run, modify and-propagate the contents of its contributor version.--  In the following three paragraphs, a "patent license" is any express-agreement or commitment, however denominated, not to enforce a patent-(such as an express permission to practice a patent or covenant not to-sue for patent infringement).  To "grant" such a patent license to a-party means to make such an agreement or commitment not to enforce a-patent against the party.--  If you convey a covered work, knowingly relying on a patent license,-and the Corresponding Source of the work is not available for anyone-to copy, free of charge and under the terms of this License, through a-publicly available network server or other readily accessible means,-then you must either (1) cause the Corresponding Source to be so-available, or (2) arrange to deprive yourself of the benefit of the-patent license for this particular work, or (3) arrange, in a manner-consistent with the requirements of this License, to extend the patent-license to downstream recipients.  "Knowingly relying" means you have-actual knowledge that, but for the patent license, your conveying the-covered work in a country, or your recipient's use of the covered work-in a country, would infringe one or more identifiable patents in that-country that you have reason to believe are valid.--  If, pursuant to or in connection with a single transaction or-arrangement, you convey, or propagate by procuring conveyance of, a-covered work, and grant a patent license to some of the parties-receiving the covered work authorizing them to use, propagate, modify-or convey a specific copy of the covered work, then the patent license-you grant is automatically extended to all recipients of the covered-work and works based on it.--  A patent license is "discriminatory" if it does not include within-the scope of its coverage, prohibits the exercise of, or is-conditioned on the non-exercise of one or more of the rights that are-specifically granted under this License.  You may not convey a covered-work if you are a party to an arrangement with a third party that is-in the business of distributing software, under which you make payment-to the third party based on the extent of your activity of conveying-the work, and under which the third party grants, to any of the-parties who would receive the covered work from you, a discriminatory-patent license (a) in connection with copies of the covered work-conveyed by you (or copies made from those copies), or (b) primarily-for and in connection with specific products or compilations that-contain the covered work, unless you entered into that arrangement,-or that patent license was granted, prior to 28 March 2007.--  Nothing in this License shall be construed as excluding or limiting-any implied license or other defenses to infringement that may-otherwise be available to you under applicable patent law.--  12. No Surrender of Others' Freedom.--  If conditions are imposed on you (whether by court order, agreement or-otherwise) that contradict the conditions of this License, they do not-excuse you from the conditions of this License.  If you cannot convey a-covered work so as to satisfy simultaneously your obligations under this-License and any other pertinent obligations, then as a consequence you may-not convey it at all.  For example, if you agree to terms that obligate you-to collect a royalty for further conveying from those to whom you convey-the Program, the only way you could satisfy both those terms and this-License would be to refrain entirely from conveying the Program.--  13. Remote Network Interaction; Use with the GNU General Public License.--  Notwithstanding any other provision of this License, if you modify the-Program, your modified version must prominently offer all users-interacting with it remotely through a computer network (if your version-supports such interaction) an opportunity to receive the Corresponding-Source of your version by providing access to the Corresponding Source-from a network server at no charge, through some standard or customary-means of facilitating copying of software.  This Corresponding Source-shall include the Corresponding Source for any work covered by version 3-of the GNU General Public License that is incorporated pursuant to the-following paragraph.--  Notwithstanding any other provision of this License, you have-permission to link or combine any covered work with a work licensed-under version 3 of the GNU General Public License into a single-combined work, and to convey the resulting work.  The terms of this-License will continue to apply to the part which is the covered work,-but the work with which it is combined will remain governed by version-3 of the GNU General Public License.--  14. Revised Versions of this License.--  The Free Software Foundation may publish revised and/or new versions of-the GNU Affero General Public License from time to time.  Such new versions-will be similar in spirit to the present version, but may differ in detail to-address new problems or concerns.--  Each version is given a distinguishing version number.  If the-Program specifies that a certain numbered version of the GNU Affero General-Public License "or any later version" applies to it, you have the-option of following the terms and conditions either of that numbered-version or of any later version published by the Free Software-Foundation.  If the Program does not specify a version number of the-GNU Affero General Public License, you may choose any version ever published-by the Free Software Foundation.--  If the Program specifies that a proxy can decide which future-versions of the GNU Affero General Public License can be used, that proxy's-public statement of acceptance of a version permanently authorizes you-to choose that version for the Program.--  Later license versions may give you additional or different-permissions.  However, no additional obligations are imposed on any-author or copyright holder as a result of your choosing to follow a-later version.--  15. Disclaimer of Warranty.--  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY-APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM-IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.--  16. Limitation of Liability.--  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF-SUCH DAMAGES.--  17. Interpretation of Sections 15 and 16.--  If the disclaimer of warranty and limitation of liability provided-above cannot be given local legal effect according to their terms,-reviewing courts shall apply local law that most closely approximates-an absolute waiver of all civil liability in connection with the-Program, unless a warranty or assumption of liability accompanies a-copy of the Program in return for a fee.--                     END OF TERMS AND CONDITIONS--            How to Apply These Terms to Your New Programs--  If you develop a new program, and you want it to be of the greatest-possible use to the public, the best way to achieve this is to make it-free software which everyone can redistribute and change under these terms.--  To do so, attach the following notices to the program.  It is safest-to attach them to the start of each source file to most effectively-state the exclusion of warranty; and each file should have at least-the "copyright" line and a pointer to where the full notice is found.--    <one line to give the program's name and a brief idea of what it does.>-    Copyright (C) <year>  <name of author>--    This program is free software: you can redistribute it and/or modify-    it under the terms of the GNU Affero General Public License as published by-    the Free Software Foundation, either version 3 of the License, or-    (at your option) any later version.--    This program is distributed in the hope that it will be useful,-    but WITHOUT ANY WARRANTY; without even the implied warranty of-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the-    GNU Affero General Public License for more details.--    You should have received a copy of the GNU Affero General Public License-    along with this program.  If not, see <https://www.gnu.org/licenses/>.--Also add information on how to contact you by electronic and paper mail.+MIT License Copyright (c) 2020 Tocqueville Group -  If your software can interact with users remotely through a computer-network, you should also make sure that it provides a way for users to-get its source.  For example, if your program is a web application, its-interface could display a "Source" link that leads users to an archive-of the code.  There are many ways you could offer source, and different-solutions will be better for different programs; see section 13 for the-specific requirements.+Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is furnished+to do so, subject to the following conditions: -  You should also get your employer (if you work as a programmer) or school,-if any, to sign a "copyright disclaimer" for the program, if necessary.-For more information on this, and how to apply and follow the GNU AGPL, see-<https://www.gnu.org/licenses/>.+The above copyright notice and this permission notice (including the next+paragraph) shall be included in all copies or substantial portions of the+Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS+OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF+OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
README.md view
@@ -1,3 +1,9 @@+<!--+SPDX-FileCopyrightText: 2020 Tocqueville Group++SPDX-License-Identifier: LicenseRef-MIT-TQ+-->+ # Morley Lorentz EDSL  ## Table of contents
lorentz.cabal view
@@ -4,19 +4,19 @@ -- -- see: https://github.com/sol/hpack ----- hash: 19874377999eb866131159c713da07469cac8c7698406c41b9e7758fd1104672+-- hash: 7df6ecd69cd3e2cb79e6545e9f1715fce5b2d92b302c7ed0bcfb82a4090245fa  name:           lorentz-version:        0.2.0+version:        0.3.0 synopsis:       EDSL for the Michelson Language description:    Lorentz is a powerful meta-programming tool which allows one to write Michelson contracts directly in Haskell. It has the same instructions as Michelson, but operates on Haskell values and allows one to use Haskell features. category:       Language homepage:       https://gitlab.com/morley-framework/morley-bug-reports:    https://gitlab.com/morley-framework/morley/issues+bug-reports:    https://gitlab.com/morley-framework/morley/-/issues author:         camlCase, Serokell, Tocqueville Group maintainer:     Serokell <hi@serokell.io> copyright:      2019-2020 Tocqueville Group-license:        AGPL-3.0-or-later+license:        MIT license-file:   LICENSE build-type:     Simple extra-source-files:@@ -94,7 +94,7 @@       Paths_lorentz   hs-source-dirs:       src-  default-extensions: ApplicativeDo AllowAmbiguousTypes BangPatterns BlockArguments ConstraintKinds DataKinds DefaultSignatures DeriveAnyClass DeriveDataTypeable DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable DerivingStrategies EmptyCase FlexibleContexts FlexibleInstances GADTs GeneralizedNewtypeDeriving LambdaCase MonadFailDesugaring MultiParamTypeClasses MultiWayIf NamedFieldPuns NegativeLiterals NumDecimals OverloadedLabels OverloadedStrings PatternSynonyms PolyKinds QuasiQuotes RankNTypes RecordWildCards RecursiveDo ScopedTypeVariables StandaloneDeriving StrictData TemplateHaskell TupleSections TypeApplications TypeFamilies TypeOperators UndecidableInstances ViewPatterns+  default-extensions: ApplicativeDo AllowAmbiguousTypes BangPatterns BlockArguments ConstraintKinds DataKinds DefaultSignatures DeriveAnyClass DeriveDataTypeable DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable DerivingStrategies EmptyCase FlexibleContexts FlexibleInstances GADTs GeneralizedNewtypeDeriving LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NegativeLiterals NumDecimals OverloadedLabels OverloadedStrings PatternSynonyms PolyKinds QuasiQuotes RankNTypes RecordWildCards RecursiveDo ScopedTypeVariables StandaloneDeriving StrictData TemplateHaskell TupleSections TypeApplications TypeFamilies TypeOperators UndecidableInstances UndecidableSuperClasses ViewPatterns   ghc-options: -Weverything -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missed-specialisations -Wno-all-missed-specialisations -Wno-unsafe -Wno-safe -Wno-missing-local-signatures -Wno-monomorphism-restriction -Wno-implicit-prelude   build-depends:       HUnit@@ -162,7 +162,7 @@       Paths_lorentz   hs-source-dirs:       test-  default-extensions: ApplicativeDo AllowAmbiguousTypes BangPatterns BlockArguments ConstraintKinds DataKinds DefaultSignatures DeriveAnyClass DeriveDataTypeable DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable DerivingStrategies EmptyCase FlexibleContexts FlexibleInstances GADTs GeneralizedNewtypeDeriving LambdaCase MonadFailDesugaring MultiParamTypeClasses MultiWayIf NamedFieldPuns NegativeLiterals NumDecimals OverloadedLabels OverloadedStrings PatternSynonyms PolyKinds QuasiQuotes RankNTypes RecordWildCards RecursiveDo ScopedTypeVariables StandaloneDeriving StrictData TemplateHaskell TupleSections TypeApplications TypeFamilies TypeOperators UndecidableInstances ViewPatterns DerivingStrategies+  default-extensions: ApplicativeDo AllowAmbiguousTypes BangPatterns BlockArguments ConstraintKinds DataKinds DefaultSignatures DeriveAnyClass DeriveDataTypeable DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable DerivingStrategies EmptyCase FlexibleContexts FlexibleInstances GADTs GeneralizedNewtypeDeriving LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NegativeLiterals NumDecimals OverloadedLabels OverloadedStrings PatternSynonyms PolyKinds QuasiQuotes RankNTypes RecordWildCards RecursiveDo ScopedTypeVariables StandaloneDeriving StrictData TemplateHaskell TupleSections TypeApplications TypeFamilies TypeOperators UndecidableInstances UndecidableSuperClasses ViewPatterns DerivingStrategies   ghc-options: -Weverything -Wno-missing-exported-signatures -Wno-missing-import-lists -Wno-missed-specialisations -Wno-all-missed-specialisations -Wno-unsafe -Wno-safe -Wno-missing-local-signatures -Wno-monomorphism-restriction -Wno-implicit-prelude -threaded -with-rtsopts=-N   build-tool-depends:       tasty-discover:tasty-discover
src/Lorentz.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Lorentz   ( module Exports   ) where
src/Lorentz/ADT.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# LANGUAGE FunctionalDependencies #-}  module Lorentz.ADT@@ -14,6 +18,8 @@   , modifyField   , construct   , constructT+  , constructStack+  , deconstruct   , fieldCtor   , wrap_   , case_@@ -34,7 +40,7 @@   , argF   ) where -import Data.Constraint (Dict(..))+import Data.Constraint ((\\)) import qualified Data.Kind as Kind import Data.Vinyl.Core (RMap(..), Rec(..)) import GHC.TypeLits (AppendSymbol, Symbol)@@ -47,6 +53,7 @@ import Michelson.Typed.Haskell.Value import Util.TypeTuple import Util.Label (Label)+import Util.Type (type (++), KnownList)  -- | Allows field access and modification. type HasField dt fname =@@ -152,6 +159,32 @@   => IsoRecTuple fctors   -> st :-> dt & st constructT = construct . recFromTuple++-- | Construct an object from fields on the stack.+constructStack+  :: forall dt fields st .+  ( InstrConstructC dt+  , ToTs fields ~ ToTs (ConstructorFieldTypes dt)+  , KnownList fields+  )+  => (fields ++ st) :-> dt & st+constructStack =+  I (instrConstructStack @dt @(ToTs fields))+      \\ totsKnownLemma @fields+      \\ totsAppendLemma @fields @st++-- | Decompose a complex object into its fields+deconstruct+  :: forall dt fields st .+  ( InstrDeconstructC dt+  , KnownList fields+  , ToTs fields ~ ToTs (ConstructorFieldTypes dt)+  )+  => dt & st :-> (fields ++ st)+deconstruct =+  I (instrDeconstruct @dt @(ToTs fields))+    \\ totsKnownLemma @fields+    \\ totsAppendLemma @fields @st  -- | Lift an instruction to field constructor. fieldCtor :: HasCallStack => (st :-> f & st) -> FieldConstructor st f
src/Lorentz/Address.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {- |  This module introduces several types for safe work with @address@ and
src/Lorentz/Arith.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Type families from 'Michelson.Typed.Arith' lifted to Haskell types. module Lorentz.Arith   ( ArithOpHs (..)@@ -7,23 +11,20 @@ import qualified Data.Kind as Kind  import Lorentz.Value+import Lorentz.Constraints.Scopes (NiceComparable) import Michelson.Typed.Arith-import Michelson.Typed.Haskell.Value-import Michelson.Typed.T --- | Lifted 'AithOp'.-class ( ArithOp aop (ToCT n) (ToCT m)-      , IsComparable n, IsComparable m-      , Typeable (ToCT n), Typeable (ToCT m)-      , ToT (ArithResHs aop n m) ~ 'Tc (ArithRes aop (ToCT n) (ToCT m))+-- | Lifted 'ArithOp'.+class ( ArithOp aop (ToT n) (ToT m)+      , NiceComparable n, NiceComparable m+      , ToT (ArithResHs aop n m) ~ ArithRes aop (ToT n) (ToT m)       ) => ArithOpHs (aop :: Kind.Type) (n :: Kind.Type) (m :: Kind.Type) where   type ArithResHs aop n m :: Kind.Type --- | Lifted 'UnaryAithOp'.-class ( UnaryArithOp aop (ToCT n)-      , IsComparable n-      , Typeable (ToCT n)-      , ToT (UnaryArithResHs aop n) ~ 'Tc (UnaryArithRes aop (ToCT n))+-- | Lifted 'UnaryArithOp'.+class ( UnaryArithOp aop (ToT n)+      , NiceComparable n+      , ToT (UnaryArithResHs aop n) ~ UnaryArithRes aop (ToT n)       ) => UnaryArithOpHs (aop :: Kind.Type) (n :: Kind.Type) where   type UnaryArithResHs aop n :: Kind.Type 
src/Lorentz/Base.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# OPTIONS_GHC -Wno-redundant-constraints #-}  -- | Foundation of Lorentz development.@@ -25,7 +29,7 @@    , ContractOut   , ContractCode-  , SomeContract (..)+  , SomeContractCode (..)   , Lambda   ) where @@ -108,11 +112,11 @@ type ContractOut st = '[([Operation], st)] type ContractCode cp st = '[(cp, st)] :-> ContractOut st -data SomeContract where-  SomeContract+data SomeContractCode where+  SomeContractCode     :: (NiceParameterFull cp, NiceStorage st)     => ContractCode cp st-    -> SomeContract+    -> SomeContractCode  type (&) (a :: Kind.Type) (b :: [Kind.Type]) = a ': b infixr 2 &
src/Lorentz/Coercions.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Identity transformations between different Haskell types. module Lorentz.Coercions   ( -- * Safe coercions@@ -28,7 +32,7 @@  import Control.Lens (Wrapped(..)) import qualified Data.Coerce as Coerce-import Data.Constraint (Dict(..), (\\))+import Data.Constraint ((\\)) import qualified GHC.Generics as G import Named (NamedF) import Unsafe.Coerce (unsafeCoerce)@@ -39,7 +43,6 @@ import Lorentz.Value import Lorentz.Zip import Michelson.Typed-import Util.Label (Label)  ---------------------------------------------------------------------------- -- Unsafe coercions
src/Lorentz/Common.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Common primitives. module Lorentz.Common   ( Entrypoint
src/Lorentz/Constraints.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Lorentz.Constraints   ( module Exports   ) where
src/Lorentz/Constraints/Derivative.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Some derivative constraints. -- -- They are moved to separate module because they need to lie quite high in
src/Lorentz/Constraints/Scopes.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# LANGUAGE UndecidableSuperClasses #-}  -- | Scope-related constraints used in Lorentz.@@ -6,14 +10,14 @@ -- in Lorentz. module Lorentz.Constraints.Scopes   ( -- * Grouped constraints-    NiceParameter-  , NiceStorage+    NiceComparable   , NiceConstant-  , NicePackedValue-  , NiceUnpackedValue   , NiceFullPackedValue+  , NicePackedValue+  , NiceParameter   , NicePrintedValue-  , NiceComparable+  , NiceStorage+  , NiceUnpackedValue    , niceParameterEvi   , niceStorageEvi@@ -25,7 +29,6 @@     -- * Individual constraints (internals)   , CanHaveBigMap   , KnownValue-  , KnownCValue   , NoOperation   , NoContractType   , NoBigMap@@ -35,7 +38,6 @@   ) where  import Data.Constraint (trans, weaken2)-import Data.Singletons (SingI)  import Michelson.Typed @@ -46,9 +48,6 @@ class (IsoValue a, Typeable (ToT a), SingI (ToT a)) => KnownValue a instance (IsoValue a, Typeable (ToT a), SingI (ToT a)) => KnownValue a -class (IsoValue a, Typeable (ToCT a), SingI (ToCT a)) => KnownCValue a-instance (IsoValue a, Typeable (ToCT a), SingI (ToCT a)) => KnownCValue a- -- | Ensure given type does not contain "operation". class (IsoValue a, ForbidOp (ToT a)) => NoOperation a instance (IsoValue a, ForbidOp (ToT a)) => NoOperation a@@ -83,7 +82,7 @@  type NicePrintedValue a = (KnownValue a, ProperPrintedValBetterErrors (ToT a)) -type NiceComparable a = (KnownValue a, ProperComparabilityBetterErrors (ToT a))+type NiceComparable n = (KnownValue n, Comparable (ToT n))  niceParameterEvi :: forall a. NiceParameter a :- ParameterScope (ToT a) niceParameterEvi =
src/Lorentz/ContractRegistry.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | This module contains various datatypes and functions which are -- common for contract registry packages (e.g. @morley-ledgers@ and -- @morley-multisig@).@@ -14,7 +18,6 @@   , runContractRegistry    -- * Building blocks-  , getContract   , printContractFromRegistryDoc   ) where @@ -27,13 +30,14 @@ import qualified Options.Applicative as Opt import Tezos.V005.Micheline (Expression) -import Lorentz.Base import Lorentz.Constraints import Lorentz.Doc import Lorentz.Print import Lorentz.Run-import Michelson.Printer (printTypedFullContract)-import Michelson.Typed (FullContract(..), IsoValue(..), Notes)+import Michelson.Analyzer (analyze)+import Michelson.Printer (printTypedContract)+import Michelson.Typed (IsoValue(..), Notes)+import qualified Michelson.Typed as M (Contract(..)) import Morley.Micheline import Util.IO @@ -41,7 +45,7 @@   forall cp st.     (NiceParameterFull cp, NiceStorage st) =>   ContractInfo-  { ciContract :: ContractCode cp st+  { ciContract :: Contract cp st   , ciIsDocumented :: Bool   , ciStorageParser :: Maybe (Opt.Parser st)   -- ^ Specifies how to parse initial storage value.@@ -51,8 +55,6 @@   --   -- If storage is simple and can be easilly constructed manually, you   -- can use 'Nothing'.-  , ciCompilationOptions :: CompilationOptions-  -- ^ How to compile this contract.   , ciStorageNotes :: Notes (ToT st)   -- ^ A temporary approach to add annotations to storage.   -- TODO [#20]: invent something better.@@ -64,12 +66,12 @@ newtype ContractRegistry = ContractRegistry   { unContractRegistry :: Map Text ContractInfo } -getContract :: Text -> ContractRegistry -> Either String ContractInfo+getContract :: Text -> ContractRegistry -> IO ContractInfo getContract name registry =   case Map.lookup name (unContractRegistry registry) of     Nothing ->-      Left $ "No contract with name '" +| name |+ "' found\n" +| registry |+ ""-    Just c -> Right c+      die $ "No contract with name '" +| name |+ "' found\n" +| registry |+ ""+    Just c -> pure c  instance Buildable ContractRegistry where   build registry =@@ -77,11 +79,11 @@  printContractFromRegistryDoc :: Text -> ContractRegistry -> DGitRevision -> Maybe FilePath -> IO () printContractFromRegistryDoc name contracts gitRev mOutput = do-  ContractInfo{..} <- either die pure $ getContract name contracts+  ContractInfo{..} <- getContract name contracts   if ciIsDocumented   then      writeFunc (toString name <> ".md") mOutput $-       contractDocToMarkdown $ buildLorentzDocWithGitRev gitRev ciContract+       contractDocToMarkdown $ buildLorentzDocWithGitRev gitRev $ cCode ciContract   else die "This contract is not documented"  data SomeNiceStorage where@@ -92,6 +94,7 @@   = List   | Print Text (Maybe FilePath) Bool Bool   | Document Text (Maybe FilePath) DGitRevision+  | Analyze Text   | PrintStorage SomeNiceStorage Bool  argParser :: ContractRegistry -> DGitRevision -> Opt.Parser CmdLnArgs@@ -99,6 +102,7 @@   [ listSubCmd   , printSubCmd   , documentSubCmd+  , analyzerSubCmd   ] <> mapMaybe storageSubCmd (Map.toList $ unContractRegistry registry)   where     mkCommandParser commandName parser desc =@@ -113,15 +117,20 @@      printSubCmd =       mkCommandParser "print"-      (Print <$> printOptions <*> outputOptions <*> onelineOption <*> michelineOption)+      (Print <$> nameOption <*> outputOptions <*> onelineOption <*> michelineOption)       "Dump a contract in form of Michelson code"      documentSubCmd =       mkCommandParser "document"-      (Document <$> printOptions <*> outputOptions <*> pure gitRev)+      (Document <$> nameOption <*> outputOptions <*> pure gitRev)       "Dump contract documentation in Markdown" -    printOptions = Opt.strOption $ mconcat+    analyzerSubCmd =+      mkCommandParser "analyze"+      (Analyze <$> nameOption)+      "Analyze the contract and prints statistics about it."++    nameOption = Opt.strOption $ mconcat       [ Opt.short 'n'       , Opt.long "name"       , Opt.metavar "IDENTIFIER"@@ -160,20 +169,22 @@ runContractRegistry :: ContractRegistry -> CmdLnArgs -> IO () runContractRegistry registry = \case   List -> pretty registry-  Print name mOutput forceOneLine useMicheline ->-    case getContract name registry of-      Left err ->-        die err-      Right ContractInfo{..} ->-        let compiledContract  =-              (compileLorentzContractWithOptions ciCompilationOptions ciContract)-                {fcStoreNotes = ciStorageNotes} in-        writeFunc (toString name <> ".tz") mOutput $-          if useMicheline-          then toLazyText $ encodePrettyToTextBuilder $ toExpression compiledContract-          else printTypedFullContract forceOneLine $ compiledContract+  Print name mOutput forceOneLine useMicheline -> do+    ContractInfo{..} <- getContract name registry+    let compiledContract  =+          (compileLorentzContract ciContract)+            {M.cStoreNotes = ciStorageNotes}+    writeFunc (toString name <> ".tz") mOutput $+      if useMicheline+      then toLazyText $ encodePrettyToTextBuilder $ toExpression compiledContract+      else printTypedContract forceOneLine $ compiledContract   Document name mOutput gitRev -> do     printContractFromRegistryDoc name registry gitRev mOutput+  Analyze name -> do+    ContractInfo{..} <- getContract name registry+    let compiledContract  =+          compileLorentzContract ciContract+    putTextLn $ pretty $ analyze $ M.cCode compiledContract   PrintStorage (SomeNiceStorage (storage :: st)) useMicheline ->     if useMicheline     then BS.putStrLn $ encodePretty $ toExpressionHelper storage
src/Lorentz/Doc.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# OPTIONS_GHC -Wno-orphans #-}  module Lorentz.Doc@@ -152,7 +156,7 @@       , SomeTypeWithDoc (Proxy @MText)       ]     ]-  typeDocHaskellRep _ = Nothing+  typeDocHaskellRep _ _ = Nothing   typeDocMichelsonRep _ =     ( Just "Code [Integer, Natural, MText, ()] [ByteString]"     , demote @(ToT ([Integer, Natural, MText, ()] :-> '[ByteString]))
src/Lorentz/Empty.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# OPTIONS_GHC -Wno-orphans #-}  -- | Support for uninhabited type.
src/Lorentz/EntryPoints.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# LANGUAGE UndecidableSuperClasses #-} {-# OPTIONS_GHC -Wno-redundant-constraints #-} 
src/Lorentz/EntryPoints/Core.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# LANGUAGE UndecidableSuperClasses #-}  -- | Primitives supplying entrypoints declarations and lookup.@@ -42,7 +46,7 @@   , RequireAllUniqueEntryPoints'   ) where -import Data.Constraint (Dict(..), (\\))+import Data.Constraint ((\\)) import qualified Data.Kind as Kind import Data.Typeable (typeRep) import Data.Vinyl (Rec(..))@@ -52,6 +56,7 @@ import Fmt (pretty)  import Michelson.Typed+import qualified Michelson.Untyped as U import Util.Label import Util.Type import Util.TypeLits@@ -146,7 +151,7 @@ data EpCallingStep   -- | Wrap into constructor with given name.   = EpsWrapIn Text-  deriving (Show, Eq)+  deriving stock (Show, Eq)  -- | Which entrypoints given parameter declares. --@@ -255,7 +260,7 @@   => ParamNotes (ToT cp) parameterEntryPointsToNotes =   let notes = pepNotes @cp-  in case mkParamNotes notes of+  in case mkParamNotes notes U.noAnn of        -- Normally this should be valid because        -- 1. Constraint in superclass of 'ParameterHasEntryPoints' ensures that        -- no entrypoint is duplicated.
src/Lorentz/EntryPoints/Doc.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Utilities for declaring and documenting entry points. module Lorentz.EntryPoints.Doc   ( DEntryPoint (..)@@ -34,11 +38,10 @@ import Data.Char (toLower) import Data.Constraint (Dict(..)) import qualified Data.Kind as Kind-import Data.Vinyl.Core (RMap, Rec(..), rappend)+import Data.Vinyl.Core (RMap, rappend) import Fmt (Buildable(..), listF) import GHC.Generics ((:+:)) import qualified GHC.Generics as G-import GHC.TypeLits (AppendSymbol, KnownSymbol, symbolVal) import qualified Text.Show  import Lorentz.ADT
src/Lorentz/EntryPoints/Helpers.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Lorentz.EntryPoints.Helpers   ( ctorNameToAnn   , ctorNameToEp@@ -31,7 +35,8 @@ -- explicit wrapper. newtype ShouldHaveEntryPoints a = ShouldHaveEntryPoints { unHasEntryPoints :: a }   deriving stock Generic-  deriving anyclass IsoValue++deriving anyclass instance (WellTypedIsoValue r) => IsoValue (ShouldHaveEntryPoints r)  -- | Used to understand whether a type can potentially declare any entrypoints. type family CanHaveEntryPoints (p :: Kind.Type) :: Bool where
src/Lorentz/EntryPoints/Impl.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Common implementations of entrypoints. module Lorentz.EntryPoints.Impl   ( -- * Ways to implement 'ParameterHasEntryPoints'@@ -12,10 +16,8 @@   ) where  import qualified Data.Kind as Kind-import Data.Singletons (SingI(..))-import Data.Singletons.Prelude (Sing(SFalse, STrue))+import Data.Singletons.Prelude (SBool(SFalse, STrue)) import Data.Singletons.Prelude.Eq ((%==))-import Data.Type.Bool (If) import Data.Vinyl.Core (Rec(..), (<+>)) import Data.Vinyl.Recursive (rmap) import Fcf (Eval, Exp)@@ -25,8 +27,7 @@  import Lorentz.Value import Michelson.Typed-import Michelson.Typed.Haskell.Instr.Sum (IsPrimitiveValue)-import Michelson.Typed.Haskell.Value (GValueType, GenericIsoValue)+import Michelson.Typed.Haskell.Value (GValueType) import Michelson.Untyped (FieldAnn, noAnn) import Util.Fcf (type (<|>), Over2, TyEqSing) import Util.Type@@ -342,9 +343,9 @@ -- Return 'Just' iff given entries of type @k1@ are equal. type family JustOnEq (a :: k1) (b :: k2) :: k1 -> Exp (Maybe k2) where   JustOnEq a b =-    Fcf.Flip Fcf.Guarded-      '[ TyEqSing a 'Fcf.:= Fcf.Pure ('Just b)-       , Fcf.Otherwise 'Fcf.:= Fcf.Pure 'Nothing+    Fcf.Case+      '[ Fcf.Is (TyEqSing a) ('Just b)+       , Fcf.Any 'Nothing        ]  -- Get field type under 'G.C1'.
src/Lorentz/EntryPoints/Manual.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Allows specifying entrypoints without declaring 'ParamterHasEntryPoints' -- instance. module Lorentz.EntryPoints.Manual
src/Lorentz/Errors.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# LANGUAGE TypeFamilyDependencies #-}  -- We want to make sure 'failUsingArg' is used with sane argument.@@ -13,6 +17,7 @@   , customErrorDocHaskellRepGeneral    , UnspecifiedError (..)+  , SomeError (..)      -- * General instructions   , failUsing@@ -45,14 +50,11 @@   ) where  import qualified Data.Char as C-import Data.Constraint (Dict(..)) import qualified Data.Kind as Kind import qualified Data.List as L-import Data.Singletons (SingI(..), demote)-import Data.Type.Equality (type (==))+import Data.Singletons (demote) import Data.Typeable (cast) import Fmt (Buildable, build, fmt, pretty, (+|), (+||), (|+), (||+))-import GHC.TypeLits (ErrorMessage(..), KnownSymbol, Symbol, TypeError, symbolVal) import qualified Language.Haskell.TH as TH import qualified Text.Show @@ -61,13 +63,13 @@ import Lorentz.Instr hiding (cast) import Lorentz.Value import Michelson.Text+import Michelson.Typed.Convert (untypeValue) import Michelson.Typed.Haskell import Michelson.Typed.Instr import Michelson.Typed.Scope import Michelson.Typed.Sing import Michelson.Typed.T import Michelson.Typed.Value-import Util.Label (Label) import Util.Markdown import Util.Type import Util.Typeable@@ -158,6 +160,7 @@       c : s -> c : go s       "" -> "" +---------------------------------------------------------------------------- -- Instances ---------------------------------------------------------------------------- @@ -204,6 +207,18 @@   errorDocHaskellRep = typeDocMdReference (Proxy @()) (WithinParens False) <> "."   errorDocDependencies = typeDocDependencies' (Proxy @()) +-- | Type wrapper for an @IsError@.+data SomeError = forall e. (IsError e, Eq e) => SomeError e++instance Eq SomeError where+  SomeError e1 == SomeError e2 = eqExt e1 e2++instance Buildable SomeError where+  build (SomeError e) = errorToVal e (build . untypeValue)++instance Show SomeError where+  show = pretty+ ---------------------------------------------------------------------------- -- General instructions ----------------------------------------------------------------------------@@ -223,7 +238,7 @@ -- -- Like 'error' in Haskell code, this instruction is for internal errors only. failUnexpected :: MText -> s :-> t-failUnexpected msg = failUsing $ [mt|Internal: |] <> msg+failUnexpected msg = failUsing $ [mt|Unexpected: |] <> msg  ---------------------------------------------------------------------------- -- Custom errors@@ -283,9 +298,13 @@ type CustomErrorRep tag = (MText, ErrorArg tag)  -- | This instance cannot be implemented, use 'IsError' instance instead.-instance TypeError ('Text "CustomError has no IsoValue instance") =>+instance (WellTypedIsoValue (ErrorArg tag), TypeError ('Text "CustomError has no IsoValue instance")) =>          IsoValue (CustomError tag) where-  type ToT (CustomError tag) = TypeError ('Text "CustomError has no IsoValue instance")+  -- Originally we had a `TypeError` here, but that had to be changed when+  -- `WellTyped (ToT a)` was added as a superclass of `IsoValue`, because it+  -- resulted in the type error being triggerred from the evaluation of `ToT`+  -- typefamily in the super class clause.+  type ToT (CustomError tag) = (ToT (MText, ErrorArg tag))   toVal = error "impossible"   fromVal = error "impossible" @@ -625,7 +644,7 @@       -- the event of weird chars occurrence to be quite improbable       let tag' = mkMTextUnsafe tag       in case (opAbsense (sing @t), bigMapAbsense (sing @t), contractTypeAbsense (sing @t)) of-        (Just Dict, Just Dict, Just Dict) -> cont $ VPair (VC (CvString tag'), datVal)+        (Just Dict, Just Dict, Just Dict) -> cont $ VPair (VString tag', datVal)          -- We could check this at type-level, but this would require         -- specializing 'Michelson.Typed.LooseSum' to errors.@@ -644,7 +663,7 @@       (SingI t, LooseSumC e)   => Value t -> Either Text e customErrorFromVal v = case (v, sing @t) of-  (VPair (VC (CvString tag), datVal), STPair _ _) ->+  (VPair (VString tag, datVal), STPair _ _) ->     case fromTaggedVal (toText tag, SomeValue datVal) of       ComposeOk e ->         Right e@@ -673,7 +692,7 @@       errorToVal = customErrorToVal       errorFromVal = customErrorFromVal -    instance CustomErrorNoIsoValue $ty => IsoValue $ty where+    instance (WellTypedIsoValue $ty, CustomErrorNoIsoValue $ty) => IsoValue $ty where       type ToT $ty = CustomErrorNoIsoValue $ty       toVal = error "impossible"       fromVal = error "impossible"
src/Lorentz/Errors/Common.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# OPTIONS_GHC -Wno-orphans #-}  -- | Some common errors.
src/Lorentz/Errors/Numeric.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Lorentz.Errors.Numeric   ( module Exports   ) where
src/Lorentz/Errors/Numeric/Contract.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | By default we represent error tags using strings. This module -- makes it possible to use numbers instead. It introduces new [error format]. --@@ -29,7 +33,6 @@ import qualified Data.Bimap as Bimap import Data.Default (def) import qualified Data.HashSet as HS-import Data.Singletons (SingI, sing) import Fmt (pretty)  import Lorentz.Base@@ -139,14 +142,14 @@     tagToNatValue :: HasCallStack => MText -> SomeConstrainedValue ConstantScope'     tagToNatValue tag =       case (HS.member tag exclusions, Bimap.lookupR tag errorTagMap) of-        (True, _) -> SomeConstrainedValue (VC $ CvString tag)+        (True, _) -> SomeConstrainedValue (VString tag)         -- It will be applied to textual tags detected by 'modifyTypicalFailWith'.         -- Here we assume that all of them are discovered by the analyzer.         -- If this error ever happens, it means that someone used         -- 'applyErrorTagMap' with incomplete 'ErrorTagMap' or there is an         -- internal bug somewhere.         (False, Nothing) -> error $ "Can't find a tag: " <> pretty tag-        (False, Just n) -> SomeConstrainedValue (VC $ CvNat n)+        (False, Just n) -> SomeConstrainedValue (VNat n)      step :: HasCallStack => Instr inp out -> Instr inp out     step = modifyTypicalFailWith tagToNatValue@@ -162,13 +165,13 @@   (Typeable t, SingI t, IsError e) => ErrorTagMap -> Value t -> Either Text e errorFromValNumeric errorTagMap v =   case v of-    VC (CvNat tag)+    VNat tag       | Just textualTag <- Bimap.lookup tag errorTagMap ->-        errorFromVal . VC . CvString $ textualTag-    VPair (VC (CvNat tag), something)+        errorFromVal $ VString textualTag+    VPair (VNat tag, something)       | Just textualTag <- Bimap.lookup tag errorTagMap       , _ :: Value pair <- v ->         case sing @pair of           STPair {} ->-            errorFromVal $ VPair (VC $ CvString textualTag, something)+            errorFromVal $ VPair (VString textualTag, something)     _ -> errorFromVal v
src/Lorentz/Errors/Numeric/Doc.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Autodoc for numeric errors. module Lorentz.Errors.Numeric.Doc   ( DDescribeErrorTagMap (..)@@ -15,12 +19,10 @@  import Control.Monad.Cont (callCC, runCont) import qualified Data.Bimap as Bimap-import Data.Constraint (Dict(..)) import qualified Data.Kind as Kind-import Data.Typeable ((:~:)(..), eqT) import Data.Typeable (typeRep) import Fmt (build, pretty)-import GHC.TypeNats (KnownNat, Nat, natVal, someNatVal)+import GHC.TypeNats (Nat)  import Lorentz.Base import Lorentz.Doc@@ -36,7 +38,8 @@ data DDescribeErrorTagMap = DDescribeErrorTagMap   { detmSrcLoc :: Text     -- ^ Describes where the error tag map is defined in Haskell code.-  } deriving (Eq, Ord)+  }+  deriving stock (Eq, Ord)  instance DocItem DDescribeErrorTagMap where   type DocItemPosition DDescribeErrorTagMap = 4090
src/Lorentz/Ext.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Lorentz.Ext   ( stackRef   , printComment
src/Lorentz/Extensible.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {- | This module contains implementation of 'Extensible' values.  @Extensible@ values are an alternative representation of sum-types@@ -54,20 +58,18 @@ import Data.Char (isSpace) import qualified Data.Kind as Kind import qualified Data.Text as T-import Data.Typeable (Proxy(..))-import Data.Vinyl.TypeLevel (type (++)) import Fmt (Buildable(build), (+||), (|+), (||+)) import GHC.Generics ((:+:)(..)) import qualified GHC.Generics as G-import GHC.TypeLits (AppendSymbol, Nat, Symbol)+import GHC.TypeLits (Nat) import GHC.TypeNats (type (+))  import Lorentz.Base import Lorentz.Coercions import Lorentz.Constraints-import Lorentz.TypeAnns import Lorentz.Instr import Lorentz.Pack+import Lorentz.TypeAnns import Michelson.Typed import Util.Label (Label) import Util.Markdown
src/Lorentz/Instr.hs view
@@ -1,5 +1,13 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Lorentz.Instr   ( nop+  , justComment+  , comment+  , commentAroundFun+  , commentAroundStmt   , drop   , dropN   , dup@@ -88,7 +96,6 @@   , sha512   , blake2B   , hashKey-  , stepsToQuota   , source   , sender   , address@@ -101,7 +108,7 @@ import Prelude hiding   (EQ, GT, LT, abs, and, compare, concat, drop, get, map, not, or, some, swap, xor) -import Data.Constraint (Dict(..), (\\))+import Data.Constraint ((\\)) import qualified Data.Kind as Kind import Data.Singletons (SingI, sing) import qualified GHC.TypeNats as GHC (Nat)@@ -112,13 +119,13 @@ import Lorentz.Constraints import Lorentz.EntryPoints import Lorentz.Polymorphic-import Lorentz.Run (compileLorentzContract)+import Lorentz.Run (Contract, compileLorentzContract) import Lorentz.Value import Lorentz.Zip import Michelson.Typed-  (pattern CAR, pattern CDR, ConstraintDIG, ConstraintDIG', ConstraintDIPN, ConstraintDIPN',-  ConstraintDUG, ConstraintDUG', pattern DefEpName, EntryPointCallT(..), Instr(..), RemFail(..),-  SomeEntryPointCallT(..), ToTs, Value'(..), sepcName, starNotes)+  (pattern CAR, pattern CDR, CommentType(..), ConstraintDIG, ConstraintDIG', ConstraintDIPN,+  ConstraintDIPN', ConstraintDUG, ConstraintDUG', EntryPointCallT(..), ExtInstr(..), Instr(..),+  RemFail(..), SomeEntryPointCallT(..), Value'(..), sepcName, starNotes) import Michelson.Typed.Arith import Michelson.Typed.Haskell.Value import Util.Peano@@ -127,6 +134,26 @@ nop :: s :-> s nop = I Nop ++justComment :: Text -> s :-> s+justComment = comment . JustComment++comment :: CommentType -> s :-> s+comment = I . Ext . COMMENT_ITEM++commentAroundFun :: Text -> (i :-> o) -> (i :-> o)+commentAroundFun funName funBody =+  comment (FunctionStarts funName) #+  funBody #+  comment (FunctionEnds funName)++commentAroundStmt :: Text -> (i :-> o) -> (i :-> o)+commentAroundStmt stmtName stmtBody =+  comment (StatementStarts stmtName) #+  stmtBody #+  comment (StatementEnds stmtName)++ drop :: a & s :-> s drop = I DROP @@ -250,14 +277,14 @@ size :: SizeOpHs c => c & s :-> Natural & s size = I SIZE -emptySet :: (KnownCValue e) => s :-> Set e & s+emptySet :: (NiceComparable e) => s :-> Set e & s emptySet = I EMPTY_SET -emptyMap :: (KnownCValue k, KnownValue v)+emptyMap :: (NiceComparable k, KnownValue v)          => s :-> Map k v & s emptyMap = I EMPTY_MAP -emptyBigMap :: (KnownCValue k, KnownValue v)+emptyBigMap :: (NiceComparable k, KnownValue v)             => s :-> BigMap k v & s emptyBigMap = I EMPTY_BIG_MAP @@ -446,8 +473,7 @@ not :: UnaryArithOpHs Not n => n & s :-> UnaryArithResHs Not n & s not = I NOT -compare :: NiceComparable n-        => n & n & s :-> Integer & s+compare :: NiceComparable n => n & n & s :-> Integer & s compare = I COMPARE  eq0 :: UnaryArithOpHs Eq' n => n & s :-> UnaryArithResHs Eq' n & s@@ -577,7 +603,7 @@  createContract   :: forall p g s. (NiceStorage g, NiceParameterFull p)-  => ContractCode p g+  => Contract p g   -> Maybe KeyHash & Mutez & g & s   :-> Operation & Address & s createContract cntrc =@@ -611,10 +637,6 @@  hashKey :: PublicKey & s :-> KeyHash & s hashKey = I HASH_KEY--{-# WARNING stepsToQuota "STEPS_TO_QUOTA instruction is deprecated in Michelson 005" #-}-stepsToQuota :: s :-> Natural & s-stepsToQuota = I STEPS_TO_QUOTA  {-# WARNING source     "Using `source` is considered a bad practice.\n\
src/Lorentz/Macro.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# LANGUAGE PartialTypeSignatures #-} {-# OPTIONS_GHC -Wno-redundant-constraints #-} @@ -99,6 +103,8 @@   , unwrapView   , void_   , mkVoid+  , wrapVoid+  , unwrapVoid   , voidResultTag    -- * Buildable utils for additional Morley macros@@ -116,7 +122,6 @@  import qualified Data.Kind as Kind import Data.Singletons (SingI(..))-import Data.Vinyl.TypeLevel (Nat(..)) import Fmt (Buildable(..), Builder, pretty, tupleF, (+|), (|+)) import Fmt.Internal.Tuple (TupleF) import GHC.TypeNats (type (-))@@ -126,14 +131,13 @@ import Lorentz.Base import Lorentz.Coercions import Lorentz.Constraints-import Lorentz.TypeAnns import Lorentz.Doc import Lorentz.Errors import Lorentz.Ext (stackType) import Lorentz.Instr+import Lorentz.TypeAnns import Lorentz.Value-import Michelson.Typed-  (ConstraintDIG', ConstraintDIPN', ConstraintDUG', T, typeDocDependencies')+import Michelson.Typed (ConstraintDIG', ConstraintDIPN', ConstraintDUG', T, typeDocDependencies') import Michelson.Typed.Arith import Michelson.Typed.Haskell.Value import Util.Markdown@@ -169,7 +173,7 @@ lt = compare # lt0  type IfCmp0Constraints a op =-  (UnaryArithOpHs op a, (UnaryArithResHs op a ~ Bool), SingI (ToCT a))+  (UnaryArithOpHs op a, (UnaryArithResHs op a ~ Bool), SingI (ToT a))  ifEq0   :: (IfCmp0Constraints a Eq')@@ -202,32 +206,32 @@ ifGe0 l r = ge0 # if_ l r  ifEq-  :: (NiceComparable a)+  :: NiceComparable a   => (s :-> s') -> (s :-> s') -> (a & a & s :-> s') ifEq l r = eq # if_ l r  ifNeq-  :: (NiceComparable a)+  :: NiceComparable a   => (s :-> s') -> (s :-> s') -> (a & a & s :-> s') ifNeq l r = neq # if_ l r  ifLt-  :: (NiceComparable a)+  :: NiceComparable a   => (s :-> s') -> (s :-> s') -> (a & a & s :-> s') ifLt l r = lt # if_ l r  ifGt-  :: (NiceComparable a)+  :: NiceComparable a   => (s :-> s') -> (s :-> s') -> (a & a & s :-> s') ifGt l r = gt # if_ l r  ifLe-  :: (NiceComparable a)+  :: NiceComparable a   => (s :-> s') -> (s :-> s') -> (a & a & s :-> s') ifLe l r = le # if_ l r  ifGe-  :: (NiceComparable a)+  :: NiceComparable a   => (s :-> s') -> (s :-> s') -> (a & a & s :-> s') ifGe l r = ge # if_ l r @@ -465,10 +469,10 @@ -- | Various convenient instructions on maps. class MapInstrs map where   -- | Specialized version of 'update'.-  mapUpdate :: IsComparable k => k : Maybe v : map k v : s :-> map k v : s+  mapUpdate :: NiceComparable k => k : Maybe v : map k v : s :-> map k v : s    -- | Insert given element into map.-  mapInsert :: IsComparable k => k : v : map k v : s :-> map k v : s+  mapInsert :: NiceComparable k => k : v : map k v : s :-> map k v : s   mapInsert = dip some # mapUpdate    -- | Insert given element into map, ensuring that it does not overwrite@@ -476,13 +480,13 @@   --   -- As first argument accepts container name (for error message).   mapInsertNew-    :: (IsComparable k, KnownValue e)+    :: (NiceComparable k, KnownValue e)     => (forall s0. k : s0 :-> e : s0)     -> k : v : map k v : s :-> map k v : s    -- | Delete element from the map.   deleteMap-    :: forall k v s. (IsComparable k, KnownValue k, KnownValue v)+    :: forall k v s. (NiceComparable k, KnownValue v)     => k : map k v : s :-> map k v : s   deleteMap = dip (none @v) # mapUpdate @@ -497,7 +501,7 @@ -- -- This is a separate function from 'updateMap' because stacks they operate with -- differ in length.-setInsert :: IsComparable e => e & Set e & s :-> Set e & s+setInsert :: NiceComparable e => e & Set e & s :-> Set e & s setInsert = dip (push True) # update  -- | Insert given element into set, ensuring that it does not overwrite@@ -505,13 +509,13 @@ -- -- As first argument accepts container name. setInsertNew-  :: (IsComparable e, KnownValue err)+  :: (NiceComparable e, KnownValue err)   => (forall s0. e : s0 :-> err : s0)   -> e & Set e & s :-> Set e & s setInsertNew desc = dip (push True) # failingWhenPresent desc # update  -- | Delete given element from the set.-setDelete :: IsComparable e => e & Set e & s :-> Set e & s+setDelete :: NiceComparable e => e & Set e & s :-> Set e & s setDelete = dip (push False) # update  -- | Kind-agnostic constraint for replaceN@@ -629,8 +633,10 @@   { viewParam :: a   , viewCallbackTo :: ContractRef r   } deriving stock (Eq, Show, Generic)-    deriving anyclass (IsoValue, HasTypeAnn)+    deriving anyclass (HasTypeAnn) +deriving anyclass instance (WellTypedIsoValue r, WellTypedIsoValue a) => IsoValue (View a r)+ instance (CanCastTo a1 a2, CanCastTo r1 r2) => CanCastTo (View a1 r1) (View a2 r2)  instance Each [Typeable, TypeHasDoc] [a, r] => TypeHasDoc (View a r) where@@ -647,16 +653,16 @@   typeDocMichelsonRep =     concreteTypeDocMichelsonRep @(View () Integer) -instance {-# OVERLAPPABLE #-} Buildable a => Buildable (View a r) where+instance {-# OVERLAPPABLE #-} (Buildable a, WellTypedIsoValue r) => Buildable (View a r) where   build = buildView build -instance {-# OVERLAPPING  #-} Buildable (View () r) where+instance {-# OVERLAPPING  #-} (WellTypedIsoValue r) => Buildable (View () r) where   build = buildView $ const "()" -buildViewTuple :: TupleF a => View a r -> Builder+buildViewTuple :: (WellTypedIsoValue r, TupleF a) => View a r -> Builder buildViewTuple = buildView tupleF -buildView :: (a -> Builder) -> View a r -> Builder+buildView :: (WellTypedIsoValue r) => (a -> Builder) -> View a r -> Builder buildView bfp (View {..}) =   "(View param: " +| bfp viewParam |+ " callbackTo: " +| viewCallbackTo|+ ")" @@ -692,8 +698,10 @@   , voidResProxy :: Lambda b b     -- ^ Type of result reported via 'failWith'.   } deriving stock (Generic, Show)-    deriving anyclass (IsoValue, HasTypeAnn)+    deriving anyclass (HasTypeAnn) +deriving anyclass instance (WellTypedIsoValue r, WellTypedIsoValue a) => IsoValue (Void_ a r)+ instance (CanCastTo a1 a2, CanCastTo r1 r2) => CanCastTo (Void_ a1 r1) (Void_ a2 r2)  instance Each [Typeable, TypeHasDoc] [a, r] => TypeHasDoc (Void_ a r) where@@ -715,8 +723,8 @@   typeDocDependencies p =     genericTypeDocDependencies p <>     [SomeTypeWithDoc (Proxy @()), SomeTypeWithDoc (Proxy @Integer)]-  typeDocHaskellRep p = do-    (_, rhs) <- haskellRepNoFields (concreteTypeDocHaskellRep @(Void_ () Integer)) p+  typeDocHaskellRep p descr = do+    (_, rhs) <- haskellRepNoFields (concreteTypeDocHaskellRep @(Void_ () Integer)) p descr     return (Just "Void () Integer", rhs)   typeDocMichelsonRep p =     let (_, rhs) = concreteTypeDocMichelsonRep @(Void_ () Integer) p@@ -771,7 +779,7 @@   errorDocDependencies =     typeDocDependencies' (Proxy @MText) <> typeDocDependencies' (Proxy @r) -instance CustomErrorNoIsoValue (VoidResult r) => IsoValue (VoidResult r) where+instance (WellTypedIsoValue (VoidResult r), CustomErrorNoIsoValue (VoidResult r)) => IsoValue (VoidResult r) where   type ToT (VoidResult r) = CustomErrorNoIsoValue (VoidResult r)   toVal = error "impossible"   fromVal = error "impossible"@@ -788,6 +796,18 @@   forcedCoerce_ @_ @(_, Lambda b b) #   unpair # swap # dip code # swap # exec #   push voidResultTag # pair # failWith @(MText, b)++-- | Wrap internal representation of void into 'Void_' itself.+--+-- 'Void_' is part of public standard and should not change often.+wrapVoid :: (a, Lambda b b) : s :-> Void_ a b : s+wrapVoid = forcedCoerce_++-- | Unwrap 'Void_' into its internal representation.+--+-- 'Void_' is part of public standard and should not change often.+unwrapVoid :: Void_ a b : s :-> (a, Lambda b b) : s+unwrapVoid = forcedCoerce_  addressToEpAddress :: Address : s :-> EpAddress : s addressToEpAddress = forcedCoerce_
src/Lorentz/Pack.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Packing utilities. module Lorentz.Pack   ( lPackValue
src/Lorentz/Polymorphic.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# LANGUAGE QuantifiedConstraints #-}  -- | Type families from 'Michelson.Typed.Polymorphic' lifted to Haskell types.@@ -17,6 +21,7 @@  import qualified Data.Kind as Kind +import Lorentz.Constraints.Scopes (NiceComparable) import Michelson.Text import Michelson.Typed import Tezos.Core (Mutez)@@ -27,17 +32,17 @@  -- | Lifted 'MemOpKey'. class ( MemOp (ToT c)-      , ToT (MemOpKeyHs c) ~ 'Tc (MemOpKey (ToT c))+      , ToT (MemOpKeyHs c) ~ MemOpKey (ToT c)       ) => MemOpHs c where   type MemOpKeyHs c :: Kind.Type -instance IsComparable e => MemOpHs (Set e) where+instance NiceComparable e => MemOpHs (Set e) where   type MemOpKeyHs (Set e) = e -instance IsComparable k => MemOpHs (Map k v) where+instance NiceComparable k => MemOpHs (Map k v) where   type MemOpKeyHs (Map k v) = k -instance IsComparable k => MemOpHs (BigMap k v) where+instance NiceComparable k => MemOpHs (BigMap k v) where   type MemOpKeyHs (BigMap k v) = k  -- | A useful property which holds for reasonable 'MapOp' instances.@@ -54,7 +59,7 @@   type MapOpInpHs c :: Kind.Type   type MapOpResHs c :: Kind.Type -> Kind.Type -instance IsComparable k => MapOpHs (Map k v) where+instance NiceComparable k => MapOpHs (Map k v) where   type MapOpInpHs (Map k v) = (k, v)   type MapOpResHs (Map k v) = Map k @@ -68,13 +73,13 @@       ) => IterOpHs c where   type IterOpElHs c :: Kind.Type -instance IsComparable k => IterOpHs (Map k v) where+instance NiceComparable k => IterOpHs (Map k v) where   type IterOpElHs (Map k v) = (k, v)  instance IterOpHs [e] where   type IterOpElHs [e] = e -instance IsComparable e => IterOpHs (Set e) where+instance NiceComparable e => IterOpHs (Set e) where   type IterOpElHs (Set e) = e  -- | Lifted 'SizeOp'.@@ -91,37 +96,37 @@  -- | Lifted 'UpdOp'. class ( UpdOp (ToT c)-      , ToT (UpdOpKeyHs c) ~ 'Tc (UpdOpKey (ToT c))+      , ToT (UpdOpKeyHs c) ~ (UpdOpKey (ToT c))       , ToT (UpdOpParamsHs c) ~ UpdOpParams (ToT c)       ) => UpdOpHs c where   type UpdOpKeyHs c :: Kind.Type   type UpdOpParamsHs c :: Kind.Type -instance IsComparable k => UpdOpHs (Map k v) where+instance NiceComparable k => UpdOpHs (Map k v) where   type UpdOpKeyHs (Map k v) = k   type UpdOpParamsHs (Map k v) = Maybe v -instance IsComparable k => UpdOpHs (BigMap k v) where+instance NiceComparable k => UpdOpHs (BigMap k v) where   type UpdOpKeyHs (BigMap k v) = k   type UpdOpParamsHs (BigMap k v) = Maybe v -instance IsComparable a => UpdOpHs (Set a) where+instance NiceComparable a => UpdOpHs (Set a) where   type UpdOpKeyHs (Set a) = a   type UpdOpParamsHs (Set a) = Bool  -- | Lifted 'GetOp'. class ( GetOp (ToT c)-      , ToT (GetOpKeyHs c) ~ 'Tc (GetOpKey (ToT c))+      , ToT (GetOpKeyHs c) ~ (GetOpKey (ToT c))       , ToT (GetOpValHs c) ~ GetOpVal (ToT c)       ) => GetOpHs c where   type GetOpKeyHs c :: Kind.Type   type GetOpValHs c :: Kind.Type -instance IsComparable k => GetOpHs (Map k v) where+instance NiceComparable k => GetOpHs (Map k v) where   type GetOpKeyHs (Map k v) = k   type GetOpValHs (Map k v) = v -instance IsComparable k => GetOpHs (BigMap k v) where+instance NiceComparable k => GetOpHs (BigMap k v) where   type GetOpKeyHs (BigMap k v) = k   type GetOpValHs (BigMap k v) = v @@ -138,10 +143,10 @@ instance SliceOpHs ByteString  -- | Lifted 'EDivOp'.-class ( EDivOp (ToCT n) (ToCT m)-      , IsComparable n, IsComparable m-      , ToT (EDivOpResHs n m) ~ 'Tc (EDivOpRes (ToCT n) (ToCT m))-      , ToT (EModOpResHs n m) ~ 'Tc (EModOpRes (ToCT n) (ToCT m))+class ( EDivOp (ToT n) (ToT m)+      , NiceComparable n, NiceComparable m+      , ToT (EDivOpResHs n m) ~ EDivOpRes (ToT n) (ToT m)+      , ToT (EModOpResHs n m) ~ EModOpRes (ToT n) (ToT m)       ) => EDivOpHs n m where   type EDivOpResHs n m :: Kind.Type   type EModOpResHs n m :: Kind.Type
src/Lorentz/Prelude.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Commonly used parts of regular Prelude. module Lorentz.Prelude   ( ($)
src/Lorentz/Print.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# OPTIONS_GHC -Wno-redundant-constraints #-}  -- | Printing lorentz contracts.@@ -6,11 +10,9 @@   , printLorentzContract   ) where --import Lorentz.Base import Lorentz.Constraints import Lorentz.Run-import Michelson.Printer (printTypedFullContract, printTypedValue)+import Michelson.Printer (printTypedContract, printTypedValue) import Michelson.Typed (toVal)  -- | Pretty-print a Haskell value as Michelson one.@@ -26,6 +28,6 @@ printLorentzContract   :: forall cp st.      (NiceParameterFull cp, NiceStorage st)-  => Bool -> ContractCode cp st -> LText+  => Bool -> Contract cp st -> LText printLorentzContract forceSingleLine =-  printTypedFullContract forceSingleLine . compileLorentzContract+  printTypedContract forceSingleLine . compileLorentzContract
src/Lorentz/Rebinded.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {- | Reimplementation of some syntax sugar.  You need the following module pragmas to make it work smoothly:
src/Lorentz/Referenced.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# LANGUAGE FunctionalDependencies #-}  -- | Referenced-by-type versions of some instructions.@@ -22,7 +26,6 @@ import Prelude hiding (drop, swap)  import qualified Data.Kind as Kind-import Data.Type.Bool (If) import GHC.TypeLits (ErrorMessage(..), TypeError)  import Lorentz.Base
src/Lorentz/Run.hs view
@@ -1,15 +1,26 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Lorentz.Run   ( CompilationOptions(..)   , defaultCompilationOptions+   , compileLorentz+  , compileLorentzWithOptions++  , Contract(..)+  , defaultContract   , compileLorentzContract-  , compileLorentzContractWithOptions+   , interpretLorentzInstr   , interpretLorentzLambda+   , analyzeLorentz   ) where  import Data.Constraint ((\\))+import Data.Default (def) import Data.Vinyl.Core (Rec(..))  import Lorentz.Base@@ -17,60 +28,98 @@ import Lorentz.EntryPoints import Michelson.Analyzer (AnalyzerRes, analyze) import Michelson.Interpret+import Michelson.Optimizer (OptimizerConf, optimizeWithConf)+import Michelson.Text (MText) import Michelson.Typed-  (FullContract(..), Instr(..), IsoValue, IsoValuesStack(..), ParamNotes(..), ToT, ToTs, isStar,-  starNotes, unParamNotes)+  (Instr(..), IsoValue, IsoValuesStack(..), ToT, ToTs, starNotes, starParamNotes)+import qualified Michelson.Typed as M (Contract(..)) --- | For use outside of Lorentz.+-- | Options to control Lorentz to Michelson compilation.+data CompilationOptions = CompilationOptions+  { coOptimizerConf :: Maybe OptimizerConf+  -- ^ Config for Michelson optimizer.+  , coStringTransformer :: (Bool, MText -> MText)+  -- ^ Function to transform strings with. See 'transformStringsLorentz'.+  , coBytesTransformer :: (Bool, ByteString -> ByteString)+  -- ^ Function to transform byte strings with. See 'transformBytesLorentz'.+  }++-- | Runs Michelson optimizer with default config and does not touch strings and bytes.+defaultCompilationOptions :: CompilationOptions+defaultCompilationOptions = CompilationOptions+  { coOptimizerConf = Just def+  , coStringTransformer = (False, id)+  , coBytesTransformer = (False, id)+  }++-- | For use outside of Lorentz. Will use 'defaultCompilationOptions'. compileLorentz :: (inp :-> out) -> Instr (ToTs inp) (ToTs out)-compileLorentz = iAnyCode+compileLorentz = compileLorentzWithOptions defaultCompilationOptions --- | Version of 'compileLorentz' specialized to instruction corresponding to--- contract code.-compileLorentzContract-  :: forall cp st.-     (NiceParameterFull cp, NiceStorage st)-  => ContractCode cp st -> FullContract (ToT cp) (ToT st)-compileLorentzContract =-  compileLorentzContractWithOptions defaultCompilationOptions+-- | Compile Lorentz code, optionally running the optimizer, string and byte transformers.+compileLorentzWithOptions :: CompilationOptions -> (inp :-> out) -> Instr (ToTs inp) (ToTs out)+compileLorentzWithOptions CompilationOptions{..} =+  maybe id optimizeWithConf coOptimizerConf+  . iAnyCode+  . uncurry transformStringsLorentz coStringTransformer+  . uncurry transformBytesLorentz coBytesTransformer -data CompilationOptions = CompilationOptions-  { coDisableInitialCast :: Bool-  -- ^ Flag which defines, whether compiled Michelson contract+-- | Code for a contract along with compilation options for the Lorentz compiler.+--+-- It is expected that a 'Contract' is one packaged entity, wholly controlled by its author.+-- Therefore the author should be able to set all options that control contract's behavior.+--+-- This helps ensure that a given contract will be interpreted in the same way in all+-- environments, like production and testing.+--+-- Raw 'ContractCode' should not be used for distribution of contracts.+data Contract cp st = Contract+  { cCode :: ContractCode cp st+    -- ^ The contract itself.+  , cDisableInitialCast :: Bool+  -- ^ Flag which defines whether compiled Michelson contract   -- will have @CAST@ (which drops parameter annotations)-  -- as a first instruction. Note, that when-  -- flag is false, there still can be no @CAST@ (in case+  -- as a first instruction. Note that when+  -- flag is false, there still may be no @CAST@ (in case   -- when parameter type has no annotations).+  , cCompilationOptions :: CompilationOptions+  -- ^ General compilation options for the Lorentz compiler.   } -defaultCompilationOptions :: CompilationOptions-defaultCompilationOptions = CompilationOptions { coDisableInitialCast = False }+-- | Compile contract with 'defaultCompilationOptions' and 'cDisableInitialCast' set to @False@.+defaultContract :: ContractCode cp st -> Contract cp st+defaultContract code = Contract+  { cCode = code+  , cDisableInitialCast = False+  , cCompilationOptions = defaultCompilationOptions+  } --- | Version on 'compileLorentzContract' which accepts @CompilationOptions@.+-- | Compile a whole contract to Michelson. -- -- Note that compiled contract can be ill-typed in terms of Michelson code--- when some of the compilation options are used (e.g. when coDoInitialCast--- is False, resulted contract can be ill-typed).--- However, compilation with @defaultCompilationOptions@ should be valid.-compileLorentzContractWithOptions+-- when some of the compilation options are used (e.g. when 'ccoDisableInitialCast'+-- is @True@, resulted contract can be ill-typed).+-- However, compilation with 'defaultContractCompilationOptions' should be valid.+compileLorentzContract   :: forall cp st.      (NiceParameterFull cp, NiceStorage st)-  => CompilationOptions -> ContractCode cp st -> FullContract (ToT cp) (ToT st)-compileLorentzContractWithOptions CompilationOptions{..} contract =-  FullContract-  { fcCode = if (isStar (unParamNotes cpNotes) || coDisableInitialCast)+  => Contract cp st -> M.Contract (ToT cp) (ToT st)+compileLorentzContract Contract{..} =+  M.Contract+  { cCode = if (cpNotes == starParamNotes || cDisableInitialCast)       then -- If contract parameter type has no annotations or explicitly asked, we drop CAST.-        compileLorentz contract+        compileLorentzWithOptions cCompilationOptions cCode       else -- Perform CAST otherwise.-        compileLorentz (I CAST # contract :: ContractCode cp st)-  , fcParamNotesSafe = cpNotes-  , fcStoreNotes = starNotes+        compileLorentzWithOptions cCompilationOptions (I CAST # cCode :: ContractCode cp st)+  , cParamNotes = cpNotes+  , cStoreNotes = starNotes   } \\ niceParameterEvi @cp     \\ niceStorageEvi @st   where     cpNotes = parameterEntryPointsToNotes @cp --- | Interpret a Lorentz instruction, for test purposes.+-- | Interpret a Lorentz instruction, for test purposes. Note that this does not run the+-- optimizer. interpretLorentzInstr   :: (IsoValuesStack inp, IsoValuesStack out)   => ContractEnv
src/Lorentz/Store.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# OPTIONS_GHC -Wno-redundant-constraints #-}  -- | Impementation of @Store@ - object incapsulating multiple 'BigMap's.@@ -68,7 +72,6 @@   , StorePieceC   ) where -import Data.Constraint (Dict(..)) import Data.Default (Default) import qualified Data.Kind as Kind import qualified Data.Map as Map@@ -442,7 +445,7 @@ -- newtypes. newtype MyNatural = MyNatural Natural   deriving stock Generic-  deriving newtype (IsoCValue, IsoValue)+  deriving newtype (IsoValue)  data MyStoreTemplate3 = MyStoreTemplate3 (Natural |-> MyNatural)   deriving stock Generic@@ -509,7 +512,9 @@   { sMap :: Store storeTemplate   , sFields :: other   } deriving stock (Eq, Show, Generic)-    deriving anyclass (Default, IsoValue)+    deriving anyclass Default++deriving anyclass instance (WellTypedIsoValue st, WellTypedIsoValue o) => IsoValue (StorageSkeleton st o)  -- | Unpack 'StorageSkeleton' into a pair. storageUnpack :: StorageSkeleton store fields : s :-> (Store store, fields) : s
src/Lorentz/StoreClass.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# LANGUAGE FunctionalDependencies #-}  -- | This module provides storage interfaces.@@ -39,8 +43,6 @@ import qualified Lorentz.Instr as L import qualified Lorentz.Macro as L import Lorentz.Value-import Michelson.Typed.Haskell-import Util.Label (Label)  ---------------------------------------------------------------------------- -- Fields@@ -172,7 +174,7 @@  -- | 'BigMap' can be used as standalone key-value storage, -- name of submap is not accounted in this case.-instance (key ~ key', value ~ value', IsComparable key) =>+instance (key ~ key', value ~ value', NiceComparable key) =>          StoreHasSubmap (BigMap key' value') name key value where   storeSubmapOps = StoreSubmapOps     { sopMem = \_label -> L.mem@@ -183,7 +185,7 @@     }  -- | 'Map' can be used as standalone key-value storage if very needed.-instance (key ~ key', value ~ value', IsComparable key) =>+instance (key ~ key', value ~ value', NiceComparable key) =>          StoreHasSubmap (Map key' value') name key value where   storeSubmapOps = StoreSubmapOps     { sopMem = \_label -> L.mem
src/Lorentz/Test.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Lorentz.Test   ( -- * Importing a contract     specWithContract
src/Lorentz/Test/Consumer.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Contract which remembers all parameters it has been called with. -- -- Useful to save return values of @View@ entry points.@@ -8,7 +12,9 @@ import Lorentz.Base import Lorentz.Instr import Lorentz.Macro+import Lorentz.Run  -- | Remembers parameters it was called with, last goes first.-contractConsumer :: ContractCode cp [cp]-contractConsumer = unpair # cons # nil # pair+contractConsumer :: Contract cp [cp]+contractConsumer = defaultContract $+  unpair # cons # nil # pair
src/Lorentz/Test/Doc.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Testing predicates for documentation of Lorentz contracts. module Lorentz.Test.Doc   ( -- * Test predicates
src/Lorentz/Test/Integrational.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Mirrors 'Michelson.Test.Integrational' module in a Lorentz way. module Lorentz.Test.Integrational   (@@ -70,13 +74,11 @@   ) where  import Data.Constraint (Dict(..))-import Data.Default (Default(..)) import Data.Singletons (SingI) import Data.Typeable (gcast) import Fmt (Buildable, listF, (+|), (|+)) import Named ((:!), arg) -import qualified Lorentz.Base as L import Lorentz.Constraints import Lorentz.EntryPoints import qualified Lorentz.Errors as L@@ -93,7 +95,6 @@ import qualified Michelson.Typed as T import qualified Michelson.Untyped as U import Tezos.Core-import Util.Label (Label) import Util.Named ((.!))  ----------------------------------------------------------------------------@@ -110,7 +111,7 @@ lOriginate   :: forall cp st.      (NiceParameterFull cp, NiceStorage st)-  => L.ContractCode cp st+  => Contract cp st   -> Text   -> st   -> Mutez@@ -124,7 +125,7 @@ -- | Originate a contract with empty balance and default storage. lOriginateEmpty   :: (NiceParameterFull cp, NiceStorage st, Default st)-  => L.ContractCode cp st+  => Contract cp st   -> Text   -> IntegrationalScenarioM (TAddress cp) lOriginateEmpty contract name = lOriginate contract name def (unsafeMkMutez 0)
src/Lorentz/Test/Unit.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Unit tests for Lorentz. module Lorentz.Test.Unit     ( expectContractEntrypoints@@ -7,7 +11,7 @@  import Lorentz hiding (contract) import Michelson.Test.Unit (matchContractEntryPoints)-import Michelson.Typed (convertFullContract, flattenEntryPoints)+import Michelson.Typed (convertContract, flattenEntryPoints)  -- | Expect the given contract to have some specific entrypoints. expectContractEntrypoints@@ -16,13 +20,13 @@      , NiceParameterFull contractEps      , NiceStorage st      )-  => ContractCode contractEps st -> Assertion+  => Contract contractEps st -> Assertion expectContractEntrypoints contract =   withDict (niceParameterEvi @expectedEps) $   withDict (niceParameterEvi @contractEps) $   withDict (niceStorageEvi @st) $ do     let entrypoints = flattenEntryPoints $ parameterEntryPointsToNotes @expectedEps-        contract' = convertFullContract . compileLorentzContract $ contract+        contract' = convertContract . compileLorentzContract $ contract     case matchContractEntryPoints contract' entrypoints of       Left eps -> assertFailure $ "Some entrypoints were not found " <> show eps       Right _ -> pass
src/Lorentz/TestScenario.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Lorentz.TestScenario   {-# DEPRECATED "Use morley-nettest instead" #-}   ( TestScenario
src/Lorentz/TypeAnns.hs view
@@ -1,9 +1,14 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# LANGUAGE UndecidableSuperClasses #-}  -- | Type annotations for Lorentz types. module Lorentz.TypeAnns   ( HasTypeAnn (..)   , GHasTypeAnn (..)+  , insertTypeAnn   ) where  import Data.Singletons (SingI)@@ -12,7 +17,7 @@  import Michelson.Text import Michelson.Typed-  (BigMap, ContractRef(..), EpAddress, Notes(..), Operation, T(..), ToCT, ToT, starNotes)+  (BigMap, ContractRef(..), EpAddress, Notes(..), Operation, ToT, insertTypeAnn, starNotes) import Michelson.Typed.Haskell.Value (GValueType) import Michelson.Untyped (TypeAnn, ann, noAnn) import Tezos.Address@@ -36,28 +41,10 @@  instance (HasTypeAnn a, KnownSymbol name)   => HasTypeAnn (NamedF Identity a name) where-  getTypeAnn = insertNote (symbolAnn @name) $ getTypeAnn @a+  getTypeAnn = insertTypeAnn (symbolAnn @name) $ getTypeAnn @a     where       symbolAnn :: forall s. KnownSymbol s => TypeAnn       symbolAnn = ann $ symbolValT' @s-      -- Insert the provided type annotation into the provided note.-      insertNote :: forall (b :: T). TypeAnn -> Notes b -> Notes b-      insertNote nt s = case s of-        NTc _ -> NTc nt-        NTKey _ -> NTKey nt-        NTUnit _ -> NTUnit nt-        NTSignature _ -> NTSignature nt-        NTOption _ n1  -> NTOption nt n1-        NTList _ n1 -> NTList nt n1-        NTSet _ n1 -> NTSet nt n1-        NTOperation _ -> NTOperation nt-        NTContract _ n1 -> NTContract nt n1-        NTPair _ n1 n2 n3 n4 -> NTPair nt n1 n2 n3 n4-        NTOr _ n1 n2 n3 n4 -> NTOr nt n1 n2 n3 n4-        NTLambda _ n1 n2 -> NTLambda nt n1 n2-        NTMap _ n1 n2 -> NTMap nt n1 n2-        NTBigMap _ n1 n2 -> NTBigMap nt n1 n2-        NTChainId _ -> NTChainId nt  instance (HasTypeAnn (Maybe a), KnownSymbol name)   => HasTypeAnn (NamedF Maybe a name) where@@ -108,13 +95,13 @@ instance (HasTypeAnn a) => HasTypeAnn (ContractRef a) where   getTypeAnn = NTContract noAnn (getTypeAnn @a) -instance (HasTypeAnn v) => HasTypeAnn (Map k v) where-  getTypeAnn = NTMap noAnn noAnn (getTypeAnn @v)+instance (HasTypeAnn k, HasTypeAnn v) => HasTypeAnn (Map k v) where+  getTypeAnn = NTMap noAnn (getTypeAnn @k) (getTypeAnn @v) -instance (HasTypeAnn v) => HasTypeAnn (BigMap k v) where-  getTypeAnn = NTBigMap noAnn noAnn (getTypeAnn @v)+instance (HasTypeAnn k, HasTypeAnn v) => HasTypeAnn (BigMap k v) where+  getTypeAnn = NTBigMap noAnn (getTypeAnn @k) (getTypeAnn @v) -instance (SingI (ToCT v), Typeable (ToCT v)) => HasTypeAnn (Set v) where+instance (SingI (ToT v), Typeable (ToT v)) => HasTypeAnn (Set v) where   getTypeAnn = starNotes  instance (HasTypeAnn a) => HasTypeAnn [a] where
src/Lorentz/UParam.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# OPTIONS_GHC -Wno-redundant-constraints #-} {-# OPTIONS_GHC -Wno-orphans #-} @@ -45,13 +49,10 @@  import Data.Constraint ((\\)) import qualified Data.Kind as Kind-import Data.Vinyl.Core (Rec(..))-import Data.Vinyl.TypeLevel (type (++)) import qualified Fcf import Fmt (Buildable(..)) import GHC.Generics ((:*:)(..), (:+:)(..)) import qualified GHC.Generics as G-import GHC.TypeLits (KnownSymbol, Symbol) import qualified Text.Show  import Lorentz.ADT
src/Lorentz/UStore.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {- | This module contains implementation of 'UStore'.  @UStore@ is essentially 'Lorentz.Store.Store' modified for the sake of
src/Lorentz/UStore/Common.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Lorentz.UStore.Common   ( fieldNameToMText   ) where
src/Lorentz/UStore/Haskell.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# OPTIONS_GHC -Wno-redundant-constraints #-}  -- | Conversion between 'UStore' in Haskell and Michelson representation.
src/Lorentz/UStore/Instances.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# OPTIONS_GHC -Wno-orphans #-}  module Lorentz.UStore.Instances () where
src/Lorentz/UStore/Instr.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# OPTIONS_GHC -Wno-redundant-constraints #-}  -- | Instructions to work with 'UStore'.@@ -301,7 +305,7 @@   deriving stock (Generic)  newtype MyNatural = MyNatural Natural-  deriving newtype (IsoCValue, IsoValue)+  deriving newtype (IsoValue)  data MyStoreTemplate3 = MyStoreTemplate3 { store3 :: Natural |~> MyNatural }   deriving stock Generic
src/Lorentz/UStore/Lift.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# OPTIONS_GHC -Wno-redundant-constraints #-}  -- | Composability helper for 'UStore'.@@ -9,12 +13,10 @@   , UStoreFieldsAreUnique   ) where -import Data.Type.Bool (If) import qualified Data.Kind as Kind-import GHC.TypeLits (Symbol, TypeError, ErrorMessage (..))-import Data.Vinyl.TypeLevel (type (++)) import GHC.Generics (type (:+:), type (:*:)) import qualified GHC.Generics as G+import GHC.TypeLits (ErrorMessage(..), Symbol, TypeError)  import Lorentz.Base import Lorentz.Coercions
src/Lorentz/UStore/Migration.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {- | Type-safe migrations of UStore.  This implements imperative approach to migration when we make user
src/Lorentz/UStore/Migration/Base.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# OPTIONS_GHC -Wno-redundant-constraints #-} {-# OPTIONS_GHC -Wno-orphans #-} @@ -93,8 +97,7 @@   , formMigrationAtom   ) where -import Control.Lens (traversed, _Wrapped')-import Data.Default (def)+import Control.Lens (traversed) import qualified Data.Foldable as Foldable import qualified Data.Kind as Kind import Data.Singletons (SingI(..), demote)@@ -104,14 +107,14 @@ import Lorentz.Base import Lorentz.Coercions import Lorentz.Doc-import Lorentz.TypeAnns (HasTypeAnn) import Lorentz.Instr (nop) import Lorentz.Run+import Lorentz.TypeAnns (HasTypeAnn) import Lorentz.UStore.Types import Lorentz.Value import Michelson.Typed (ExtInstr(..), Instr(..), T(..)) import Michelson.Typed.Util-import Util.Label (Label, labelToText)+import Util.Label (labelToText) import Util.Lens import Util.TypeLits 
src/Lorentz/UStore/Migration/Batching.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Different approaches to batching. -- -- For now we do not support perfect batching because operation size evaluation
src/Lorentz/UStore/Migration/Blocks.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# OPTIONS_GHC -Wno-redundant-constraints #-}  -- | Elemental building blocks for migrations.
src/Lorentz/UStore/Migration/Diff.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Lorentz.UStore.Migration.Diff   ( FieldInfo   , DiffKind (..)
src/Lorentz/UStore/Types.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | 'UStore' definition and common type-level stuff. module Lorentz.UStore.Types   ( -- * UStore and related type definitions@@ -33,24 +37,20 @@   , FSMarker   ) where -import Data.Default (Default) import Control.Lens (Wrapped) import qualified Data.Kind as Kind-import Data.Type.Equality (type (==)) import GHC.Generics ((:*:)(..), (:+:)(..)) import qualified GHC.Generics as G import GHC.TypeLits (ErrorMessage(..), Symbol, TypeError) import Test.QuickCheck (Arbitrary) -import Lorentz.Pack import Lorentz.Doc-import Lorentz.TypeAnns (HasTypeAnn)+import Lorentz.Pack import Lorentz.Polymorphic+import Lorentz.TypeAnns (HasTypeAnn)+import Lorentz.Value import Michelson.Text (labelToMText) import Michelson.Typed.T-import Michelson.Typed.Haskell.Value-import Lorentz.Value-import Util.Label (Label) import Util.Type  -- | Gathers multple fields and 'BigMap's under one object.@@ -190,8 +190,8 @@   FSValue ('MapSignature _ _) =     TypeError ('Text "Expected UStore field, but submap was referred") type family FSMarker (ms :: ElemSignature) :: UStoreMarkerType where-  FSValue ('FieldSignature m _) = m-  FSValue ('MapSignature _ _) =+  FSMarker ('FieldSignature m _) = m+  FSMarker ('MapSignature _ _) =     TypeError ('Text "Expected UStore field, but submap was referred")  -- | Get map signature from the constructor with a given name.
src/Lorentz/Value.hs view
@@ -1,11 +1,14 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Re-exports typed Value, CValue, some core types, some helpers and -- defines aliases for constructors of typed values. -- module Lorentz.Value   ( Value   , IsoValue (..)-  , IsoCValue (..)-  , CValue (..)+  , WellTypedIsoValue      -- * Primitive types   , Integer@@ -62,12 +65,8 @@  import Lorentz.Address import Michelson.Text-import Michelson.Typed-  (ContractRef(..), EntryPointCall, IsoCValue(..), IsoValue(..), SomeEntryPointCall, Value)+import Michelson.Typed (EntryPointCall, IsoValue(..), SomeEntryPointCall, Value, WellTypedIsoValue) import qualified Michelson.Typed as M-import Michelson.Typed.CValue (CValue(..))-import Michelson.Typed.EntryPoints (EpAddress(..))-import Tezos.Address (Address) import Tezos.Core   (ChainId, Mutez, Timestamp, timestampFromSeconds, timestampFromUTCTime, timestampQuote, toMutez) import Tezos.Crypto (KeyHash, PublicKey, Signature)
src/Lorentz/Zip.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# OPTIONS_GHC -Wno-orphans #-}  -- | Stack zipping.@@ -69,7 +73,7 @@   => Lambda (ZippedStack inp) (ZippedStack out) -> inp :-> out unzippingStack code = zipInstr ## code ## unzipInstr -instance (ZipInstr inp, ZipInstr out) => IsoValue (inp :-> out) where+instance (WellTypedToT (ZippedStack inp), WellTypedToT (ZippedStack out), ZipInstr inp, ZipInstr out) => IsoValue (inp :-> out) where   type ToT (inp :-> out) = 'TLambda (ToT (ZippedStack inp)) (ToT (ZippedStack out))   toVal i = VLam . unLorentzInstr $ zippingStack i   fromVal (VLam i) = zipInstr ## LorentzInstr i ## unzipInstr
test/Main.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Main   ( main   ) where
test/Test/Doc.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Tests on automatic documentation generation.  module Test.Doc
test/Test/DocTest.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Tests on doc test framework. module Test.DocTest   ( test_Predicates_work
test/Test/Lorentz/Base.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Tests for basic Lorentz functionality.  module Test.Lorentz.Base
test/Test/Lorentz/Conditionals.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# LANGUAGE NoApplicativeDo, RebindableSyntax #-} {-# OPTIONS_GHC -Wno-unused-do-bind #-} 
test/Test/Lorentz/DeadCode.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Tests checking dead code avoidance in Lorentz.  module Test.Lorentz.DeadCode@@ -35,7 +39,10 @@   ]   where     compilesTo linstr instr =-      compileLorentz @'[()] linstr @?= instr+      compileLorentzWithOptions @'[()]+        (defaultCompilationOptions { coOptimizerConf = Nothing })+        linstr+      @?= instr     infixr 0 `compilesTo`      fails instr =
test/Test/Lorentz/Doc/Positions.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Tests on ordering of documentation items. module Test.Lorentz.Doc.Positions   ( test_Errors
test/Test/Lorentz/EntryPoints.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# LANGUAGE DeriveAnyClass #-}  -- | Tests for Lorentz compilation which uses 'LorentzCompilationWay'.@@ -10,23 +14,23 @@   ) where  import Fcf (Eval)-import Unsafe.Coerce (unsafeCoerce)-import Data.Constraint (Dict (..)) import Test.HUnit ((@?=)) import Test.Tasty (TestTree, testGroup) import Test.Tasty.HUnit (testCase) import Test.Tasty.TypeSpec (typeTest) import Test.TypeSpec (Is, TypeSpec(..)) import Test.Util.TypeSpec (ExactlyIs)+import Unsafe.Coerce (unsafeCoerce) -import Lorentz ((:!), ( # ), (/->), HasTypeAnn)+import Lorentz ((:!), HasTypeAnn, ( # ), (/->)) import qualified Lorentz as L import Lorentz.Constraints import Lorentz.EntryPoints import Lorentz.Run import Lorentz.Test import Lorentz.Value-import Michelson.Typed+import Michelson.Typed hiding (Contract)+import qualified Michelson.Typed as M (Contract(..)) import Michelson.Untyped (FieldAnn, TypeAnn, ann, noAnn)  ----------------------------------------------------------------------------@@ -188,8 +192,9 @@ instance ParameterHasEntryPoints MyEntryPointsSubDelegated where   type ParameterEntryPointsDerivation MyEntryPointsSubDelegated = EpdNone -dummyContract :: L.ContractCode param ()-dummyContract = L.drop L.# L.unit L.# L.nil L.# L.pair+dummyContract :: Contract param ()+dummyContract = defaultContract $+  L.drop L.# L.unit L.# L.nil L.# L.pair  -- | Helper datatype which contains field annotations from 'NTOr'. data FieldAnnTree t where@@ -208,15 +213,14 @@   TANodeOr :: TypeAnn -> TypeAnnTree a -> TypeAnnTree b -> TypeAnnTree ('TOr a b)   TANodeLambda :: TypeAnn -> TypeAnnTree a -> TypeAnnTree b -> TypeAnnTree ('TLambda a b)   TANodeList :: TypeAnn -> TypeAnnTree a -> TypeAnnTree ('TList a)-  TANodeMap :: TypeAnn -> TypeAnnTree b -> TypeAnnTree ('TMap a b)-  TANodeBigMap :: TypeAnn -> TypeAnnTree b -> TypeAnnTree ('TBigMap a b)+  TANodeMap :: TypeAnn -> TypeAnnTree a -> TypeAnnTree b -> TypeAnnTree ('TMap a b)+  TANodeBigMap :: TypeAnn -> TypeAnnTree a -> TypeAnnTree b -> TypeAnnTree ('TBigMap a b)  deriving stock instance Eq (TypeAnnTree t) deriving stock instance Show (TypeAnnTree t)  extractTypeAnnTres :: Notes t -> TypeAnnTree t extractTypeAnnTres = \case-  NTc ta -> TALeaf ta   NTKey ta -> TALeaf ta   NTUnit ta -> TALeaf ta   NTSignature ta -> TALeaf ta@@ -228,9 +232,18 @@   NTPair ta _ _ n1 n2 -> TANodePair ta (extractTypeAnnTres n1) (extractTypeAnnTres n2)   NTOr ta _ _ n1 n2 -> TANodeOr ta (extractTypeAnnTres n1) (extractTypeAnnTres n2)   NTLambda ta n1 n2 -> TANodeLambda ta (extractTypeAnnTres n1) (extractTypeAnnTres n2)-  NTMap ta _ n1 -> TANodeMap ta (extractTypeAnnTres n1)-  NTBigMap ta _ n1 -> TANodeBigMap ta (extractTypeAnnTres n1)+  NTMap ta n1 n2 -> TANodeMap ta (extractTypeAnnTres n1) (extractTypeAnnTres n2)+  NTBigMap ta n1 n2 -> TANodeBigMap ta (extractTypeAnnTres n1) (extractTypeAnnTres n2)   NTChainId ta -> TALeaf ta+  NTInt ta -> TALeaf ta+  NTNat ta -> TALeaf ta+  NTString ta -> TALeaf ta+  NTBytes ta -> TALeaf ta+  NTMutez ta -> TALeaf ta+  NTBool ta -> TALeaf ta+  NTKeyHash ta -> TALeaf ta+  NTTimestamp ta -> TALeaf ta+  NTAddress ta -> TALeaf ta  extractFieldAnnTree :: Notes t -> FieldAnnTree t extractFieldAnnTree = \case@@ -277,8 +290,8 @@     ]   ]   where-    paramAnnTree :: FullContract cp st -> FieldAnnTree cp-    paramAnnTree = extractFieldAnnTree . fcParamNotes+    paramAnnTree :: M.Contract cp st -> FieldAnnTree cp+    paramAnnTree = extractFieldAnnTree . pnNotes . cParamNotes  test_TypeAnnotations :: [TestTree] test_TypeAnnotations =@@ -317,7 +330,13 @@       (paramAnnTree $ compileLorentzContract (dummyContract @MyEntryPoints8))       @?=       (TANodeOr noAnn-       (TANodeMap (ann "maparg") (TANodePair noAnn (TALeaf (ann "balance")) (TALeaf (ann "address")))) (TALeaf noAnn))+        (TANodeMap+          (ann "maparg")+          (TALeaf noAnn)+          (TANodePair noAnn (TALeaf (ann "balance")) (TALeaf (ann "address")))+        )+        (TALeaf noAnn)+      )    , testCase "Maybe field parameter 2" $       (paramAnnTree $ compileLorentzContract (dummyContract @MyEntryPoints9))@@ -329,7 +348,16 @@       (paramAnnTree $ compileLorentzContract (dummyContract @MyEntryPoints10))       @?=       (TANodeOr noAnn-        (TANodeLambda (ann "bigmaparg") (TANodeBigMap noAnn (TANodePair noAnn (TALeaf (ann "balance")) (TALeaf (ann "address")))) (TALeaf noAnn)) (TALeaf noAnn))+        (TANodeLambda (ann "bigmaparg")+          (TANodeBigMap+            noAnn+            (TALeaf noAnn)+            (TANodePair noAnn (TALeaf (ann "balance")) (TALeaf (ann "address")))+          )+          (TALeaf noAnn)+        )+        (TALeaf noAnn)+      )    , testCase "Newtype" $       (paramAnnTree $ compileLorentzContract (dummyContract @(ShouldHaveEntryPoints MySingleEntryPoint)))@@ -356,8 +384,8 @@       )   ]   where-    paramAnnTree :: FullContract cp st -> TypeAnnTree cp-    paramAnnTree = extractTypeAnnTres . fcParamNotes+    paramAnnTree :: M.Contract cp st -> TypeAnnTree cp+    paramAnnTree = extractTypeAnnTres . pnNotes . M.cParamNotes  ---------------------------------------------------------------------------- -- @contract@ instruction@@ -406,8 +434,8 @@      )   => EntryPointRef mname   -> arg-  -> L.ContractCode (TAddress cp) ()-callerContract epRef arg =+  -> Contract (TAddress cp) ()+callerContract epRef arg = defaultContract $   L.car # L.contractCalling epRef #   L.assertSome [mt|Contract lookup failed|] #   L.push (toMutez 1) # L.push arg # L.transferTokens #@@ -418,7 +446,7 @@   [ testCase "Calling entrypoint" $       integrationalTestExpectation $ do         let myCallerContract = callerContract (Call @"Do11") 5-        let myTargetContract = L.car # L.caseT @MyEntryPoints2+        let myTargetContract = defaultContract $ L.car # L.caseT @MyEntryPoints2               ( #cDo10 /-> L.push 0               , #cDo11 /-> L.nop               ) # L.nil # L.pair@@ -432,7 +460,7 @@   , testCase "Calling default entrypoint" $       integrationalTestExpectation $ do         let myCallerContract = callerContract CallDefault 3-        let myTargetContract = L.car # L.caseT @MyEntryPointsWithDef+        let myTargetContract = defaultContract $ L.car # L.caseT @MyEntryPointsWithDef               ( #cDefault /-> L.nop               , #cNonDefault /-> L.neg               ) # L.nil # L.pair@@ -448,7 +476,7 @@ test_Self_call =   [ testCase "Calling entrypoint" $       integrationalTestExpectation $ do-        let myContract = L.car # L.caseT @MyEntryPoints2+        let myContract = defaultContract $ L.car # L.caseT @MyEntryPoints2               ( #cDo10 /->                   L.selfCalling @MyEntryPoints2 (Call @"Do11") #                   L.push (toMutez 1) # L.push 5 # L.transferTokens #
test/Test/Lorentz/EntryPoints/Doc.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Tests on autodoc for entrypoints. module Test.Lorentz.EntryPoints.Doc   ( test_ParamBuildingSteps_are_correct
test/Test/Lorentz/Errors.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# OPTIONS_GHC -Wno-deprecations #-} {-# OPTIONS_GHC -Wno-orphans #-} @@ -15,7 +19,6 @@  import Lorentz as L import Lorentz.Test.Integrational-import Michelson.Text (mt)  {- Checking that errors of old format still can be used fine -} @@ -131,7 +134,7 @@ unit_errorFromValNumeric = integrationalTestExpectation $ do   let     (voidSample', errorTagMap) = useNumericErrors voidSample-  ref <- lOriginate voidSample' "voidSample" () minBound+  ref <- lOriginate (defaultContract voidSample') "voidSample" () minBound   lCall ref (mkVoid True)   validate . Left $     lExpectErrorNumeric errorTagMap (== VoidResult False)
test/Test/Lorentz/Errors/Numeric.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# OPTIONS_GHC -Wno-orphans #-}  module Test.Lorentz.Errors.Numeric
test/Test/Lorentz/Extensible.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Test.Lorentz.Extensible   ( test_Extensible   ) where
test/Test/Lorentz/Interpreter.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Test.Lorentz.Interpreter   ( test_Entry_points_lookup   , test_Entry_points_calling@@ -11,9 +15,8 @@  import Lorentz.Test.Integrational import Michelson.Interpret (ContractEnv(..))-import Michelson.Test (contractProp, testTreesWithTypedContract)+import Michelson.Test (testTreesWithTypedContract) import Michelson.Test.Dummy (dummyContractEnv)-import Michelson.Test.Integrational (genesisAddress, integrationalTestExpectation, validate) import Michelson.Test.Unit import Michelson.Text import Michelson.Typed (IsoValue(..))@@ -67,29 +70,29 @@      dir = entrypointsDir     contractSimpleTy =-      U.Type (U.TOr (U.ann "a") (U.ann "b") (U.Type U.Tint U.noAnn) (U.Type U.Tnat U.noAnn))+      U.Type (U.TOr (U.ann "a") (U.ann "b") (U.Type U.TInt U.noAnn) (U.Type U.TNat U.noAnn))              U.noAnn     contractComplexTy =-      U.Type (U.TOr (U.ann "s") (U.ann "t") (U.Type U.Tstring U.noAnn) contractSimpleTy)+      U.Type (U.TOr (U.ann "s") (U.ann "t") (U.Type U.TString U.noAnn) contractSimpleTy)              U.noAnn     contractWithDefTy =-      U.Type (U.TOr (U.ann "a") (U.ann "default") (U.Type U.Tnat U.noAnn) (U.Type U.Tstring U.noAnn))+      U.Type (U.TOr (U.ann "a") (U.ann "default") (U.Type U.TNat U.noAnn) (U.Type U.TString U.noAnn))              U.noAnn     addr = mkContractAddressRaw     env =-      [ (mkContractHashRaw "simple", contractSimpleTy)-      , (mkContractHashRaw "complex", contractComplexTy)-      , (mkContractHashRaw "def", contractWithDefTy)+      [ (mkContractHashRaw "simple", U.ParameterType contractSimpleTy U.noAnn)+      , (mkContractHashRaw "complex", U.ParameterType contractComplexTy U.noAnn)+      , (mkContractHashRaw "def", U.ParameterType contractWithDefTy U.noAnn)       ]  test_Entry_points_calling :: IO [TestTree] test_Entry_points_calling =   testTreesWithTypedContract (dir </> "call1.mtz") $-    \(call1 :: T.FullContract (ToT Address) (ToT ())) ->+    \(call1 :: T.Contract (ToT Address) (ToT ())) ->   testTreesWithTypedContract (dir </> "contract1.mtz") $-    \(contract1 :: T.FullContract (ToT (Either Integer MText)) (ToT Integer)) ->+    \(contract1 :: T.Contract (ToT (Either Integer MText)) (ToT Integer)) ->   testTreesWithTypedContract (dir </> "self1.mtz") $-    \(self1 :: T.FullContract (ToT (Either Integer ())) (ToT Integer)) ->+    \(self1 :: T.Contract (ToT (Either Integer ())) (ToT Integer)) ->   pure   [ testCase "Calling some entrypoint in CONTRACT" $       integrationalTestExpectation $ do
test/Test/Lorentz/Macro.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Tests for Lorentz macros. -- -- They test logic of macros and type-level logic.  Also they serve as
test/Test/Lorentz/Pack.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Tests for Lorentz packing/unpacking  module Test.Lorentz.Pack
test/Test/Lorentz/Print.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# LANGUAGE DeriveAnyClass #-}  -- | Tests on Lorentz contracts pretty-printing.@@ -15,8 +19,8 @@ import Lorentz hiding (contract, unpack) import qualified Lorentz as L import Michelson.Printer.Util (buildRenderDoc)-import Michelson.Typed hiding (ContractCode)-import Michelson.Untyped (para)+import Michelson.Typed hiding (Contract, ContractCode)+import Michelson.Untyped (contractParameter)  data MyEntryPoints1   = Do1 Integer@@ -28,15 +32,16 @@ instance ParameterHasEntryPoints MyEntryPoints1 where   type ParameterEntryPointsDerivation MyEntryPoints1 = EpdPlain -contract :: ContractCode MyEntryPoints1 ()-contract = drop # unit # nil # pair+contract :: Contract MyEntryPoints1 ()+contract = defaultContract $+  drop # unit # nil # pair  test_Print_parameter_annotations :: [TestTree] test_Print_parameter_annotations =   [ testCase "Simple parameter" $       let typedContract = compileLorentzContract contract-          untypedContract = convertFullContract typedContract-      in buildRenderDoc (para untypedContract)+          untypedContract = convertContract typedContract+      in buildRenderDoc (contractParameter untypedContract)          @?=          "or (int %do1) (or (pair %do2 int int) (unit %do3))"   ]@@ -64,8 +69,10 @@ unit_Erase_annotations :: Assertion unit_Erase_annotations =   let-    myContract :: ContractCode TestParam ()-    myContract = cdr # nil # L.pair+    myContract :: Contract TestParam ()+    myContract = defaultContract $+      cdr # nil # L.pair+     expected = "parameter (or (pair %testCon1 (nat :a) (bool :b)) (unit %testCon2));storage unit;code { CAST (pair (or (pair nat bool) unit) unit);CDR;NIL operation;PAIR };"   in assertEqual       "Printed Lorentz contract is supposed to have an instruction which erases\
test/Test/Lorentz/UParam.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Tests for Lorentz 'UParam'. module Test.Lorentz.UParam   ( test_Simple_contract
test/Test/Lorentz/UStore/Behaviour.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Tests for Lorentz 'UStore'. module Test.Lorentz.UStore.Behaviour   ( test_Roundtrip
test/Test/Lorentz/UStore/Migration/Batched.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Test.Lorentz.UStore.Migration.Batched   ( test_Separated_lambdas   ) where
test/Test/Lorentz/UStore/Migration/Batched/V1.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Test.Lorentz.UStore.Migration.Batched.V1   ( MyTemplate (..)   ) where
test/Test/Lorentz/UStore/Migration/Batched/V2.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Test.Lorentz.UStore.Migration.Batched.V2   ( MyTemplate (..)   ) where
test/Test/Lorentz/UStore/Migration/FillInParts.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Test.Lorentz.UStore.Migration.FillInParts   ( test_Migration_works   ) where
test/Test/Lorentz/UStore/Migration/Simple.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Test.Lorentz.UStore.Migration.Simple   ( test_Migration_works   ) where
test/Test/Lorentz/UStore/Migration/Simple/V1.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Test.Lorentz.UStore.Migration.Simple.V1   ( MyTemplate (..)   ) where
test/Test/Lorentz/UStore/Migration/Simple/V2.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Test.Lorentz.UStore.Migration.Simple.V2   ( MyTemplate (..)   ) where
test/Test/Lorentz/UStore/SafeLift.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | We have a constraint in 'ustoreLift' which -- forbids nested store templates with duplicated fields. -- This module checks this constraint will work fine.
test/Test/Lorentz/UStore/SafeLift/Helpers.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Contains a template for safe lifting check. -- -- We are going to define another template with the same field name,
test/Test/Tasty/TypeSpec.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ -- | Tasty integration for TypeSpec. module Test.Tasty.TypeSpec   ( typeTest
test/Test/Util/TypeSpec.hs view
@@ -1,3 +1,7 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ module Test.Util.TypeSpec   ( ExactlyIs   ) where
test/Tree.hs view
@@ -1,1 +1,5 @@+-- SPDX-FileCopyrightText: 2020 Tocqueville Group+--+-- SPDX-License-Identifier: LicenseRef-MIT-TQ+ {-# OPTIONS_GHC -F -pgmF tasty-discover -optF --tree-display -optF --generated-module -optF Tree #-}