diff --git a/.gitignore b/.gitignore
index 7c74bb519..7ea5fe64d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,19 @@
+# Lambda template
+_build
+_coverage
+/_esy
+/node_modules
+/esy.lock
+/.melange.eobjs
+
+# Fsharp
+test
+*.fs
+*.fsi
+
+# Fsharp Ionide
+.fake
+
+# MS
_build
.DS_Store
diff --git a/CSharpStrange/.envrc b/CSharpStrange/.envrc
deleted file mode 100644
index 686a37170..000000000
--- a/CSharpStrange/.envrc
+++ /dev/null
@@ -1,2 +0,0 @@
-export OPAMSWITCH=4.14.2+flambda
-eval $(opam env)
diff --git a/CSharpStrange/.gitignore b/CSharpStrange/.gitignore
deleted file mode 100644
index 7102a822c..000000000
--- a/CSharpStrange/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-_build
-_coverage
-/_esy
-/node_modules
-/esy.lock
-/.melange.eobjs
diff --git a/CSharpStrange/.ocamlformat b/CSharpStrange/.ocamlformat
deleted file mode 100644
index 97f970802..000000000
--- a/CSharpStrange/.ocamlformat
+++ /dev/null
@@ -1,2 +0,0 @@
-profile=janestreet
-version=0.26.2
diff --git a/CSharpStrange/.zanuda b/CSharpStrange/.zanuda
deleted file mode 100644
index 39f42da0d..000000000
--- a/CSharpStrange/.zanuda
+++ /dev/null
@@ -1 +0,0 @@
-forward mutability_check ignore REPL.ml
\ No newline at end of file
diff --git a/CSharpStrange/COPYING b/CSharpStrange/COPYING
deleted file mode 100644
index f288702d2..000000000
--- a/CSharpStrange/COPYING
+++ /dev/null
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is 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. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- 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.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- 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 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. Use with the GNU Affero General Public License.
-
- 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 Affero 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 special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU 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 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 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 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.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- Copyright (C)
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- 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 GPL, see
-.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-.
diff --git a/CSharpStrange/COPYING.CC0 b/CSharpStrange/COPYING.CC0
deleted file mode 100644
index 0e259d42c..000000000
--- a/CSharpStrange/COPYING.CC0
+++ /dev/null
@@ -1,121 +0,0 @@
-Creative Commons Legal Code
-
-CC0 1.0 Universal
-
- CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
- LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
- ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
- INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
- REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
- PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
- THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
- HEREUNDER.
-
-Statement of Purpose
-
-The laws of most jurisdictions throughout the world automatically confer
-exclusive Copyright and Related Rights (defined below) upon the creator
-and subsequent owner(s) (each and all, an "owner") of an original work of
-authorship and/or a database (each, a "Work").
-
-Certain owners wish to permanently relinquish those rights to a Work for
-the purpose of contributing to a commons of creative, cultural and
-scientific works ("Commons") that the public can reliably and without fear
-of later claims of infringement build upon, modify, incorporate in other
-works, reuse and redistribute as freely as possible in any form whatsoever
-and for any purposes, including without limitation commercial purposes.
-These owners may contribute to the Commons to promote the ideal of a free
-culture and the further production of creative, cultural and scientific
-works, or to gain reputation or greater distribution for their Work in
-part through the use and efforts of others.
-
-For these and/or other purposes and motivations, and without any
-expectation of additional consideration or compensation, the person
-associating CC0 with a Work (the "Affirmer"), to the extent that he or she
-is an owner of Copyright and Related Rights in the Work, voluntarily
-elects to apply CC0 to the Work and publicly distribute the Work under its
-terms, with knowledge of his or her Copyright and Related Rights in the
-Work and the meaning and intended legal effect of CC0 on those rights.
-
-1. Copyright and Related Rights. A Work made available under CC0 may be
-protected by copyright and related or neighboring rights ("Copyright and
-Related Rights"). Copyright and Related Rights include, but are not
-limited to, the following:
-
- i. the right to reproduce, adapt, distribute, perform, display,
- communicate, and translate a Work;
- ii. moral rights retained by the original author(s) and/or performer(s);
-iii. publicity and privacy rights pertaining to a person's image or
- likeness depicted in a Work;
- iv. rights protecting against unfair competition in regards to a Work,
- subject to the limitations in paragraph 4(a), below;
- v. rights protecting the extraction, dissemination, use and reuse of data
- in a Work;
- vi. database rights (such as those arising under Directive 96/9/EC of the
- European Parliament and of the Council of 11 March 1996 on the legal
- protection of databases, and under any national implementation
- thereof, including any amended or successor version of such
- directive); and
-vii. other similar, equivalent or corresponding rights throughout the
- world based on applicable law or treaty, and any national
- implementations thereof.
-
-2. Waiver. To the greatest extent permitted by, but not in contravention
-of, applicable law, Affirmer hereby overtly, fully, permanently,
-irrevocably and unconditionally waives, abandons, and surrenders all of
-Affirmer's Copyright and Related Rights and associated claims and causes
-of action, whether now known or unknown (including existing as well as
-future claims and causes of action), in the Work (i) in all territories
-worldwide, (ii) for the maximum duration provided by applicable law or
-treaty (including future time extensions), (iii) in any current or future
-medium and for any number of copies, and (iv) for any purpose whatsoever,
-including without limitation commercial, advertising or promotional
-purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
-member of the public at large and to the detriment of Affirmer's heirs and
-successors, fully intending that such Waiver shall not be subject to
-revocation, rescission, cancellation, termination, or any other legal or
-equitable action to disrupt the quiet enjoyment of the Work by the public
-as contemplated by Affirmer's express Statement of Purpose.
-
-3. Public License Fallback. Should any part of the Waiver for any reason
-be judged legally invalid or ineffective under applicable law, then the
-Waiver shall be preserved to the maximum extent permitted taking into
-account Affirmer's express Statement of Purpose. In addition, to the
-extent the Waiver is so judged Affirmer hereby grants to each affected
-person a royalty-free, non transferable, non sublicensable, non exclusive,
-irrevocable and unconditional license to exercise Affirmer's Copyright and
-Related Rights in the Work (i) in all territories worldwide, (ii) for the
-maximum duration provided by applicable law or treaty (including future
-time extensions), (iii) in any current or future medium and for any number
-of copies, and (iv) for any purpose whatsoever, including without
-limitation commercial, advertising or promotional purposes (the
-"License"). The License shall be deemed effective as of the date CC0 was
-applied by Affirmer to the Work. Should any part of the License for any
-reason be judged legally invalid or ineffective under applicable law, such
-partial invalidity or ineffectiveness shall not invalidate the remainder
-of the License, and in such case Affirmer hereby affirms that he or she
-will not (i) exercise any of his or her remaining Copyright and Related
-Rights in the Work or (ii) assert any associated claims and causes of
-action with respect to the Work, in either case contrary to Affirmer's
-express Statement of Purpose.
-
-4. Limitations and Disclaimers.
-
- a. No trademark or patent rights held by Affirmer are waived, abandoned,
- surrendered, licensed or otherwise affected by this document.
- b. Affirmer offers the Work as-is and makes no representations or
- warranties of any kind concerning the Work, express, implied,
- statutory or otherwise, including without limitation warranties of
- title, merchantability, fitness for a particular purpose, non
- infringement, or the absence of latent or other defects, accuracy, or
- the present or absence of errors, whether or not discoverable, all to
- the greatest extent permissible under applicable law.
- c. Affirmer disclaims responsibility for clearing rights of other persons
- that may apply to the Work or any use thereof, including without
- limitation any person's Copyright and Related Rights in the Work.
- Further, Affirmer disclaims responsibility for obtaining any necessary
- consents, permissions or other rights required for any use of the
- Work.
- d. Affirmer understands and acknowledges that Creative Commons is not a
- party to this document and has no duty or obligation with respect to
- this CC0 or use of the Work.
diff --git a/CSharpStrange/COPYING.LESSER b/CSharpStrange/COPYING.LESSER
deleted file mode 100644
index 0a041280b..000000000
--- a/CSharpStrange/COPYING.LESSER
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser 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
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/CSharpStrange/CSharpStrange.opam b/CSharpStrange/CSharpStrange.opam
deleted file mode 100644
index 7e5c764d0..000000000
--- a/CSharpStrange/CSharpStrange.opam
+++ /dev/null
@@ -1,36 +0,0 @@
-# This file is generated by dune, edit dune-project instead
-opam-version: "2.0"
-version: "0.1"
-synopsis: "An interpreter for strange subset of C# language"
-description:
- "An interpreter for subset of C# language with async/await and LINQ (and some other stuff which will be added later)"
-maintainer: ["Dmitrii Kuznetsov dmitrvlkuznetsov@gmail.com"]
-authors: ["Dmitrii Kuznetsov dmitrvlkuznetsov@gmail.com"]
-license: "LGPL-3.0-or-later"
-homepage: "https://github.com/f1i3g3/fp2024"
-bug-reports: "https://github.com/f1i3g3/fp2024"
-depends: [
- "dune" {>= "3.7"}
- "angstrom"
- "ppx_inline_test" {with-test}
- "ppx_expect"
- "ppx_deriving"
- "bisect_ppx"
- "odoc" {with-doc}
- "ocamlformat" {build}
- "base"
-]
-build: [
- ["dune" "subst"] {dev}
- [
- "dune"
- "build"
- "-p"
- name
- "-j"
- jobs
- "@install"
- "@runtest" {with-test}
- "@doc" {with-doc}
- ]
-]
diff --git a/CSharpStrange/Makefile b/CSharpStrange/Makefile
deleted file mode 100644
index 79fbb624c..000000000
--- a/CSharpStrange/Makefile
+++ /dev/null
@@ -1,49 +0,0 @@
-.PHONY: repl tests test fmt lint celan
-
-all:
- dune build
-
-repl:
- dune build ./REPL.exe && rlwrap _build/default/REPL.exe
-
-tests: test
-test:
- dune runtest
-
-celan: clean
-clean:
- @$(RM) -r _build _coverage
-
-fmt:
- dune build @fmt --auto-promote
-
-lint:
- dune build @lint --force
-
-release:
- dune build --profile=release
- dune runtest --profile=release
-
-install:
- dune b @install --profile=release
- dune install
-
-ODIG_SWITCHES = --odoc-theme=odig.gruvbox.light
-ODIG_SWITCHES += --no-tag-index
-ODIG_SWITCHES += --no-pkg-deps
-odig:
- odig odoc $(ODIG_SWITCHES) Lambda
-
-TEST_COV_D = /tmp/cov
-COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect tests/
-
-.PHONY: test_coverage coverage
-test_coverage: coverage
-coverage:
- $(RM) -r $(TEST_COV_D)
- mkdir -p $(TEST_COV_D)
- BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \
- --instrument-with bisect_ppx --force
- bisect-ppx-report html $(COVERAGE_OPTS)
- bisect-ppx-report summary $(COVERAGE_OPTS)
- @echo "Use 'xdg-open _coverage/index.html' to see coverage report"
diff --git a/CSharpStrange/bin/REPL.ml b/CSharpStrange/bin/REPL.ml
deleted file mode 100644
index 26d45ea39..000000000
--- a/CSharpStrange/bin/REPL.ml
+++ /dev/null
@@ -1,31 +0,0 @@
-open C_sharp_strange_lib.Ast
-open C_sharp_strange_lib.Parser
-open Printf
-open Stdio
-
-type opts =
- { mutable dump_parse_tree : bool
- ; mutable file_path : string option
- }
-
-let () =
- let opts = { dump_parse_tree = false; file_path = None } in
- let _ =
- Arg.parse
- [ "-parseast", Arg.Unit (fun () -> opts.dump_parse_tree <- true), "\n"
- ; "-filepath", Arg.String (fun file_path -> opts.file_path <- Some file_path), "\n"
- ]
- (fun _ ->
- Stdlib.Format.eprintf "Something got wrong\n";
- Stdlib.exit 1)
- "\n"
- in
- let path =
- match opts.file_path with
- | None -> String.trim @@ In_channel.input_all stdin
- | Some path -> String.trim @@ In_channel.read_all path
- in
- match apply_parser parse_prog path with
- | Ok ast -> if opts.dump_parse_tree then print_endline (show_program ast)
- | Error msg -> failwith (sprintf "Failed to parse file: %s" msg)
-;;
diff --git a/CSharpStrange/bin/dune b/CSharpStrange/bin/dune
deleted file mode 100644
index f1f0d7674..000000000
--- a/CSharpStrange/bin/dune
+++ /dev/null
@@ -1,7 +0,0 @@
-(executable
- (name REPL)
- (public_name REPL)
- (modules REPL)
- (libraries c_sharp_strange_lib stdio)
- (instrumentation
- (backend bisect_ppx)))
diff --git a/CSharpStrange/bin/factorial.cs b/CSharpStrange/bin/factorial.cs
deleted file mode 100644
index f85758ec7..000000000
--- a/CSharpStrange/bin/factorial.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-public class Program
-{
- public int Factorial(int n)
- {
- if (n == 0)
- {
- return 1;
- }
- else
- {
- return n * Factorial(n - 1);
- }
- }
-
- public static void Main()
- {
-
- }
-}
\ No newline at end of file
diff --git a/CSharpStrange/dune-project b/CSharpStrange/dune-project
deleted file mode 100644
index dba4e1cb9..000000000
--- a/CSharpStrange/dune-project
+++ /dev/null
@@ -1,35 +0,0 @@
-(lang dune 3.7)
-
-(generate_opam_files true)
-
-(cram enable)
-
-(license LGPL-3.0-or-later)
-
-(authors "Dmitrii Kuznetsov dmitrvlkuznetsov@gmail.com")
-
-(maintainers "Dmitrii Kuznetsov dmitrvlkuznetsov@gmail.com")
-
-(bug_reports "https://github.com/f1i3g3/fp2024")
-
-(homepage "https://github.com/f1i3g3/fp2024")
-
-(package
- (name CSharpStrange)
- (synopsis "An interpreter for strange subset of C# language")
- (description
- "An interpreter for subset of C# language with async/await and LINQ (and some other stuff which will be added later)")
- ; TODO: actual documentation (documentation "https://kakadu.github.io/fp2024/docs/Lambda")
- (version 0.1)
- (depends
- dune
- angstrom
- (ppx_inline_test :with-test)
- ppx_expect
- ppx_deriving
- bisect_ppx
- (odoc :with-doc)
- (ocamlformat :build)
- base
- ; After adding dependencies to 'dune' files add the same dependecies here too
- ))
diff --git a/CSharpStrange/lib/ast.ml b/CSharpStrange/lib/ast.ml
deleted file mode 100644
index 7f03ac5b9..000000000
--- a/CSharpStrange/lib/ast.ml
+++ /dev/null
@@ -1,108 +0,0 @@
-(** Copyright 2025, Dmitrii Kuznetsov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-(** Values types *)
-type val_type =
- | ValInt of int (** Int value *)
- | ValChar of char (** Char value *)
- | ValNull (** Null *)
- | ValBool of bool (** Bool value *)
- | ValString of string (** string value *)
-[@@deriving eq, show { with_path = false }]
-
-(** Identidicator *)
-type ident = Id of string [@@deriving eq, show { with_path = false }]
-
-(** Basic types declarations *)
-type base_type =
- | TypeInt (** Declaration of int *)
- | TypeChar (** Declaration of char *)
- | TypeBool (** Declaration of bool *)
- | TypeString (** Declaration of string *)
-[@@deriving eq, show { with_path = false }]
-
-(** Type delcaration *)
-type _type =
- | TypeBase of base_type (** Declaration of basic type *)
- | TypeVoid (** Declaration of void *)
-[@@deriving eq, show { with_path = false }]
-
-(** Variable *)
-type var_type = TypeVar of _type [@@deriving eq, show { with_path = false }]
-
-(** Modifiers *)
-type modifier =
- | MPublic (** Public modifier, used for main() method only *)
- | MStatic (** Static modifier, used for main() method only *)
- | MAsync (** Async modifier *)
-[@@deriving eq, show { with_path = false }]
-
-type var_decl = Var of var_type * ident [@@deriving eq, show { with_path = false }]
-type params = Params of var_decl list [@@deriving eq, show { with_path = false }]
-
-(** Binary operations *)
-type bin_op =
- | OpAdd (** Sum: a [+] b *)
- | OpSub (** a [-] b *)
- | OpMul (** a [*] b *)
- | OpDiv (** a [/] b in integers *)
- | OpMod (** a [%] b *)
- | OpEqual (** a [==] b *)
- | OpNonEqual (** a [!=] b *)
- | OpLess (** a [<] b *)
- | OpMore (** a [>] b *)
- | OpLessEqual (** a [<=] b *)
- | OpMoreEqual (** a [>=] b *)
- | OpAnd (** a [&&] b *)
- | OpOr (** a [||] b *)
- | OpAssign (** a [=] b *)
-[@@deriving eq, show { with_path = false }]
-
-(** Unary operations *)
-type un_op = OpNot (** [!] a *) [@@deriving eq, show { with_path = false }]
-
-(** From clauses *)
-type from_clause = FromClause of string * ident
-[@@deriving eq, show { with_path = false }]
-
-(** Language expressions *)
-type expr =
- | EValue of val_type (** Some value *)
- | EBinOp of bin_op * expr * expr (** Binary operation *)
- | EUnOp of un_op * expr (** Unary operation *)
- | EId of ident (** Identificator expression *)
- | EArrayAccess of expr * expr (** Array access: a = arr[i] *)
- | EFuncCall of expr * expr list (** Call of function: name(arguments) *)
- | EAwait of expr (** [Await] expression *)
-[@@deriving eq, show { with_path = false }]
-
-(** Language statements *)
-type stmt =
- | SFor of stmt option * expr option * expr option * stmt
- (** For cycle: [for] (int i = 0, j = 3; i < 4; i++, j--) \{\} *)
- | SIf of expr * stmt * stmt option
- (** If condition: [if] (a) [then] \{ b \} ([else] \{ c \} ) *)
- | SWhile of expr * stmt (** While cycle: [while] (a) \{ \} *)
- | SReturn of expr option (** Return: [return] (a) *)
- | SBlock of stmt list (** Block of statements: \{ a \}; could be empty: \{\} *)
- | SBreak (** Cycle [break] *)
- | SContinue (** Cycle [continue] *)
- | SExpr of expr (** Another expression *)
- | SDecl of var_decl * expr option (** Var declaration *)
-[@@deriving eq, show { with_path = false }]
-
-(** C Sharp class fields *)
-type field =
- | VarField of modifier list * var_type * ident * expr option
- (** Class field - always initialized *)
- | Method of modifier list * _type * ident * params * stmt (** Class method *)
-[@@deriving eq, show { with_path = false }]
-
-(** C Sharp class *)
-type c_sharp_class =
- | Class of modifier list * ident * field list (** Basic class (Program) name *)
-[@@deriving eq, show { with_path = false }]
-
-(** Program AST *)
-type program = Program of c_sharp_class [@@deriving eq, show { with_path = false }]
diff --git a/CSharpStrange/lib/dune b/CSharpStrange/lib/dune
deleted file mode 100644
index 1fe37a666..000000000
--- a/CSharpStrange/lib/dune
+++ /dev/null
@@ -1,9 +0,0 @@
-(library
- (name c_sharp_strange_lib)
- (public_name CSharpStrange.Lib)
- (modules Ast Parser Prettyprinter)
- (libraries angstrom base)
- (preprocess
- (pps ppx_deriving.show ppx_deriving.eq ppx_expect ppx_inline_test))
- (instrumentation
- (backend bisect_ppx)))
diff --git a/CSharpStrange/lib/parser.ml b/CSharpStrange/lib/parser.ml
deleted file mode 100644
index 9b0019156..000000000
--- a/CSharpStrange/lib/parser.ml
+++ /dev/null
@@ -1,393 +0,0 @@
-(** Copyright 2025, Dmitrii Kuznetsov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-open Angstrom
-open Base
-
-(* Chain functions *)
-let chainl0 expr op = op >>= (fun op1 -> expr >>| op1) <|> expr
-
-let chainl1 expr op =
- let rec pars e1 = lift2 (fun op1 e2 -> op1 e1 e2) op expr >>= pars <|> return e1 in
- expr >>= pars
-;;
-
-let chainr1 expr op =
- fix (fun x -> lift2 (fun op1 -> op1) (lift2 (fun e1 op2 -> op2 e1) expr op) x <|> expr)
-;;
-
-(* Special functions *)
-let reserved =
- [ "true"
- ; "false"
- ; "if"
- ; "else"
- ; "while"
- ; "public"
- ; "static"
- ; "void"
- ; "string"
- ; "char"
- ; "int"
- ; "bool"
- ; "for"
- ; "null"
- ; "new"
- ; "return"
- ; "break"
- ; "continue"
- ; "class"
- ; "async"
- ; "await"
- ]
-;;
-
-let in_reserved t = List.mem reserved t ~equal:String.equal
-
-let is_space = function
- | ' ' | '\t' | '\n' | '\r' -> true
- | _ -> false
-;;
-
-let is_token_sym = function
- | 'a' .. 'z' | '0' .. '9' | 'A' .. 'Z' | '_' -> true
- | _ -> false
-;;
-
-let skip_spaces = skip_while is_space
-
-let parens p =
- skip_spaces *> (char '(' <|> fail "<(> error)") *> p
- <* skip_spaces
- <* (char ')' <|> fail "<)> error)")
-;;
-
-let braces p =
- skip_spaces *> (char '{' <|> fail "<{> error)") *> p
- <* skip_spaces
- <* (char '}' <|> fail "<}> error)")
-;;
-
-let brackets p =
- skip_spaces *> (char '[' <|> fail "<[> error)") *> p
- <* skip_spaces
- <* (char ']' <|> fail "<]> error)")
-;;
-
-let skip_semicolons = fix (fun f -> skip_spaces *> char ';' *> f <|> return "")
-let skip_semicolons1 = skip_spaces *> char ';' *> skip_semicolons
-
-(* Values *)
-
-let parse_int =
- take_while1 Char.is_digit
- >>= fun num -> return @@ ValInt (Int.of_string num) <|> fail "Not an int"
-;;
-
-let parse_char =
- char '\'' *> any_char
- <* char '\''
- >>= (fun c -> return @@ ValChar c)
- <|> fail "Not a char"
-;;
-
-let parse_bool =
- choice
- [ string "true" *> return (ValBool true); string "false" *> return (ValBool false) ]
- <|> fail "Not a bool"
-;;
-
-let parse_val_string =
- char '\"'
- *> take_till (function
- | '\"' -> true
- | _ -> false)
- <* char '\"'
- >>= (fun s -> return @@ ValString s)
- <|> fail "Not a string"
-;;
-
-let parse_null = string "null" *> return ValNull <|> fail "Not a null"
-
-(* Modifiers *)
-
-let parse_modifiers =
- many
- (choice
- [ string "public" *> skip_spaces *> return MPublic
- ; string "static" *> skip_spaces *> return MStatic
- ; string "async" *> skip_spaces *> return MAsync
- ])
- <|> fail "Modifier error"
-;;
-
-(* Type words *)
-let parse_type_word =
- take_while is_token_sym
- >>= function
- | "int" -> return TypeInt
- | "char" -> return TypeChar
- | "bool" -> return TypeBool
- | "string" -> return TypeString
- | _ -> fail "Wrong type word"
-;;
-
-let parse_base_type = parse_type_word >>= fun tp -> return @@ TypeBase tp
-let val_to_expr p = skip_spaces *> p >>| fun x -> EValue x
-
-let parse_value =
- choice
- [ val_to_expr parse_bool
- ; val_to_expr parse_char
- ; val_to_expr parse_int
- ; val_to_expr parse_null
- ; val_to_expr parse_val_string
- ]
- <|> fail "Value error"
-;;
-
-let parse_id =
- take_while is_token_sym
- >>= fun str ->
- match not (String.is_empty str || in_reserved str || Char.is_digit str.[0]) with
- | true -> return (Id str)
- | _ -> fail "Not an identifier"
-;;
-
-(* Expressions *)
-
-(* Variables && functions *)
-let parse_var_type =
- choice ?failure_msg:(Some "Incorrect type") [ parse_base_type ]
- >>= fun x -> return (TypeVar x)
-;;
-
-let parse_var =
- let parse_decl_id typ_ =
- char ' ' *> skip_spaces *> parse_id >>| fun id -> Var (typ_, id)
- in
- skip_spaces *> parse_var_type >>= parse_decl_id
-;;
-
-let parse_id_expr = skip_spaces *> (parse_id >>| fun x -> EId x) <* skip_spaces
-let parse_call_id = parse_id_expr
-let parse_args_list arg = parens @@ sep_by (skip_spaces *> char ',') arg
-
-let parse_call_args id arg =
- parse_args_list arg >>= fun args -> return @@ EFuncCall (id, args)
-;;
-
-let parse_call_expr arg = parse_call_id >>= fun id -> parse_call_args id arg
-
-(* Operations *)
-let parse_op op typ = skip_spaces *> string op *> return typ
-
-(* Binary operations *)
-let parse_bin_op op typ = parse_op op typ >>| fun t a b -> EBinOp (t, a, b)
-let ( ^+^ ) = parse_bin_op "+" OpAdd
-let ( ^-^ ) = parse_bin_op "-" OpSub
-let ( ^*^ ) = parse_bin_op "*" OpMul
-let ( ^/^ ) = parse_bin_op "/" OpDiv
-let ( ^%^ ) = parse_bin_op "%" OpMod
-let ( ^==^ ) = parse_bin_op "==" OpEqual
-let ( ^!=^ ) = parse_bin_op "!=" OpNonEqual
-let ( ^<^ ) = parse_bin_op "<" OpLess
-let ( ^>^ ) = parse_bin_op ">" OpMore
-let ( ^<=^ ) = parse_bin_op "<=" OpLessEqual
-let ( ^>=^ ) = parse_bin_op ">=" OpMoreEqual
-let ( ^&&^ ) = parse_bin_op "&&" OpAnd
-let ( ^||^ ) = parse_bin_op "||" OpOr
-let ( ^=^ ) = parse_bin_op "=" OpAssign
-
-(* Unary operations *)
-let parse_un_op op typ = parse_op op typ >>| fun t a -> EUnOp (t, a)
-let ( ^!^ ) = parse_un_op "!" OpNot
-
-let parse_ops =
- fix (fun expr ->
- let lv1 = choice [ parens expr; parse_value; parse_call_expr expr; parse_id_expr ] in
- let lv2 = chainl0 lv1 (choice [ ( ^!^ ) ]) in
- let lv3 = chainl1 lv2 (choice [ ( ^*^ ); ( ^/^ ); ( ^%^ ) ]) in
- let lv4 = chainl1 lv3 (choice [ ( ^+^ ); ( ^-^ ) ]) in
- let lv5 = chainl1 lv4 (choice [ ( ^<=^ ); ( ^>=^ ); ( ^<^ ); ( ^>^ ) ]) in
- let lv6 = chainl1 lv5 (choice [ ( ^==^ ); ( ^!=^ ) ]) in
- let lv7 = chainl1 lv6 (choice [ ( ^&&^ ) ]) in
- let lv8 = chainl1 lv7 (choice [ ( ^||^ ) ]) in
- chainr1 lv8 (choice [ ( ^=^ ) ]))
- <|> fail "Expr error"
-;;
-
-let parse_assign =
- lift3 (fun id eq ex -> eq id ex) parse_id_expr ( ^=^ ) parse_ops <|> fail "Assign error"
-;;
-
-(* Statements *)
-
-let get_opt p = p >>| fun x -> Some x
-
-let parse_decl =
- lift2
- (fun dcl e -> SDecl (dcl, e))
- parse_var
- (option None (skip_spaces *> char '=' *> parse_ops >>| fun e -> Some e))
-;;
-
-let expr_to_stmt expr = expr >>| fun x -> SExpr x
-let parse_stmt_ops = expr_to_stmt @@ choice [ parse_assign; parse_call_expr parse_ops ]
-
-let parse_if_else f_if_body =
- let parse_if_cond = string "if" *> skip_spaces *> parens parse_ops in
- let parse_else_cond ifls body =
- skip_spaces
- *> (get_opt @@ (string "else" *> skip_spaces *> choice [ ifls; body ]) <|> return None)
- in
- fix (fun ifls ->
- let parse_body = f_if_body <|> (parse_stmt_ops <* skip_semicolons1) in
- let parse_else_body = parse_else_cond ifls parse_body in
- lift3
- (fun cond if_body else_body -> SIf (cond, if_body, else_body))
- parse_if_cond
- parse_body
- parse_else_body)
- <|> fail "If error"
-;;
-
-let parse_for body =
- let expr_to_option_stmt expr = get_opt @@ expr_to_stmt expr in
- let p_body = body <|> (parse_stmt_ops <* skip_semicolons1) in
- let p_for_init =
- option None (get_opt parse_decl <|> expr_to_option_stmt parse_assign)
- in
- let p_for_expr = option None (get_opt parse_ops) in
- let p_for =
- lift2
- (fun (f_init_p, f_cond_p, f_iter_p) f_body ->
- SFor (f_init_p, f_cond_p, f_iter_p, f_body))
- (parens
- @@ lift3
- (fun init cond incr -> init, cond, incr)
- (p_for_init <* skip_spaces <* char ';')
- (p_for_expr <* skip_spaces <* char ';')
- p_for_expr)
- p_body
- in
- string "for" *> p_for <|> fail "For error"
-;;
-
-let parse_while body =
- let p_body = body <|> skip_semicolons1 *> parse_stmt_ops in
- let p_cond = parens parse_ops in
- let p_while = string "while" *> skip_spaces *> p_cond in
- lift2 (fun cond body -> SWhile (cond, body)) p_while p_body <|> fail "While error"
-;;
-
-let parse_return =
- lift2
- (fun _ expr -> SReturn expr)
- (string "return")
- (parse_ops >>= (fun ret -> return (Some ret)) <|> return None)
- <|> fail "Return error"
-;;
-
-let parse_break = skip_spaces *> string "break" *> return SBreak <|> fail "Break error"
-
-let parse_continue =
- skip_spaces *> string "continue" *> return SContinue <|> fail "Continue error"
-;;
-
-let parse_block =
- fix (fun block ->
- let sc p = p <* skip_semicolons1 in
- let op_sc p = p <* skip_semicolons in
- let body_step =
- choice
- ?failure_msg:(Some "Error in some block sentence")
- [ sc parse_decl
- ; sc parse_break
- ; sc parse_continue
- ; sc parse_return
- ; sc parse_stmt_ops
- ; op_sc @@ parse_if_else block
- ; op_sc @@ parse_for block
- ; op_sc @@ parse_while block
- ]
- in
- braces (skip_semicolons *> many (skip_spaces *> body_step))
- >>= fun stmt_lst -> return @@ SBlock stmt_lst)
-;;
-
-(* Program class functions *)
-let parse_field_sign =
- let f_value = skip_spaces *> char '=' *> get_opt parse_ops in
- lift4
- (fun f_modif f_type f_id f_val -> f_modif, f_type, f_id, f_val)
- (skip_spaces *> parse_modifiers)
- (skip_spaces *> parse_var_type)
- (skip_spaces *> parse_id)
- (option None f_value)
- <* skip_semicolons1
-;;
-
-let parse_method_type =
- let parse_void = string "void" *> return TypeVoid in
- choice ?failure_msg:(Some "Not a method type") [ parse_base_type; parse_void ]
-;;
-
-let parse_method_sign =
- let parse_args =
- parens @@ sep_by (skip_spaces *> char ',' <* skip_spaces) parse_var
- >>= fun exp -> return (Params exp)
- in
- lift4
- (fun m_modif m_type m_id m_params -> m_modif, m_type, m_id, m_params)
- (skip_spaces *> parse_modifiers)
- (skip_spaces *> parse_method_type)
- (skip_spaces *> parse_id)
- (skip_spaces *> parse_args)
-;;
-
-let parse_method_member =
- lift2
- (fun (mds, tp, id, ps) bd -> Method (mds, tp, id, ps, bd))
- parse_method_sign
- parse_block
-;;
-
-let parse_field_member =
- parse_field_sign
- >>| function
- | mds, tp, id, Some ex -> VarField (mds, tp, id, Some (EBinOp (OpAssign, EId id, ex)))
- | mds, tp, id, None -> VarField (mds, tp, id, None)
-;;
-
-let parse_class_members =
- let member =
- choice ?failure_msg:(Some "Method error") [ parse_method_member; parse_field_member ]
- in
- braces @@ sep_by skip_spaces member
-;;
-
-let parse_class =
- let class_id =
- skip_spaces *> string "class" *> skip_spaces *> parse_id <|> fail "Class sign error"
- in
- lift3
- (fun cl_mdf cl_id cl_mbs -> Class (cl_mdf, cl_id, cl_mbs))
- (skip_spaces *> parse_modifiers)
- class_id
- parse_class_members
-;;
-
-let parse_prog : program t = parse_class <* skip_spaces >>| fun prog -> Program prog
-
-(* Main functions *)
-
-let apply_parser parser = parse_string ~consume:Consume.All parser
-
-let parse_option p str =
- match apply_parser p str with
- | Ok x -> Some x
- | Error _ -> None
-;;
diff --git a/CSharpStrange/lib/parser.mli b/CSharpStrange/lib/parser.mli
deleted file mode 100644
index 730e660bb..000000000
--- a/CSharpStrange/lib/parser.mli
+++ /dev/null
@@ -1,28 +0,0 @@
-(** Copyright 2025, Dmitrii Kuznetsov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-open Angstrom
-open Base
-
-val parens : 'a t -> 'a t
-val braces : 'a t -> 'a t
-val brackets : 'a t -> 'a t
-val parse_int : val_type t
-val parse_char : val_type t
-val parse_bool : val_type t
-val parse_val_string : val_type t
-val parse_modifiers : modifier list t
-val parse_ops : expr t
-val parse_decl : stmt t
-val parse_return : stmt t
-val parse_break : stmt t
-val parse_continue : stmt t
-val parse_block : stmt t
-val parse_method_member : field t
-val parse_field_member : field t
-val parse_class : c_sharp_class t
-val parse_prog : program t
-val apply_parser : 'a t -> string -> ('a, string) Result.t
-val parse_option : 'a t -> string -> 'a option
diff --git a/CSharpStrange/lib/prettyprinter.ml b/CSharpStrange/lib/prettyprinter.ml
deleted file mode 100644
index a8e971cfa..000000000
--- a/CSharpStrange/lib/prettyprinter.ml
+++ /dev/null
@@ -1,165 +0,0 @@
-(** Copyright 2025, Dmitrii Kuznetsov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Format
-open Ast
-
-let pp_list : 'a. (formatter -> 'a -> unit) -> string -> formatter -> 'a list -> unit =
- fun pp sep fmt lst ->
- let rec aux fmt = function
- | [] -> ()
- | [ x ] -> pp fmt x
- | x :: xs -> fprintf fmt "%a%s%a" pp x sep aux xs
- in
- aux fmt lst
-;;
-
-let pp_option : 'a. (formatter -> 'a -> unit) -> formatter -> 'a option -> unit =
- fun pp fmt -> function
- | None -> fprintf fmt ""
- | Some x -> pp fmt x
-;;
-
-let pp_ident fmt (Id s) = fprintf fmt "%s" s
-
-let pp_base_type fmt = function
- | TypeInt -> fprintf fmt "int"
- | TypeChar -> fprintf fmt "char"
- | TypeBool -> fprintf fmt "bool"
- | TypeString -> fprintf fmt "string"
-;;
-
-let pp_type fmt = function
- | TypeBase bt -> pp_base_type fmt bt
- | TypeVoid -> fprintf fmt "void"
-;;
-
-let pp_var_type fmt (TypeVar t) = pp_type fmt t
-
-let pp_modifier fmt = function
- | MPublic -> fprintf fmt "public"
- | MStatic -> fprintf fmt "static"
- | MAsync -> fprintf fmt "async"
-;;
-
-let pp_var_decl fmt (Var (vt, id)) = fprintf fmt "%a %a" pp_var_type vt pp_ident id
-
-let pp_bin_op fmt = function
- | OpAdd -> fprintf fmt "+"
- | OpSub -> fprintf fmt "-"
- | OpMul -> fprintf fmt "*"
- | OpDiv -> fprintf fmt "/"
- | OpMod -> fprintf fmt "%%"
- | OpEqual -> fprintf fmt "=="
- | OpNonEqual -> fprintf fmt "!="
- | OpLess -> fprintf fmt "<"
- | OpMore -> fprintf fmt ">"
- | OpLessEqual -> fprintf fmt "<="
- | OpMoreEqual -> fprintf fmt ">="
- | OpAnd -> fprintf fmt "&&"
- | OpOr -> fprintf fmt "||"
- | OpAssign -> fprintf fmt "="
-;;
-
-let pp_un_op fmt = function
- | OpNot -> fprintf fmt "!"
-;;
-
-let pp_val_type fmt = function
- | ValInt n -> fprintf fmt "%d" n
- | ValChar c -> fprintf fmt "'%c'" c
- | ValNull -> fprintf fmt "null"
- | ValBool b -> fprintf fmt "%b" b
- | ValString s -> fprintf fmt {|%S|} s
-;;
-
-let rec pp_expr fmt = function
- | EValue v -> pp_val_type fmt v
- | EBinOp (op, e1, e2) -> fprintf fmt "(%a %a %a)" pp_expr e1 pp_bin_op op pp_expr e2
- | EUnOp (op, e) -> fprintf fmt "(%a%a)" pp_un_op op pp_expr e
- | EId id -> pp_ident fmt id
- | EArrayAccess (e1, e2) -> fprintf fmt "%a[%a]" pp_expr e1 pp_expr e2
- | EFuncCall (e, args) -> fprintf fmt "%a(%a)" pp_expr e (pp_list pp_expr ", ") args
- | EAwait e -> fprintf fmt "await %a" pp_expr e
-;;
-
-let rec pp_stmt fmt = function
- | SFor (init, cond, incr, body) ->
- fprintf
- fmt
- "@[for (%a; %a; %a) {@ %a@]@ }"
- (pp_option pp_stmt)
- init
- (pp_option pp_expr)
- cond
- (pp_option pp_expr)
- incr
- pp_stmt
- body
- | SIf (cond, then_branch, else_branch) ->
- fprintf
- fmt
- "@[if (%a) {@ %a@]@ }%a"
- pp_expr
- cond
- pp_stmt
- then_branch
- (pp_option (fun fmt -> fprintf fmt "@ @[else {@ %a@]@ }" pp_stmt))
- else_branch
- | SWhile (cond, body) ->
- fprintf fmt "@[while (%a) {@ %a@]@ }" pp_expr cond pp_stmt body
- | SReturn e -> fprintf fmt "return %a;" (pp_option pp_expr) e
- | SBlock stmts -> pp_sblock fmt stmts
- | SBreak -> fprintf fmt "break;"
- | SContinue -> fprintf fmt "continue;"
- | SExpr e -> fprintf fmt "%a;" pp_expr e
- | SDecl (vd, e) -> fprintf fmt "%a = %a;" pp_var_decl vd (pp_option pp_expr) e
-
-and pp_sblock fmt = function
- | [] -> fprintf fmt ""
- | stmts -> fprintf fmt "@[%a@]" (pp_list pp_stmt "@ ") stmts
-;;
-
-let pp_field fmt = function
- | VarField (mods, t, id, e) ->
- fprintf
- fmt
- "@[%a %a %a = %a;@]"
- (pp_list pp_modifier " ")
- mods
- pp_var_type
- t
- pp_ident
- id
- (pp_option pp_expr)
- e
- | Method (mods, t, id, Params params, body) ->
- fprintf
- fmt
- "@[%a %a %a(%a)@ @[{@ %a@]@ @[}@]@ "
- (pp_list pp_modifier " ")
- mods
- pp_type
- t
- pp_ident
- id
- (pp_list pp_var_decl ", ")
- params
- pp_stmt
- body
-;;
-
-let pp_c_sharp_class fmt (Class (mods, id, fields)) =
- fprintf
- fmt
- "@[%a class %a@ @[{@ %a@]@ @[}@]"
- (pp_list pp_modifier " ")
- mods
- pp_ident
- id
- (pp_list pp_field " ")
- fields
-;;
-
-let pp_prog fmt (Program cls) = pp_c_sharp_class fmt cls
diff --git a/CSharpStrange/lib/prettyprinter.mli b/CSharpStrange/lib/prettyprinter.mli
deleted file mode 100644
index 949077e67..000000000
--- a/CSharpStrange/lib/prettyprinter.mli
+++ /dev/null
@@ -1,7 +0,0 @@
-(** Copyright 2025, Dmitrii Kuznetsov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-
-val pp_prog : Format.formatter -> program -> unit
diff --git a/CSharpStrange/tests/ast_fact.t b/CSharpStrange/tests/ast_fact.t
deleted file mode 100644
index f62ed32b9..000000000
--- a/CSharpStrange/tests/ast_fact.t
+++ /dev/null
@@ -1,25 +0,0 @@
- $ ../bin/REPL.exe -parseast -filepath="../bin/factorial.cs"
- (Program
- (Class ([MPublic], (Id "Program"),
- [(Method ([MPublic], (TypeBase TypeInt), (Id "Factorial"),
- (Params [(Var ((TypeVar (TypeBase TypeInt)), (Id "n")))]),
- (SBlock
- [(SIf ((EBinOp (OpEqual, (EId (Id "n")), (EValue (ValInt 0)))),
- (SBlock [(SReturn (Some (EValue (ValInt 1))))]),
- (Some (SBlock
- [(SReturn
- (Some (EBinOp (OpMul, (EId (Id "n")),
- (EFuncCall ((EId (Id "Factorial")),
- [(EBinOp (OpSub, (EId (Id "n")),
- (EValue (ValInt 1))))
- ]
- ))
- ))))
- ]))
- ))
- ])
- ));
- (Method ([MPublic; MStatic], TypeVoid, (Id "Main"), (Params []),
- (SBlock [])))
- ]
- )))
diff --git a/CSharpStrange/tests/dune b/CSharpStrange/tests/dune
deleted file mode 100644
index f112a01f1..000000000
--- a/CSharpStrange/tests/dune
+++ /dev/null
@@ -1,14 +0,0 @@
-(library
- (name tests)
- (public_name CSharpStrange.Lib.Tests)
- (modules Parser_tests Pp_tests)
- (libraries angstrom c_sharp_strange_lib)
- (inline_tests)
- (instrumentation
- (backend bisect_ppx))
- (preprocess
- (pps ppx_expect)))
-
-(cram
- (applies_to ast_fact)
- (deps ../bin/REPL.exe ../bin/factorial.cs))
diff --git a/CSharpStrange/tests/parser_tests.ml b/CSharpStrange/tests/parser_tests.ml
deleted file mode 100644
index bcc62dba8..000000000
--- a/CSharpStrange/tests/parser_tests.ml
+++ /dev/null
@@ -1,422 +0,0 @@
-(** Copyright 2025, Dmitrii Kuznetsov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open C_sharp_strange_lib.Ast
-open C_sharp_strange_lib.Parser
-
-let%test "Parse one integer" = apply_parser parse_int {|1|} = Ok (ValInt 1)
-let%test "Parse one char" = apply_parser parse_char {|'c'|} = Ok (ValChar 'c')
-let%test "Parse true" = apply_parser parse_bool {|true|} = Ok (ValBool true)
-let%test "Parse false" = apply_parser parse_bool {|false|} = Ok (ValBool false)
-
-let%test "Parse string" =
- apply_parser parse_val_string {|"sample"|} = Ok (ValString "sample")
-;;
-
-let%test "Parse parens" = apply_parser (parens parse_int) {|(1)|} = Ok (ValInt 1)
-let%test "Parse braces" = apply_parser (braces parse_int) {|{1}|} = Ok (ValInt 1)
-let%test "Parse brackets" = apply_parser (brackets parse_int) {|[1]|} = Ok (ValInt 1)
-let%test "Parse one modifier 1" = apply_parser parse_modifiers {|static|} = Ok [ MStatic ]
-let%test "Parse one modifier 2" = apply_parser parse_modifiers {|public|} = Ok [ MPublic ]
-
-let%test "Parse two modifiers" =
- apply_parser parse_modifiers {|public async|} = Ok [ MPublic; MAsync ]
-;;
-
-let%test "Parse add 1" =
- apply_parser parse_ops {| 1 + 2|}
- = Ok (EBinOp (OpAdd, EValue (ValInt 1), EValue (ValInt 2)))
-;;
-
-let%test "Parse add 2" =
- apply_parser parse_ops {| a + b|} = Ok (EBinOp (OpAdd, EId (Id "a"), EId (Id "b")))
-;;
-
-let%test "Parse many adds" =
- apply_parser parse_ops {| 1 + 2 + 3|}
- = Ok
- (EBinOp
- (OpAdd, EBinOp (OpAdd, EValue (ValInt 1), EValue (ValInt 2)), EValue (ValInt 3)))
-;;
-
-let%test "Parse adds with mul 1" =
- apply_parser parse_ops {|1 + 2 * 3|}
- = Ok
- (EBinOp
- (OpAdd, EValue (ValInt 1), EBinOp (OpMul, EValue (ValInt 2), EValue (ValInt 3))))
-;;
-
-let%test "Parse adds with mul 2" =
- apply_parser parse_ops {| (1 + 2 ) * 3|}
- = Ok
- (EBinOp
- (OpMul, EBinOp (OpAdd, EValue (ValInt 1), EValue (ValInt 2)), EValue (ValInt 3)))
-;;
-
-let%test "Parse div with mod" =
- apply_parser parse_ops {| 1 / 2 % 3|}
- = Ok
- (EBinOp
- (OpMod, EBinOp (OpDiv, EValue (ValInt 1), EValue (ValInt 2)), EValue (ValInt 3)))
-;;
-
-let%test "Parse div with mod" =
- apply_parser parse_ops {| 1 - 2 / 3 + 4|}
- = Ok
- (EBinOp
- ( OpAdd
- , EBinOp
- ( OpSub
- , EValue (ValInt 1)
- , EBinOp (OpDiv, EValue (ValInt 2), EValue (ValInt 3)) )
- , EValue (ValInt 4) ))
-;;
-
-let%test "Parse simple boolean expression" =
- apply_parser parse_ops {| ( 1 + 2 == 3 + 4 )|}
- = Ok
- (EBinOp
- ( OpEqual
- , EBinOp (OpAdd, EValue (ValInt 1), EValue (ValInt 2))
- , EBinOp (OpAdd, EValue (ValInt 3), EValue (ValInt 4)) ))
-;;
-
-let%test "Parse complex boolean expression" =
- apply_parser parse_ops {|( 1 + 2 < 3 + 4) && (5 == 8)|}
- = Ok
- (EBinOp
- ( OpAnd
- , EBinOp
- ( OpLess
- , EBinOp (OpAdd, EValue (ValInt 1), EValue (ValInt 2))
- , EBinOp (OpAdd, EValue (ValInt 3), EValue (ValInt 4)) )
- , EBinOp (OpEqual, EValue (ValInt 5), EValue (ValInt 8)) ))
-;;
-
-let%test "Parse ident expr" = apply_parser parse_ops {| x|} = Ok (EId (Id "x"))
-let%test "Parse id in expressions 1" = apply_parser parse_ops {| x|} = Ok (EId (Id "x"))
-
-let%test "Parse id in expressions 2" =
- apply_parser parse_ops {|x + 1|} = Ok (EBinOp (OpAdd, EId (Id "x"), EValue (ValInt 1)))
-;;
-
-let%test "Parse var declaration 1" =
- apply_parser parse_decl {|int x|}
- = Ok (SDecl (Var (TypeVar (TypeBase TypeInt), Id "x"), None))
-;;
-
-let%test "Parse var declaration 2" =
- apply_parser parse_decl {|int x = 1|}
- = Ok (SDecl (Var (TypeVar (TypeBase TypeInt), Id "x"), Some (EValue (ValInt 1))))
-;;
-
-let%test "Parse multiple var declarations" =
- apply_parser parse_decl {|int x = y = z = 1|}
- = Ok
- (SDecl
- ( Var (TypeVar (TypeBase TypeInt), Id "x")
- , Some
- (EBinOp
- ( OpAssign
- , EId (Id "y")
- , EBinOp (OpAssign, EId (Id "z"), EValue (ValInt 1)) )) ))
-;;
-
-let%test "Parse return 1" =
- apply_parser parse_return {|return 5|} = Ok (SReturn (Some (EValue (ValInt 5))))
-;;
-
-let%test "Parse return 2" = apply_parser parse_return {|return|} = Ok (SReturn None)
-let%test "Parse break" = apply_parser parse_break {|break|} = Ok SBreak
-let%test "Parse continue" = apply_parser parse_continue {|continue|} = Ok SContinue
-let%test "Parse empty block 1" = apply_parser parse_block {|{}|} = Ok (SBlock [])
-let%test "Parse empty block 2" = apply_parser parse_block {|{;;;;}|} = Ok (SBlock [])
-
-let%test "Parse block 1" =
- apply_parser parse_block {|{return 5;}|}
- = Ok (SBlock [ SReturn (Some (EValue (ValInt 5))) ])
-;;
-
-let%test "Parse block 2" =
- apply_parser parse_block {|{int x = 6; x = 6 + 1; return x;}|}
- = Ok
- (SBlock
- [ SDecl (Var (TypeVar (TypeBase TypeInt), Id "x"), Some (EValue (ValInt 6)))
- ; SExpr
- (EBinOp
- ( OpAssign
- , EId (Id "x")
- , EBinOp (OpAdd, EValue (ValInt 6), EValue (ValInt 1)) ))
- ; SReturn (Some (EId (Id "x")))
- ])
-;;
-
-let%test "Parse while" =
- apply_parser
- parse_block
- {|
- {
- int x = 1;
- while ( x < 1 )
- {
- x = 2;
- break;
- continue;
- }
- }|}
- = Ok
- (SBlock
- [ SDecl (Var (TypeVar (TypeBase TypeInt), Id "x"), Some (EValue (ValInt 1)))
- ; SWhile
- ( EBinOp (OpLess, EId (Id "x"), EValue (ValInt 1))
- , SBlock
- [ SExpr (EBinOp (OpAssign, EId (Id "x"), EValue (ValInt 2)))
- ; SBreak
- ; SContinue
- ] )
- ])
-;;
-
-let%test "Parse for" =
- apply_parser
- parse_block
- {|{
- for (int i = 1;i < 5; i = i+1)
- {
- i = i + 1;
- }
- }|}
- = Ok
- (SBlock
- [ SFor
- ( Some
- (SDecl
- (Var (TypeVar (TypeBase TypeInt), Id "i"), Some (EValue (ValInt 1))))
- , Some (EBinOp (OpLess, EId (Id "i"), EValue (ValInt 5)))
- , Some
- (EBinOp
- ( OpAssign
- , EId (Id "i")
- , EBinOp (OpAdd, EId (Id "i"), EValue (ValInt 1)) ))
- , SBlock
- [ SExpr
- (EBinOp
- ( OpAssign
- , EId (Id "i")
- , EBinOp (OpAdd, EId (Id "i"), EValue (ValInt 1)) ))
- ] )
- ])
-;;
-
-let%test "Parse if" =
- apply_parser
- parse_block
- {|{if (x == 5)
- x=1;
- else if (x == 2)
- {
- x=2;
- }
- }|}
- = Ok
- (SBlock
- [ SIf
- ( EBinOp (OpEqual, EId (Id "x"), EValue (ValInt 5))
- , SExpr (EBinOp (OpAssign, EId (Id "x"), EValue (ValInt 1)))
- , Some
- (SIf
- ( EBinOp (OpEqual, EId (Id "x"), EValue (ValInt 2))
- , SBlock
- [ SExpr (EBinOp (OpAssign, EId (Id "x"), EValue (ValInt 2))) ]
- , None )) )
- ])
-;;
-
-let%test "Parse field 1" =
- apply_parser parse_field_member {|public int X;|}
- = Ok (VarField ([ MPublic ], TypeVar (TypeBase TypeInt), Id "X", None))
-;;
-
-let%test "Parse field 2" =
- apply_parser parse_field_member {|public int X = 1;|}
- = Ok
- (VarField
- ( [ MPublic ]
- , TypeVar (TypeBase TypeInt)
- , Id "X"
- , Some (EBinOp (OpAssign, EId (Id "X"), EValue (ValInt 1))) ))
-;;
-
-let%test "Parse method 1" =
- apply_parser parse_method_member {|public int Func() {}|}
- = Ok (Method ([ MPublic ], TypeBase TypeInt, Id "Func", Params [], SBlock []))
-;;
-
-let%test "Parse method 2" =
- apply_parser parse_method_member {|public int Func()
- {
- return 2;
- }|}
- = Ok
- (Method
- ( [ MPublic ]
- , TypeBase TypeInt
- , Id "Func"
- , Params []
- , SBlock [ SReturn (Some (EValue (ValInt 2))) ] ))
-;;
-
-let%test "Parse method 3" =
- apply_parser
- parse_method_member
- {|public int Factorial(int n)
- {
- if (n == 0)
- {
- return 1;
- }
- else
- {
- return n * Factorial(n - 1);
- }
- }|}
- = Ok
- (Method
- ( [ MPublic ]
- , TypeBase TypeInt
- , Id "Factorial"
- , Params [ Var (TypeVar (TypeBase TypeInt), Id "n") ]
- , SBlock
- [ SIf
- ( EBinOp (OpEqual, EId (Id "n"), EValue (ValInt 0))
- , SBlock [ SReturn (Some (EValue (ValInt 1))) ]
- , Some
- (SBlock
- [ SReturn
- (Some
- (EBinOp
- ( OpMul
- , EId (Id "n")
- , EFuncCall
- ( EId (Id "Factorial")
- , [ EBinOp (OpSub, EId (Id "n"), EValue (ValInt 1))
- ] ) )))
- ]) )
- ] ))
-;;
-
-let%test "Parse class 1" =
- apply_parser parse_class {|
- public class Sample {}|}
- = Ok (Class ([ MPublic ], Id "Sample", []))
-;;
-
-let%test "Parse class 2" =
- apply_parser
- parse_class
- {|
- public class Sample {
- public int X;
- public int Y = 1;
- }|}
- = Ok
- (Class
- ( [ MPublic ]
- , Id "Sample"
- , [ VarField ([ MPublic ], TypeVar (TypeBase TypeInt), Id "X", None)
- ; VarField
- ( [ MPublic ]
- , TypeVar (TypeBase TypeInt)
- , Id "Y"
- , Some (EBinOp (OpAssign, EId (Id "Y"), EValue (ValInt 1))) )
- ] ))
-;;
-
-let%test "Parse class 3" =
- apply_parser
- parse_class
- {|
- public class Sample {
-
- public int X;
-
- public int add(int x) {
- X = X + x;
- }
- }|}
- = Ok
- (Class
- ( [ MPublic ]
- , Id "Sample"
- , [ VarField ([ MPublic ], TypeVar (TypeBase TypeInt), Id "X", None)
- ; Method
- ( [ MPublic ]
- , TypeBase TypeInt
- , Id "add"
- , Params [ Var (TypeVar (TypeBase TypeInt), Id "x") ]
- , SBlock
- [ SExpr
- (EBinOp
- ( OpAssign
- , EId (Id "X")
- , EBinOp (OpAdd, EId (Id "X"), EId (Id "x")) ))
- ] )
- ] ))
-;;
-
-let%test "Parse factorial" =
- apply_parser
- parse_prog
- {|
- public class Program
- {
- public static void Main() {}
-
- public int Factorial(int n)
- {
- if (n == 0)
- {
- return 1;
- }
- else
- {
- return n * Factorial(n - 1);
- }
- }
- }
-
- |}
- = Ok
- (Program
- (Class
- ( [ MPublic ]
- , Id "Program"
- , [ Method ([ MPublic; MStatic ], TypeVoid, Id "Main", Params [], SBlock [])
- ; Method
- ( [ MPublic ]
- , TypeBase TypeInt
- , Id "Factorial"
- , Params [ Var (TypeVar (TypeBase TypeInt), Id "n") ]
- , SBlock
- [ SIf
- ( EBinOp (OpEqual, EId (Id "n"), EValue (ValInt 0))
- , SBlock [ SReturn (Some (EValue (ValInt 1))) ]
- , Some
- (SBlock
- [ SReturn
- (Some
- (EBinOp
- ( OpMul
- , EId (Id "n")
- , EFuncCall
- ( EId (Id "Factorial")
- , [ EBinOp
- ( OpSub
- , EId (Id "n")
- , EValue (ValInt 1) )
- ] ) )))
- ]) )
- ] )
- ] )))
-;;
diff --git a/CSharpStrange/tests/parser_tests.mli b/CSharpStrange/tests/parser_tests.mli
deleted file mode 100644
index 2a5ede905..000000000
--- a/CSharpStrange/tests/parser_tests.mli
+++ /dev/null
@@ -1,3 +0,0 @@
-(** Copyright 2025, Dmitrii Kuznetsov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
diff --git a/CSharpStrange/tests/pp_tests.ml b/CSharpStrange/tests/pp_tests.ml
deleted file mode 100644
index af45e6841..000000000
--- a/CSharpStrange/tests/pp_tests.ml
+++ /dev/null
@@ -1,119 +0,0 @@
-(** Copyright 2025, Dmitrii Kuznetsov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open C_sharp_strange_lib.Prettyprinter
-open C_sharp_strange_lib.Parser
-open Format
-
-let fact_str =
- {|
-public class Program
-{
- public int Factorial(int n)
- {
- if (n == 0)
- {
- return 1;
- }
- else
- {
- return n * Factorial(n - 1);
- }
- }
-
- public static void Main()
- {
-
- }
-}
-
-|}
-;;
-
-let fact_prog = parse_option parse_prog fact_str
-
-let pretty_fact_str = function
- | Some x -> asprintf "%a" pp_prog x
- | None -> ""
-;;
-
-let parse_after_pp prog = parse_option parse_prog (pretty_fact_str prog)
-let%test "Factorial pp" = parse_after_pp fact_prog = fact_prog
-
-let cycles_str =
- {|
-public class Program
-{
- public int Cycles(int n, bool e, string x)
- {
- int x = 0;
- while (x < n)
- {
- if (x == -1)
- {
- break;
- }
-
- if (x == -2)
- {
- continue;
- }
-
- x = x + 1;
- }
-
- for (int i = 1; i < n; i++)
- {
- break;
- }
-
- for (;;)
- {
- break;
- }
-
- for (int i = 1;; i++)
- {
- break;
- }
- }
-
- public static void Main()
- {
- Cycles(5, true, "sample");
- }
-}
-|}
-;;
-
-let cycles_prog = parse_option parse_prog cycles_str
-let%test "Cycles pp" = parse_after_pp cycles_prog = cycles_prog
-
-let binops_prog =
- parse_option
- parse_prog
- {|
-
-public class Program
-{
- public int Binops(int n, bool e, string x)
- {
- int x_ = n;
- bool sample = !e || ((1 + 2 < 3 + 4) && (5 == 8));
- string e = x;
- char eeAe065ef = 'a';
- e = null;
- const int a = 1;
- }
-
-
- public static void Main()
- {
- Binops(5, true, "");
- }
-}
-|}
-;;
-
-let%test "Binops pp" = parse_after_pp binops_prog = binops_prog
diff --git a/CSharpStrange/tests/pp_tests.mli b/CSharpStrange/tests/pp_tests.mli
deleted file mode 100644
index 2a5ede905..000000000
--- a/CSharpStrange/tests/pp_tests.mli
+++ /dev/null
@@ -1,3 +0,0 @@
-(** Copyright 2025, Dmitrii Kuznetsov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
diff --git a/EChirkov/.envrc b/EChirkov/.envrc
deleted file mode 100644
index e6bd6786d..000000000
--- a/EChirkov/.envrc
+++ /dev/null
@@ -1,3 +0,0 @@
-export OPAMSWITCH=4.14.2+flambda
-eval $(opam env)
-
diff --git a/EChirkov/.gitignore b/EChirkov/.gitignore
deleted file mode 100644
index 7102a822c..000000000
--- a/EChirkov/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-_build
-_coverage
-/_esy
-/node_modules
-/esy.lock
-/.melange.eobjs
diff --git a/EChirkov/.ocamlformat b/EChirkov/.ocamlformat
deleted file mode 100644
index 97f970802..000000000
--- a/EChirkov/.ocamlformat
+++ /dev/null
@@ -1,2 +0,0 @@
-profile=janestreet
-version=0.26.2
diff --git a/EChirkov/.zanuda b/EChirkov/.zanuda
deleted file mode 100644
index 0f09b19b2..000000000
--- a/EChirkov/.zanuda
+++ /dev/null
@@ -1 +0,0 @@
-forward mutability_check ignore REPL.ml
diff --git a/EChirkov/COPYING b/EChirkov/COPYING
deleted file mode 100644
index f288702d2..000000000
--- a/EChirkov/COPYING
+++ /dev/null
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is 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. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- 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.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- 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 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. Use with the GNU Affero General Public License.
-
- 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 Affero 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 special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU 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 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 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 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.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- Copyright (C)
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- 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 GPL, see
-.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-.
diff --git a/EChirkov/COPYING.CC0 b/EChirkov/COPYING.CC0
deleted file mode 100644
index 0e259d42c..000000000
--- a/EChirkov/COPYING.CC0
+++ /dev/null
@@ -1,121 +0,0 @@
-Creative Commons Legal Code
-
-CC0 1.0 Universal
-
- CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
- LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
- ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
- INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
- REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
- PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
- THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
- HEREUNDER.
-
-Statement of Purpose
-
-The laws of most jurisdictions throughout the world automatically confer
-exclusive Copyright and Related Rights (defined below) upon the creator
-and subsequent owner(s) (each and all, an "owner") of an original work of
-authorship and/or a database (each, a "Work").
-
-Certain owners wish to permanently relinquish those rights to a Work for
-the purpose of contributing to a commons of creative, cultural and
-scientific works ("Commons") that the public can reliably and without fear
-of later claims of infringement build upon, modify, incorporate in other
-works, reuse and redistribute as freely as possible in any form whatsoever
-and for any purposes, including without limitation commercial purposes.
-These owners may contribute to the Commons to promote the ideal of a free
-culture and the further production of creative, cultural and scientific
-works, or to gain reputation or greater distribution for their Work in
-part through the use and efforts of others.
-
-For these and/or other purposes and motivations, and without any
-expectation of additional consideration or compensation, the person
-associating CC0 with a Work (the "Affirmer"), to the extent that he or she
-is an owner of Copyright and Related Rights in the Work, voluntarily
-elects to apply CC0 to the Work and publicly distribute the Work under its
-terms, with knowledge of his or her Copyright and Related Rights in the
-Work and the meaning and intended legal effect of CC0 on those rights.
-
-1. Copyright and Related Rights. A Work made available under CC0 may be
-protected by copyright and related or neighboring rights ("Copyright and
-Related Rights"). Copyright and Related Rights include, but are not
-limited to, the following:
-
- i. the right to reproduce, adapt, distribute, perform, display,
- communicate, and translate a Work;
- ii. moral rights retained by the original author(s) and/or performer(s);
-iii. publicity and privacy rights pertaining to a person's image or
- likeness depicted in a Work;
- iv. rights protecting against unfair competition in regards to a Work,
- subject to the limitations in paragraph 4(a), below;
- v. rights protecting the extraction, dissemination, use and reuse of data
- in a Work;
- vi. database rights (such as those arising under Directive 96/9/EC of the
- European Parliament and of the Council of 11 March 1996 on the legal
- protection of databases, and under any national implementation
- thereof, including any amended or successor version of such
- directive); and
-vii. other similar, equivalent or corresponding rights throughout the
- world based on applicable law or treaty, and any national
- implementations thereof.
-
-2. Waiver. To the greatest extent permitted by, but not in contravention
-of, applicable law, Affirmer hereby overtly, fully, permanently,
-irrevocably and unconditionally waives, abandons, and surrenders all of
-Affirmer's Copyright and Related Rights and associated claims and causes
-of action, whether now known or unknown (including existing as well as
-future claims and causes of action), in the Work (i) in all territories
-worldwide, (ii) for the maximum duration provided by applicable law or
-treaty (including future time extensions), (iii) in any current or future
-medium and for any number of copies, and (iv) for any purpose whatsoever,
-including without limitation commercial, advertising or promotional
-purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
-member of the public at large and to the detriment of Affirmer's heirs and
-successors, fully intending that such Waiver shall not be subject to
-revocation, rescission, cancellation, termination, or any other legal or
-equitable action to disrupt the quiet enjoyment of the Work by the public
-as contemplated by Affirmer's express Statement of Purpose.
-
-3. Public License Fallback. Should any part of the Waiver for any reason
-be judged legally invalid or ineffective under applicable law, then the
-Waiver shall be preserved to the maximum extent permitted taking into
-account Affirmer's express Statement of Purpose. In addition, to the
-extent the Waiver is so judged Affirmer hereby grants to each affected
-person a royalty-free, non transferable, non sublicensable, non exclusive,
-irrevocable and unconditional license to exercise Affirmer's Copyright and
-Related Rights in the Work (i) in all territories worldwide, (ii) for the
-maximum duration provided by applicable law or treaty (including future
-time extensions), (iii) in any current or future medium and for any number
-of copies, and (iv) for any purpose whatsoever, including without
-limitation commercial, advertising or promotional purposes (the
-"License"). The License shall be deemed effective as of the date CC0 was
-applied by Affirmer to the Work. Should any part of the License for any
-reason be judged legally invalid or ineffective under applicable law, such
-partial invalidity or ineffectiveness shall not invalidate the remainder
-of the License, and in such case Affirmer hereby affirms that he or she
-will not (i) exercise any of his or her remaining Copyright and Related
-Rights in the Work or (ii) assert any associated claims and causes of
-action with respect to the Work, in either case contrary to Affirmer's
-express Statement of Purpose.
-
-4. Limitations and Disclaimers.
-
- a. No trademark or patent rights held by Affirmer are waived, abandoned,
- surrendered, licensed or otherwise affected by this document.
- b. Affirmer offers the Work as-is and makes no representations or
- warranties of any kind concerning the Work, express, implied,
- statutory or otherwise, including without limitation warranties of
- title, merchantability, fitness for a particular purpose, non
- infringement, or the absence of latent or other defects, accuracy, or
- the present or absence of errors, whether or not discoverable, all to
- the greatest extent permissible under applicable law.
- c. Affirmer disclaims responsibility for clearing rights of other persons
- that may apply to the Work or any use thereof, including without
- limitation any person's Copyright and Related Rights in the Work.
- Further, Affirmer disclaims responsibility for obtaining any necessary
- consents, permissions or other rights required for any use of the
- Work.
- d. Affirmer understands and acknowledges that Creative Commons is not a
- party to this document and has no duty or obligation with respect to
- this CC0 or use of the Work.
diff --git a/EChirkov/COPYING.LESSER b/EChirkov/COPYING.LESSER
deleted file mode 100644
index 0a041280b..000000000
--- a/EChirkov/COPYING.LESSER
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser 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
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/EChirkov/EChirkov.opam b/EChirkov/EChirkov.opam
deleted file mode 100644
index 94c130e52..000000000
--- a/EChirkov/EChirkov.opam
+++ /dev/null
@@ -1,33 +0,0 @@
-# This file is generated by dune, edit dune-project instead
-opam-version: "2.0"
-version: "0.1"
-synopsis: "An interpreter for miniml"
-description: "An interpreter for miniml"
-maintainer: ["Dmitri Chirkov"]
-authors: ["Dmitri Chirkov "]
-license: "LGPL-3.0-or-later"
-homepage: "https://github.com/kinokotakenoko9/MiniMl"
-bug-reports: "https://github.com/kinokotakenoko9/MiniMl"
-depends: [
- "dune" {>= "3.7"}
- "ppx_inline_test" {with-test}
- "ppx_expect"
- "ppx_deriving"
- "bisect_ppx"
- "odoc" {with-doc}
- "ocamlformat" {build}
-]
-build: [
- ["dune" "subst"] {dev}
- [
- "dune"
- "build"
- "-p"
- name
- "-j"
- jobs
- "@install"
- "@runtest" {with-test}
- "@doc" {with-doc}
- ]
-]
diff --git a/EChirkov/Makefile b/EChirkov/Makefile
deleted file mode 100644
index 79fbb624c..000000000
--- a/EChirkov/Makefile
+++ /dev/null
@@ -1,49 +0,0 @@
-.PHONY: repl tests test fmt lint celan
-
-all:
- dune build
-
-repl:
- dune build ./REPL.exe && rlwrap _build/default/REPL.exe
-
-tests: test
-test:
- dune runtest
-
-celan: clean
-clean:
- @$(RM) -r _build _coverage
-
-fmt:
- dune build @fmt --auto-promote
-
-lint:
- dune build @lint --force
-
-release:
- dune build --profile=release
- dune runtest --profile=release
-
-install:
- dune b @install --profile=release
- dune install
-
-ODIG_SWITCHES = --odoc-theme=odig.gruvbox.light
-ODIG_SWITCHES += --no-tag-index
-ODIG_SWITCHES += --no-pkg-deps
-odig:
- odig odoc $(ODIG_SWITCHES) Lambda
-
-TEST_COV_D = /tmp/cov
-COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect tests/
-
-.PHONY: test_coverage coverage
-test_coverage: coverage
-coverage:
- $(RM) -r $(TEST_COV_D)
- mkdir -p $(TEST_COV_D)
- BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \
- --instrument-with bisect_ppx --force
- bisect-ppx-report html $(COVERAGE_OPTS)
- bisect-ppx-report summary $(COVERAGE_OPTS)
- @echo "Use 'xdg-open _coverage/index.html' to see coverage report"
diff --git a/EChirkov/bin/dune b/EChirkov/bin/dune
deleted file mode 100644
index 5b2a8d229..000000000
--- a/EChirkov/bin/dune
+++ /dev/null
@@ -1,10 +0,0 @@
-(executable
- (name main)
- (public_name main)
- (modules main)
- (libraries EChirkov angstrom stdio base)
- (instrumentation
- (backend bisect_ppx)))
-
-(cram
- (deps ./main.exe %{bin:main}))
diff --git a/EChirkov/bin/main.ml b/EChirkov/bin/main.ml
deleted file mode 100644
index 1a092e471..000000000
--- a/EChirkov/bin/main.ml
+++ /dev/null
@@ -1,47 +0,0 @@
-(** Copyright 2024, Dmitri Chirkov*)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Stdio
-open EChirkov.Ast
-open EChirkov.Parser
-open EChirkov.Interpreter
-open EChirkov.Inferencer
-
-let usage () =
- printf "Usage: miniML [--interpret | --dump-ast | --infer] \n";
- Stdlib.exit 1
-;;
-
-let read_file filename =
- try In_channel.read_all filename with
- | Sys_error err ->
- printf "Error: %s\n" err;
- Stdlib.exit 1
-;;
-
-let () =
- if Array.length Stdlib.Sys.argv <> 3 then usage ();
- let mode = Stdlib.Sys.argv.(1) in
- let filename = Stdlib.Sys.argv.(2) in
- let source_code = read_file filename in
- match parse source_code with
- | Error msg -> printf "Parsing error: %s\n" msg
- | Ok ast ->
- (match mode with
- | "--dump-ast" -> printf "AST:\n%s\n" (show_program ast)
- | "--interpret" ->
- (match interpret ast with
- | Ok _ -> ()
- | Error err ->
- printf "Interpretation error: %s\n" (EChirkov.Interpreter.pp_error err))
- | "--infer" ->
- (match inference ast with
- | Ok env -> EChirkov.Inferencer.print_env env
- | Error msg ->
- Stdlib.Format.printf
- "Type inference error: %a\n"
- EChirkov.Inferencer.pp_error
- msg)
- | _ -> usage ())
-;;
diff --git a/EChirkov/dune b/EChirkov/dune
deleted file mode 100644
index 98e54536a..000000000
--- a/EChirkov/dune
+++ /dev/null
@@ -1,7 +0,0 @@
-(env
- (dev
- (flags
- (:standard -alert @deprecated -warn-error -A -w -3-9-32-34-58)))
- (release
- (flags
- (:standard -alert @deprecated -warn-error +A -w +A-4-40-42-44-70))))
diff --git a/EChirkov/dune-project b/EChirkov/dune-project
deleted file mode 100644
index fc736ac4a..000000000
--- a/EChirkov/dune-project
+++ /dev/null
@@ -1,32 +0,0 @@
-(lang dune 3.7)
-
-(generate_opam_files true)
-
-(cram enable)
-
-(license LGPL-3.0-or-later)
-
-(authors "Dmitri Chirkov ")
-
-(maintainers "Dmitri Chirkov")
-
-(bug_reports "https://github.com/kinokotakenoko9/MiniMl")
-
-(homepage "https://github.com/kinokotakenoko9/MiniMl")
-
-(package
- (name EChirkov)
- (synopsis "An interpreter for miniml")
- (description "An interpreter for miniml")
- (version 0.1)
- (depends
- dune
- (ppx_inline_test :with-test)
- ppx_expect
- ppx_deriving
- bisect_ppx
- (odoc :with-doc)
- (ocamlformat :build)
- ; base
- ; After adding dependencies to 'dune' files and the same dependecies here too
- ))
diff --git a/EChirkov/lib/ast.ml b/EChirkov/lib/ast.ml
deleted file mode 100644
index 4739f697b..000000000
--- a/EChirkov/lib/ast.ml
+++ /dev/null
@@ -1,98 +0,0 @@
-(** Copyright 2024-2025, Dmitri Chirkov*)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-type id = string [@@deriving show { with_path = false }]
-
-type const =
- | CInt of int
- | CBool of bool
- | CUnit
-(* () *)
-(* | CString of string *)
-[@@deriving show { with_path = false }]
-
-type op_un =
- | Neg (* - *)
- | Pos (* + *)
-[@@deriving show { with_path = false }]
-
-type rec_flag =
- | Recursive
- | Nonrecursive
-[@@deriving show { with_path = false }]
-
-type op_bin =
- | Add
- | Sub
- | Mul
- | Div
- | And (* && *)
- | Or (* || *)
- | Gt (* > *)
- | Lt (* < *)
- | Gte (* >= *)
- | Lte (* <= *)
- | Eq (* = *)
- | NEq (* <> *)
-[@@deriving show { with_path = false }]
-
-type binder = int [@@deriving show { with_path = false }]
-
-type core_type =
- | TPrim of string
- | TVar of binder
- | TArrow of core_type * core_type
- | TTuple of core_type * core_type * core_type list
- | TList of core_type
- | TOption of core_type
-[@@deriving show { with_path = false }]
-
-let ty_int = TPrim "int"
-let ty_bool = TPrim "bool"
-let ty_unit = TPrim "unit"
-let ty_arrow (l, r) = TArrow (l, r)
-let ty_var v = TVar v
-let ty_tuple (t1, t2, tl) = TTuple (t1, t2, tl)
-let ty_list l = TList l
-let ty_option o = TOption o
-
-type pattern =
- | PAny (* _ *)
- | PVar of id
- (* | PUnit *)
- | PTuple of pattern * pattern * pattern list
- (* | PCons of pattern * pattern (* h :: t *) *)
- | PList of pattern list (* [23; 34] *)
- | PConst of const (* 23 *)
- | POption of pattern option (* | PType of pattern * core_type *)
-[@@deriving show { with_path = false }]
-
-type expression =
- | EConst of const
- | EVar of id
- | EUnary of op_un * expression
- | EBinary of op_bin * expression * expression
- | ETuple of expression * expression * expression list
- | EList of expression list
- | EOption of expression option
- (* | EMatch of expression * case * case list (* match *) *)
- | EIf of expression * expression * expression option (* if x then false else true *)
- | EFun of pattern * expression (* fun x -> x *)
- (* | EFunction of case * case list (* function *) *)
- | EApply of expression * expression (* f x *)
- | ELet of rec_flag * value_binding * value_binding list * expression
- | EType of expression * core_type
-(* let x = 23 in x *)
-(* | ECons of expression * expression *)
-[@@deriving show { with_path = false }]
-
-(* and case = pattern * expression [@@deriving show { with_path = false }] *)
-and value_binding = pattern * expression [@@deriving show { with_path = false }]
-
-type structure_item =
- | SValue of rec_flag * value_binding * value_binding list (* let f x = x *)
-(* | SEval of expression *)
-[@@deriving show { with_path = false }]
-
-type program = structure_item list [@@deriving show { with_path = false }]
diff --git a/EChirkov/lib/dune b/EChirkov/lib/dune
deleted file mode 100644
index 6c23ab4c4..000000000
--- a/EChirkov/lib/dune
+++ /dev/null
@@ -1,9 +0,0 @@
-(library
- (name EChirkov)
- (public_name EChirkov.Lib)
- (modules Ast Parser Inferencer Interpreter)
- (libraries base angstrom)
- (preprocess
- (pps ppx_deriving.show))
- (instrumentation
- (backend bisect_ppx)))
diff --git a/EChirkov/lib/inferencer.ml b/EChirkov/lib/inferencer.ml
deleted file mode 100644
index 9c35e27a8..000000000
--- a/EChirkov/lib/inferencer.ml
+++ /dev/null
@@ -1,665 +0,0 @@
-(** Copyright 2024-2025, Dmitri Chirkov*)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-open Base
-
-module VarSet = struct
- include Stdlib.Set.Make (Int)
-end
-
-type fresh = int
-
-let alph =
- [ "🍏"
- ; "🍎"
- ; "🍐"
- ; "🍊"
- ; "🍋"
- ; "🍋🟩"
- ; "🍌"
- ; "🍉"
- ; "🍇"
- ; "🍓"
- ; "🫐"
- ; "🍈"
- ; "🍒"
- ; "🍑"
- ; "🥭"
- ; "🍍"
- ; "🥥"
- ; "🥝"
- ]
-;;
-
-module IntMap = Stdlib.Map.Make (Int)
-
-let binder_to_alpha b =
- let rec to_string n =
- if n < 0
- then ""
- else (
- let rem = Stdlib.( mod ) n (List.length alph) in
- let char =
- match List.nth alph rem with
- | Some c -> c
- | None -> Int.to_string b
- in
- let rest = to_string ((n / List.length alph) - 1) in
- rest ^ char)
- in
- to_string b
-;;
-
-let pp_ty fmt ty =
- let compute_var_mapping =
- let rec collect_vars acc = function
- | TPrim _ -> acc
- | TVar v -> if IntMap.mem v acc then acc else IntMap.add v (IntMap.cardinal acc) acc
- | TArrow (l, r) -> collect_vars (collect_vars acc l) r
- | TTuple (t1, t2, tl) ->
- List.fold_left ~f:collect_vars ~init:(collect_vars (collect_vars acc t1) t2) tl
- | TOption t -> collect_vars acc t
- | TList t -> collect_vars acc t
- in
- collect_vars IntMap.empty ty
- in
- let rec helper var_mappings fmt = function
- | TPrim s -> Stdlib.Format.fprintf fmt "%s" s
- | TVar v ->
- Stdlib.Format.fprintf fmt "%s" (binder_to_alpha (IntMap.find v var_mappings))
- | TArrow (l, r) ->
- Stdlib.Format.fprintf
- fmt
- "(%a -> %a)"
- (helper var_mappings)
- l
- (helper var_mappings)
- r
- | TTuple (t1, t2, tl) ->
- Stdlib.Format.fprintf
- fmt
- "(%a)"
- (Stdlib.Format.pp_print_list
- ~pp_sep:(fun _ _ -> Stdlib.Format.printf " * ")
- (fun fmt ty ->
- match ty with
- | TPrim _ | TVar _ -> Stdlib.Format.fprintf fmt "%a" (helper var_mappings) ty
- | _ -> Stdlib.Format.fprintf fmt "(%a)" (helper var_mappings) ty))
- (t1 :: t2 :: tl)
- | TOption o -> Stdlib.Format.fprintf fmt "%a option" (helper var_mappings) o
- | TList l -> Stdlib.Format.fprintf fmt "%a list" (helper var_mappings) l
- in
- helper compute_var_mapping fmt ty
-;;
-
-type error =
- | OccursCheck of binder * core_type
- | NoVariable of id
- | UnificationFailed of core_type * core_type
- | InvalidLeftHandSide
- | InvalidRightHandSide
-
-let pp_error fmt = function
- | OccursCheck (v, t) ->
- Stdlib.Format.fprintf
- fmt
- "Cannot construct type: %a appears within %a"
- pp_ty
- (ty_var v)
- pp_ty
- t
- | NoVariable s -> Stdlib.Format.fprintf fmt "Undefined variable '%s'" s
- | UnificationFailed (l, r) ->
- Stdlib.Format.fprintf fmt "Unification failed on %a and %a" pp_ty l pp_ty r
- | InvalidLeftHandSide -> Stdlib.Format.fprintf fmt "Invalid left hand side"
- | InvalidRightHandSide -> Stdlib.Format.fprintf fmt "Invalid right hand side"
-;;
-
-module Result : sig
- type 'a t
-
- val return : 'a -> 'a t
- val fail : error -> 'a t
-
- include Base.Monad.Infix with type 'a t := 'a t
-
- module Syntax : sig
- val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t
- end
-
- module RMap : sig
- val fold
- : ('k, 'v, 'cmp) Base.Map.t
- -> init:'b t
- -> f:('k -> 'v -> 'b -> 'b t)
- -> 'b t
- end
-
- module RList : sig
- val fold_left : 'a list -> init:'b t -> f:('b -> 'a -> 'b t) -> 'b t
- val fold_right : 'a list -> init:'b t -> f:('a -> 'b -> 'b t) -> 'b t
- val map : 'a list -> f:('a -> 'b t) -> 'b list t
- end
-
- (** Creation of a fresh name from internal state *)
- val fresh : int t
-
- (** Running a transformer: getting the inner result value *)
- val run : 'a t -> ('a, error) Result.t
-end = struct
- (* A compositon: State monad after Result monad *)
- type 'a t = int -> int * ('a, error) Result.t
-
- let ( >>= ) : 'a 'b. 'a t -> ('a -> 'b t) -> 'b t =
- fun m f st ->
- let last, r = m st in
- match r with
- | Result.Error x -> last, Result.fail x
- | Result.Ok a -> f a last
- ;;
-
- let fail e st = st, Base.Result.fail e
- let return x last = last, Base.Result.return x
- let bind x ~f = x >>= f
-
- let ( >>| ) : 'a 'b. 'a t -> ('a -> 'b) -> 'b t =
- fun x f st ->
- match x st with
- | st, Ok x -> st, Result.return (f x)
- | st, Result.Error e -> st, Result.fail e
- ;;
-
- module Syntax = struct
- let ( let* ) x f = bind x ~f
- end
-
- module RMap = struct
- let fold xs ~init ~f =
- Map.fold xs ~init ~f:(fun ~key ~data acc ->
- let open Syntax in
- let* acc = acc in
- f key data acc)
- ;;
- end
-
- module RList = struct
- let fold_left xs ~init ~f =
- Base.List.fold_left xs ~init ~f:(fun acc x ->
- let open Syntax in
- let* acc = acc in
- f acc x)
- ;;
-
- let fold_right xs ~init ~f =
- let open Syntax in
- Base.List.fold_right xs ~init ~f:(fun x acc ->
- let* acc = acc in
- f x acc)
- ;;
-
- let map xs ~f =
- let open Syntax in
- let rec helper acc = function
- | x :: t ->
- let* res = f x in
- helper (res :: acc) t
- | [] -> return (List.rev acc)
- in
- helper [] xs
- ;;
- end
-
- let fresh : int t = fun last -> last + 1, Result.Ok last
- let run m = snd (m 0)
-end
-
-module Type = struct
- let rec occurs_in v = function
- | TPrim _ -> false
- | TVar x -> x = v
- | TArrow (l, r) -> occurs_in v l || occurs_in v r
- | TTuple (t1, t2, tl) ->
- occurs_in v t1 || occurs_in v t2 || Base.List.exists tl ~f:(occurs_in v)
- | TList l -> occurs_in v l
- | TOption typ -> occurs_in v typ
- ;;
-
- let free_vars =
- let rec helper acc = function
- | TPrim _ -> acc
- | TVar x -> VarSet.add x acc
- | TArrow (l, r) -> helper (helper acc l) r
- | TTuple (t1, t2, tl) ->
- let acc' = helper (helper acc t1) t2 in
- List.fold_left ~f:(fun acc t -> helper acc t) ~init:acc' tl
- | TList t -> helper acc t
- | TOption t -> helper acc t
- in
- helper VarSet.empty
- ;;
-end
-
-(* ========== Substitutions ========== *)
-
-module Subst : sig
- type t
-
- val empty : t
- val singleton : fresh -> core_type -> t Result.t
- val remove : t -> fresh -> t
- val apply : t -> core_type -> core_type
- val unify : core_type -> core_type -> t Result.t
- val compose : t -> t -> t Result.t
- val compose_all : t list -> t Result.t
-end = struct
- open Result
- open Result.Syntax
-
- type t = (fresh, core_type, Int.comparator_witness) Map.t
-
- let empty = Map.empty (module Int)
- let mapping k v = if Type.occurs_in k v then fail (OccursCheck (k, v)) else return (k, v)
-
- let singleton k v =
- let* k, v = mapping k v in
- return (Map.singleton (module Int) k v)
- ;;
-
- let find s k = Map.find s k
- let remove s k = Map.remove s k
-
- let apply s =
- let rec helper = function
- | TVar v as ty ->
- (match find s v with
- | Some ty' -> helper ty'
- | None -> ty)
- | TArrow (l, r) -> ty_arrow (helper l, helper r)
- | TTuple (t1, t2, tl) -> ty_tuple (helper t1, helper t2, List.map ~f:helper tl)
- | TOption t -> ty_option (helper t)
- | TList t -> ty_list (helper t)
- | TPrim s -> TPrim s
- in
- helper
- ;;
-
- let rec unify l r =
- match l, r with
- | TPrim l, TPrim r when String.equal l r -> return empty
- | TVar l, TVar r when l = r -> return empty
- | TVar v, t | t, TVar v -> singleton v t
- | TArrow (l1, r1), TArrow (l2, r2) ->
- let* s1 = unify l1 l2 in
- let* s2 = unify (apply s1 r1) (apply s1 r2) in
- compose s1 s2
- | TList t1, TList t2 -> unify t1 t2
- | TTuple (t11, t12, t1l), TTuple (t21, t22, t2l) ->
- if List.length t1l <> List.length t2l
- then fail (UnificationFailed (l, r))
- else (
- let rec unify_tuples subst types1 types2 =
- match types1, types2 with
- | [], [] -> return subst
- | t1 :: rest1, t2 :: rest2 ->
- let* s2 = unify (apply subst t1) (apply subst t2) in
- let* composed_subst = compose subst s2 in
- unify_tuples composed_subst rest1 rest2
- | _, _ -> fail (UnificationFailed (l, r))
- in
- unify_tuples empty (t11 :: t12 :: t1l) (t21 :: t22 :: t2l))
- | TOption t1, TOption t2 -> unify t1 t2
- | _ -> fail (UnificationFailed (l, r))
-
- and extend k v s =
- match find s k with
- | None ->
- let v = apply s v in
- let* s2 = singleton k v in
- RMap.fold s ~init:(return s2) ~f:(fun k v acc ->
- let v = apply s2 v in
- let* k, v = mapping k v in
- return (Map.update acc k ~f:(fun _ -> v)))
- | Some v2 ->
- let* s2 = unify v v2 in
- compose s s2
-
- and compose s1 s2 = RMap.fold s2 ~init:(return s1) ~f:extend
-
- and compose_all ss =
- List.fold_left ss ~init:(return empty) ~f:(fun acc s ->
- let* acc = acc in
- compose acc s)
- ;;
-end
-
-(* ========== Scheme ========== *)
-
-module Scheme = struct
- type binder_set = VarSet.t
- type t = S of binder_set * core_type
-
- let free_vars (S (xs, t)) = VarSet.diff (Type.free_vars t) xs
-
- let apply s (S (xs, t)) =
- let s2 = VarSet.fold (fun k s -> Subst.remove s k) xs s in
- S (xs, Subst.apply s2 t)
- ;;
-end
-
-(* ========== Env ========== *)
-
-module TypeEnv = struct
- type t = (id, Scheme.t, String.comparator_witness) Map.t
-
- let extend e k v = Map.update e k ~f:(fun _ -> v)
- let remove e k = Map.remove e k
- let empty = Map.empty (module String)
-
- let free_vars : t -> VarSet.t =
- Map.fold ~init:VarSet.empty ~f:(fun ~key:_ ~data:s acc ->
- VarSet.union acc (Scheme.free_vars s))
- ;;
-
- let apply s env = Map.map env ~f:(Scheme.apply s)
- let find x env = Map.find env x
-end
-
-open Result
-open Result.Syntax
-
-let fresh_var = fresh >>| fun n -> TVar n
-
-let instantiate : Scheme.t -> core_type Result.t =
- fun (S (bs, t)) ->
- VarSet.fold
- (fun name typ ->
- let* typ = typ in
- let* f1 = fresh_var in
- let* s = Subst.singleton name f1 in
- return (Subst.apply s typ))
- bs
- (return t)
-;;
-
-let generalize env ty =
- let free = VarSet.diff (Type.free_vars ty) (TypeEnv.free_vars env) in
- Scheme.S (free, ty)
-;;
-
-let generalize_rec env ty x =
- let env = TypeEnv.remove env x in
- generalize env ty
-;;
-
-let rec infer_pattern env = function
- | PAny ->
- let* fresh = fresh_var in
- return (Subst.empty, env, fresh)
- | PConst c ->
- (match c with
- | CInt _ -> return (Subst.empty, env, ty_int)
- | CBool _ -> return (Subst.empty, env, ty_bool)
- | CUnit -> return (Subst.empty, env, ty_unit))
- | PVar x ->
- let* fresh = fresh_var in
- let env = TypeEnv.extend env x (Scheme.S (VarSet.empty, fresh)) in
- return (Subst.empty, env, fresh)
- | PTuple (t1, t2, tl) ->
- let* s1, env1, t1' = infer_pattern env t1 in
- let* s2, env2, t2' = infer_pattern (TypeEnv.apply s1 env1) t2 in
- let* sub, tl', env =
- RList.fold_right
- ~f:(fun p acc ->
- let sub_prev, acc, env = acc in
- let* sub_cur, env, t = infer_pattern env p in
- let* sub = Subst.compose sub_prev sub_cur in
- return (sub, t :: acc, env))
- ~init:(return (s2, [], env2))
- tl
- in
- return (sub, env, ty_tuple (t1', t2', tl'))
- | PList [] ->
- let* fresh = fresh_var in
- return (Subst.empty, env, ty_list fresh)
- | PList pl ->
- let* fresh_el_type = fresh_var in
- let* final_sub, final_env =
- RList.fold_left
- pl
- ~init:(return (Subst.empty, env))
- ~f:(fun (sub_acc, env_acc) pat ->
- let* sub_cur, env_cur, t = infer_pattern env_acc pat in
- let* unified_sub = Subst.compose sub_acc sub_cur in
- let* final_sub = Subst.unify (Subst.apply sub_cur fresh_el_type) t in
- let combined_sub = Subst.compose unified_sub final_sub in
- let* combined_sub = combined_sub in
- return (combined_sub, TypeEnv.apply final_sub env_cur))
- in
- return (final_sub, final_env, TList (Subst.apply final_sub fresh_el_type))
- | POption (Some p) ->
- let* sub, env1, t1 = infer_pattern env p in
- return (sub, env1, ty_option t1)
- | POption None ->
- let* fresh = fresh_var in
- return (Subst.empty, env, ty_option fresh)
-;;
-
-let rec infer_expression env = function
- | EConst c ->
- (match c with
- | CInt _ -> return (Subst.empty, ty_int)
- | CBool _ -> return (Subst.empty, ty_bool)
- | CUnit -> return (Subst.empty, ty_unit))
- | EVar x ->
- (match TypeEnv.find x env with
- | Some s ->
- let* t = instantiate s in
- return (Subst.empty, t)
- | None -> fail (NoVariable x))
- | EUnary (_, e) ->
- let* sub1, t1 = infer_expression env e in
- let* sub2 = Subst.unify (Subst.apply sub1 t1) ty_int in
- let* sub = Subst.compose_all [ sub1; sub2 ] in
- return (sub, Subst.apply sub ty_int)
- | EBinary (op, e1, e2) ->
- let* sub1, t1 = infer_expression env e1 in
- let* sub2, t2 = infer_expression (TypeEnv.apply sub1 env) e2 in
- let* e1t, e2t, et =
- match op with
- | Mul | Div | Add | Sub -> return (ty_int, ty_int, ty_int)
- | Eq | NEq | Lt | Lte | Gt | Gte ->
- let* fresh = fresh_var in
- return (fresh, fresh, ty_bool)
- | And | Or -> return (ty_bool, ty_bool, ty_bool)
- in
- let* sub3 = Subst.unify (Subst.apply sub2 t1) e1t in
- let* sub4 = Subst.unify (Subst.apply sub3 t2) e2t in
- let* sub = Subst.compose_all [ sub1; sub2; sub3; sub4 ] in
- return (sub, Subst.apply sub et)
- | EIf (i, t, e) ->
- let* sub1, t1 = infer_expression env i in
- let* sub2, t2 = infer_expression (TypeEnv.apply sub1 env) t in
- let* sub3, t3 =
- match e with
- | Some e ->
- let* sub3, t3 = infer_expression (TypeEnv.apply sub2 env) e in
- return (sub3, t3)
- | None -> return (Subst.empty, ty_unit)
- in
- let* sub4 = Subst.unify t1 ty_bool in
- let* sub5 = Subst.unify t2 t3 in
- let* sub = Subst.compose_all [ sub1; sub2; sub3; sub4; sub5 ] in
- return (sub, Subst.apply sub t2)
- | ELet (Nonrecursive, b, bl, e) ->
- let bindings = b :: bl in
- let* env2, s1 = infer_nonrec_bs env bindings in
- let* s2, t = infer_expression env2 e in
- let* sub = Subst.compose s1 s2 in
- return (sub, t)
- | ELet (Recursive, b, bl, e) ->
- let bindings = b :: bl in
- let* env2, s1 = infer_rec_bs env bindings in
- let* s, t = infer_expression env2 e in
- let* sub = Subst.compose s1 s in
- return (sub, t)
- | EFun (p, e) ->
- let* _, env, t = infer_pattern env p in
- let* sub, t1 = infer_expression env e in
- return (sub, Subst.apply sub (ty_arrow (t, t1)))
- | ETuple (e0, e1, exps) ->
- let* sub0, t0 = infer_expression env e0 in
- let* sub1, t1 = infer_expression env e1 in
- let* subs, ts =
- RList.map exps ~f:(fun e -> infer_expression env e)
- >>| List.fold_right ~f:(fun (p, e) (ps, es) -> p :: ps, e :: es) ~init:([], [])
- in
- let* sub = Subst.compose_all (sub0 :: sub1 :: subs) in
- return (sub, TTuple (t0, t1, ts))
- | EApply (e1, e2) ->
- let* fresh = fresh_var in
- let* s1, t1 = infer_expression env e1 in
- let* s2, t2 = infer_expression (TypeEnv.apply s1 env) e2 in
- let* s3 = Subst.unify (ty_arrow (t2, fresh)) (Subst.apply s2 t1) in
- let* sub = Subst.compose_all [ s1; s2; s3 ] in
- let t = Subst.apply sub fresh in
- return (sub, t)
- | EList [] ->
- let* fresh = fresh_var in
- return (Subst.empty, ty_list fresh)
- | EList (l :: ls) ->
- (match l :: ls with
- | [] ->
- let* fresh = fresh_var in
- return (Subst.empty, ty_list fresh)
- | h :: tl ->
- let* sr, tr =
- List.fold_left tl ~init:(infer_expression env h) ~f:(fun acc e ->
- let* sub, t = acc in
- let* s1, t1 = infer_expression env e in
- let* s2 = Subst.unify t t1 in
- let* final_s = Subst.compose_all [ sub; s1; s2 ] in
- let final_t = Subst.apply final_s t in
- return (final_s, final_t))
- in
- return (sr, ty_list tr))
- | EOption (Some eo) ->
- let* s, t = infer_expression env eo in
- return (s, ty_option t)
- | EOption None ->
- let* t = fresh_var in
- return (Subst.empty, ty_option t)
- | EType (e, t) ->
- let* s1, t1 = infer_expression env e in
- let* s2 = Subst.unify t1 t in
- let* s1 = Subst.compose s2 s1 in
- return (s1, t1)
-
-and infer_nonrec_bs env bl =
- let* env2, sub2 =
- Base.List.fold_left
- ~f:(fun acc b ->
- let* env, sub = acc in
- let p, e = b in
- let* s, t = infer_expression env e in
- let* sub = Subst.compose s sub in
- let env = TypeEnv.apply sub env in
- let* env, sub =
- match p with
- | PVar x -> return (TypeEnv.extend env x (generalize env t), sub)
- | _ ->
- let* _, env, t' = infer_pattern env p in
- let* sub' = Subst.unify t' t in
- let* sub = Subst.compose_all [ sub'; sub ] in
- return (TypeEnv.apply sub env, sub)
- in
- return (env, sub))
- ~init:(return (env, Subst.empty))
- bl
- in
- return (env2, sub2)
-
-and infer_rec_bs env bl =
- let* env0 =
- Base.List.fold_left
- ~f:(fun env b ->
- let* env = env in
- let p, _ = b in
- match p with
- | PVar x ->
- let* fresh = fresh_var in
- let sc = Scheme.S (VarSet.empty, fresh) in
- let env = TypeEnv.extend env x sc in
- return env
- | _ -> fail InvalidLeftHandSide)
- ~init:(return env)
- bl
- in
- let* env2 =
- Base.List.fold_left
- ~f:(fun env b ->
- let* env = env in
- let p, e = b in
- match p with
- | PVar x ->
- let* fresh = fresh_var in
- let sc = Scheme.S (VarSet.empty, fresh) in
- let env = TypeEnv.extend env x sc in
- let* s1, t1 = infer_expression env e in
- (match t1 with
- | TArrow _ ->
- let* s2 = Subst.unify t1 fresh in
- let* s3 = Subst.compose s1 s2 in
- let env = TypeEnv.apply s3 env in
- let t2 = Subst.apply s3 t1 in
- let sc = generalize_rec env t2 x in
- let env = TypeEnv.extend env x sc in
- return env
- | _ -> fail InvalidRightHandSide)
- | _ -> fail InvalidLeftHandSide)
- ~init:(return env0)
- bl
- in
- return (env2, Subst.empty)
-;;
-
-let infer_structure_item env = function
- | SValue (Nonrecursive, b, bl) ->
- let bindings = b :: bl in
- let* env, _ = infer_nonrec_bs env bindings in
- return env
- | SValue (Recursive, b, bl) ->
- let bindings = b :: bl in
- let* env, _ = infer_rec_bs env bindings in
- return env
-;;
-
-let infer_program p =
- let env =
- TypeEnv.extend
- TypeEnv.empty
- "print_int"
- (Scheme.S (VarSet.empty, ty_arrow (ty_int, ty_unit)))
- in
- List.fold_left
- ~f:(fun acc item ->
- let* env = acc in
- let* env = infer_structure_item env item in
- return env)
- ~init:(return env)
- p
-;;
-
-(* ========== print ========== *)
-
-let print_env env =
- Base.Map.iteri env ~f:(fun ~key ~data:(Scheme.S (_, ty)) ->
- match key with
- | key when String.equal key "print_int" -> ()
- | key -> Stdlib.Format.printf "val %s : %a\n" key pp_ty ty)
-;;
-
-(* inference *)
-
-let inference p = run (infer_program p)
diff --git a/EChirkov/lib/inferencer.mli b/EChirkov/lib/inferencer.mli
deleted file mode 100644
index 24b2f5e33..000000000
--- a/EChirkov/lib/inferencer.mli
+++ /dev/null
@@ -1,30 +0,0 @@
-(** Copyright 2024-2025, Dmitri Chirkov*)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-open Base
-open Stdlib
-
-module VarSet : sig
- include Set.S with type elt = int
-end
-
-module Scheme : sig
- type binder_set = VarSet.t
- type t = S of binder_set * core_type
-end
-
-type error =
- | OccursCheck of binder * core_type
- | NoVariable of id
- | UnificationFailed of core_type * core_type
- | InvalidLeftHandSide
- | InvalidRightHandSide
-
-val inference
- : structure_item list
- -> ((string, Scheme.t, Base.String.comparator_witness) Base.Map.t, error) result
-
-val pp_error : Format.formatter -> error -> unit
-val print_env : (string, Scheme.t, 'a) Base.Map.t -> unit
diff --git a/EChirkov/lib/interpreter.ml b/EChirkov/lib/interpreter.ml
deleted file mode 100644
index 4dc78c7d4..000000000
--- a/EChirkov/lib/interpreter.ml
+++ /dev/null
@@ -1,320 +0,0 @@
-(** Copyright 2024-2025, Dmitri Chirkov*)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-open Base
-
-(* ========== errors ========== *)
-
-type error =
- | UnboundVariable of string
- | TypeMissmatch
- | DivisionByZero
-
-let pp_error = function
- | UnboundVariable s -> "Unbound variable: " ^ s
- | TypeMissmatch -> "Type error"
- | DivisionByZero -> "Division by zero"
-;;
-
-(* ========== values ========== *)
-
-type value =
- | VInt of int
- | VString of string
- | VBool of bool
- | VTuple of value * value * value list
- | VFun of rec_flag * pattern * expression * environment
- | VFunMutual of rec_flag * pattern * expression * environment
- | VList of value list
- | VOption of value option
- | VUnit
- | VPrintInt
-
-and environment = (string, value, Base.String.comparator_witness) Base.Map.t
-
-(* ========== result monad ========== *)
-
-module type Monad = sig
- include Base.Monad.S2
-
- val fail : error -> ('a, error) t
- val ( let* ) : ('a, 'e) t -> ('a -> ('b, 'e) t) -> ('b, 'e) t
-end
-
-(* ========== environment ========== *)
-
-module Environment (M : Monad) = struct
- open M
-
- let empty = Base.Map.empty (module Base.String) (* create empty env *)
-
- let find env name =
- (* get from env by name *)
- match Base.Map.find env name with
- | Some x -> return x
- | None -> fail (UnboundVariable name)
- ;;
-
- (* put in env binding *)
- let extend env k v = Base.Map.update env k ~f:(fun _ -> v)
-end
-
-(* ========== evaluation ========== *)
-
-module Evaluate (M : Monad) = struct
- open M
- open Environment (M)
-
- let rec match_pattern env = function
- | PAny, _ -> Some env
- | PConst (CInt i1), VInt i2 when i1 = i2 -> Some env
- | PConst (CBool b1), VBool b2 when Bool.equal b1 b2 -> Some env
- | PConst CUnit, VUnit -> Some env
- | PVar x, v -> Some (extend env x v)
- | PTuple (p1, p2, prest), VTuple (v1, v2, vrest) ->
- match_pattern_list env (p1 :: p2 :: prest) (v1 :: v2 :: vrest)
- | PList pl, VList vl -> match_pattern_list env pl vl
- | POption None, VOption None -> Some env
- | POption (Some p), VOption (Some v) ->
- let env = match_pattern env (p, v) in
- (match env with
- | Some env -> Some env
- | None -> None)
- | _ -> None
-
- and match_pattern_list env patterns values =
- if List.length patterns <> List.length values
- then None
- else (
- let f1 acc (p, v) =
- match acc with
- | None -> None
- | Some env' -> match_pattern env' (p, v)
- in
- let rec zip l1 l2 =
- match l1, l2 with
- | [], [] -> []
- | x :: xs, y :: ys -> (x, y) :: zip xs ys
- | _ -> []
- in
- List.fold_left ~f:f1 ~init:(Some env) (zip patterns values))
- ;;
-
- let rec eq_value v1 v2 =
- match v1, v2 with
- | VList x, VList y ->
- let rec eq_list lst1 lst2 =
- match lst1, lst2 with
- | [], [] -> true
- | VInt a :: t1, VInt b :: t2 -> a = b && eq_list t1 t2
- | VBool a :: t1, VBool b :: t2 ->
- ((a && b) || ((not a) && not b)) && eq_list t1 t2
- | VList a :: t1, VList b :: t2 -> eq_list a b && eq_list t1 t2
- | _ -> false
- in
- Some (VBool (eq_list x y))
- | VInt x, VInt y -> Some (VBool (x = y))
- | VBool x, VBool y -> Some (VBool ((x && y) || ((not x) && not y)))
- | VOption (Some x), VOption (Some y) -> eq_value x y
- | VOption None, VOption None
- | VOption None, VOption (Some _)
- | VOption (Some _), VOption None -> Some (VBool false)
- | _ -> None
- ;;
-
- let rec eval_expression env = function
- | EConst c ->
- (match c with
- | CInt i -> return (VInt i)
- | CBool b -> return (VBool b)
- | CUnit -> return VUnit)
- | EVar x ->
- let* v = find env x in
- let v =
- match v with
- | VFun (Recursive, p, e, env) -> VFun (Recursive, p, e, extend env x v)
- | _ -> v
- in
- return v
- | EBinary (op, e1, e2) ->
- let* v1 = eval_expression env e1 in
- let* v2 = eval_expression env e2 in
- (match op, v1, v2 with
- | Add, VInt x, VInt y -> return (VInt (x + y))
- | Sub, VInt x, VInt y -> return (VInt (x - y))
- | Mul, VInt x, VInt y -> return (VInt (x * y))
- | Div, VInt x, VInt y ->
- (match y with
- | 0 -> fail DivisionByZero
- | _ -> return (VInt (x / y)))
- | Lt, VInt x, VInt y -> return (VBool (x < y))
- | Gt, VInt x, VInt y -> return (VBool (x > y))
- | Eq, x, y ->
- (match eq_value x y with
- | Some v -> return v
- | None -> fail TypeMissmatch)
- | NEq, x, y ->
- (match eq_value x y with
- | Some v ->
- (match v with
- | VBool v -> return (VBool (not v))
- | _ -> fail TypeMissmatch)
- | None -> fail TypeMissmatch)
- | Lte, VInt x, VInt y -> return (VBool (x <= y))
- | Gte, VInt x, VInt y -> return (VBool (x >= y))
- | And, VBool x, VBool y -> return (VBool (x && y))
- | Or, VBool x, VBool y -> return (VBool (x || y))
- | _ -> fail TypeMissmatch)
- | EUnary (op, e) ->
- let* v = eval_expression env e in
- (match op, v with
- | Pos, VInt x -> return (VInt x)
- | Neg, VInt x -> return (VInt (-x))
- | _ -> fail TypeMissmatch)
- | EIf (i, t, e) ->
- let* cv = eval_expression env i in
- (match cv with
- | VBool true -> eval_expression env t
- | VBool false ->
- (match e with
- | Some e -> eval_expression env e
- | None -> return VUnit)
- | _ -> fail TypeMissmatch)
- | ELet (Nonrecursive, b, bl, e) ->
- let bindings = b :: bl in
- let* env2 = eval_nonrec_bs env bindings in
- eval_expression env2 e
- | ELet (Recursive, (PVar x, e1), [], e) ->
- let* v = eval_expression env e1 in
- let env1 = extend env x v in
- let v =
- match v with
- | VFun (_, p, e, _) -> VFun (Recursive, p, e, env1)
- | _ -> v
- in
- let env2 = extend env x v in
- eval_expression env2 e
- | ELet (Recursive, b, bl, e) ->
- let bindings = b :: bl in
- let* env2 = eval_rec_bs env bindings in
- eval_expression env2 e
- | EFun (p, e) -> return (VFun (Nonrecursive, p, e, env))
- | EApply (e1, e2) ->
- let* v1 = eval_expression env e1 in
- let* v2 = eval_expression env e2 in
- (match v1 with
- | VFun (_, p, e, env) ->
- let* env' =
- match match_pattern env (p, v2) with
- | Some env -> return env
- | None -> fail TypeMissmatch
- in
- eval_expression env' e
- | VFunMutual (_, p, e, _) ->
- let* env' =
- match match_pattern env (p, v2) with
- | Some env -> return env
- | None -> fail TypeMissmatch
- in
- eval_expression env' e
- | VPrintInt ->
- (match v2 with
- | VInt i ->
- Stdlib.Format.printf "%d\n" i;
- (* TODO: think *) return VUnit
- | _ -> fail TypeMissmatch)
- | _ -> fail TypeMissmatch)
- | ETuple (e1, e2, el) ->
- let* v1 = eval_expression env e1 in
- let* v2 = eval_expression env e2 in
- let* vl =
- Base.List.fold_left
- ~f:(fun acc e ->
- let* acc = acc in
- let* v = eval_expression env e in
- return (v :: acc))
- ~init:(return [])
- el
- in
- return (VTuple (v1, v2, List.rev vl))
- | EList el ->
- let rec eval_list_elements env = function
- | [] -> return []
- | e :: es ->
- let* v = eval_expression env e in
- let* vs = eval_list_elements env es in
- return (v :: vs)
- in
- let* vl = eval_list_elements env el in
- return (VList vl)
- | EOption opt_expr ->
- (match opt_expr with
- | None -> return (VOption None)
- | Some e ->
- let* v = eval_expression env e in
- return (VOption (Some v)))
- | EType (e, _) -> eval_expression env e
-
- and eval_rec_bs env bl =
- let* env2 =
- Base.List.fold_left
- ~f:(fun env b ->
- let* env = env in
- let p, e = b in
- match p with
- | PVar name ->
- (match e with
- | EFun (p1, e1) ->
- return (extend env name (VFunMutual (Recursive, p1, e1, env)))
- | _ -> return env)
- | _ -> return env)
- ~init:(return env)
- bl
- in
- return env2
-
- and eval_nonrec_bs env bl =
- let* env2 =
- List.fold_left
- ~f:(fun env b ->
- let* env = env in
- let p, e = b in
- let* v = eval_expression env e in
- match match_pattern env (p, v) with
- | Some env2 -> return env2
- | None -> return env)
- ~init:(return env)
- bl
- in
- return env2
- ;;
-
- let eval_structure_item env s =
- let env = extend env "print_int" VPrintInt in
- match s with
- | SValue (Nonrecursive, b, bl) -> eval_nonrec_bs env (b :: bl)
- | SValue (Recursive, b, bl) -> eval_rec_bs env (b :: bl)
- ;;
-
- let eval_program (p : program) =
- List.fold_left
- ~f:(fun env structure_item ->
- let* env = env in
- let* env = eval_structure_item env structure_item in
- return env)
- ~init:(return empty)
- p
- ;;
-end
-
-module Interpret = Evaluate (struct
- include Result
-
- let ( let* ) m f = bind m ~f
- end)
-
-(* interpret *)
-
-let interpret = Interpret.eval_program
diff --git a/EChirkov/lib/interpreter.mli b/EChirkov/lib/interpreter.mli
deleted file mode 100644
index ef0adf893..000000000
--- a/EChirkov/lib/interpreter.mli
+++ /dev/null
@@ -1,30 +0,0 @@
-(** Copyright 2024-2025, Dmitri Chirkov*)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-
-type error =
- | UnboundVariable of string
- | TypeMissmatch
- | DivisionByZero
-
-type value =
- | VInt of int
- | VString of string
- | VBool of bool
- | VTuple of value * value * value list
- | VFun of rec_flag * pattern * expression * environment
- | VFunMutual of rec_flag * pattern * expression * environment
- | VList of value list
- | VOption of value option
- | VUnit
- | VPrintInt
-
-and environment = (string, value, Base.String.comparator_witness) Base.Map.t
-
-val interpret
- : program
- -> ((string, value, Base.String.comparator_witness) Base.Map.t, error) result
-
-val pp_error : error -> string
diff --git a/EChirkov/lib/parser.ml b/EChirkov/lib/parser.ml
deleted file mode 100644
index 4d17b4c06..000000000
--- a/EChirkov/lib/parser.ml
+++ /dev/null
@@ -1,293 +0,0 @@
-(** Copyright 2024-2025, Dmitri Chirkov*)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-open Angstrom
-open Base
-
-(* ========== errors ========== *)
-
-type error =
- | UnexpectedToken of string
- | Expected of string
- | ReservedKeyword of string
- | WildcardUsed
-
-let pp_error = function
- | UnexpectedToken tok -> "Unexpected token: " ^ tok
- | Expected msg -> "Expected: " ^ msg
- | ReservedKeyword name -> "Reserved keyword cannot be used: " ^ name
- | WildcardUsed -> "Wildcard '_' cannot be used as a variable name."
-;;
-
-(* ========== basic ========== *)
-
-let is_ws = function
- | '\x20' | '\x0a' | '\x0d' | '\x09' -> true
- | _ -> false
-;;
-
-let ws = take_while is_ws
-
-let is_digit = function
- | '0' .. '9' -> true
- | _ -> false
-;;
-
-let is_keyword = function
- | "let" | "in" | "if" | "then" | "else" | "fun" | "rec" | "true" | "false" | "and" ->
- true
- | _ -> false
-;;
-
-let is_id c = Char.is_alphanum c || Char.equal c '_' || Char.equal c '\''
-let token str = ws *> string str
-let parens s = token "(" *> s <* token ")"
-let p_digits = take_while1 is_digit
-
-let chainl1 e op =
- let rec go acc = lift2 (fun f x -> f acc x) op e >>= go <|> return acc in
- e >>= fun init -> go init <|> fail (Expected "operator" |> pp_error)
-;;
-
-let p_rec_flag =
- choice [ token "rec" *> take_while1 is_ws *> return Recursive; return Nonrecursive ]
-;;
-
-(* ========== consts ========== *)
-
-(* let p_string =
- token "\"" *> take_till (Char.equal '\"') <* token "\"" >>| fun s -> CString s
- ;; *)
-
-let p_integer =
- let* num = ws *> p_digits in
- let* next = peek_char in
- match next with
- | Some ('a' .. 'z' | '_') -> fail "unexpected character after number"
- | _ -> return (CInt (Int.of_string num))
-;;
-
-let p_boolean =
- let t = token "true" *> return (CBool true) in
- let f = token "false" *> return (CBool false) in
- choice [ t; f ]
-;;
-
-let p_unit = token "()" *> return CUnit
-
-let p_const =
- choice
- ~failure_msg:(Expected "a constant (integer, string, boolean, unit)" |> pp_error)
- [ p_integer; (*p_string;*) p_boolean; p_unit ]
-;;
-
-let p_variable =
- let* _ = ws in
- let* first_char = peek_char_fail in
- match first_char with
- | 'a' .. 'z' | '_' ->
- let* name = take_while is_id in
- (match name with
- | "_" -> fail (pp_error WildcardUsed)
- | name when is_keyword name -> fail (pp_error (ReservedKeyword name))
- | name -> return name)
- | _ -> fail (pp_error (UnexpectedToken "Expected an identifier"))
-;;
-
-(* ========== type anonotaions ========== *)
-
-let rec p_tlist t =
- let* t = t in
- let* _ = token "list" in
- p_tlist (return (ty_list t)) <|> return (ty_list t)
-;;
-
-let p_toption t =
- let* t = t in
- let* _ = token "option" in
- return (ty_option t)
-;;
-
-let p_ttuple t =
- let* f = t in
- let* s = token "*" *> t in
- let+ rest = many (token "*" *> t) in
- ty_tuple (f, s, rest)
-;;
-
-let p_type =
- fix
- @@ fun t ->
- let types =
- choice
- [ token "int" *> return ty_int
- ; token "bool" *> return ty_bool
- ; token "unit" *> return ty_unit
- ]
- <|> parens t
- in
- let t_list = p_tlist types <|> types in
- let t_opt = p_toption t_list <|> t_list in
- let t_tup = p_ttuple t_opt <|> t_opt in
- t_tup
-;;
-
-let p_etype e =
- let* e = token "(" *> e in
- let+ ty = token ":" *> p_type <* token ")" in
- EType (e, ty)
-;;
-
-(* ========== patterns ========== *)
-
-let p_any = token "_" *> return PAny
-
-let p_ptuple e =
- let tuple =
- lift3
- (fun e1 e2 rest -> PTuple (e1, e2, rest))
- (e <* token ",")
- e
- (many (token "," *> e))
- <* ws
- in
- parens tuple <|> tuple
-;;
-
-let p_plist e =
- token "[" *> sep_by (token ";" *> ws) e <* token "]" >>| fun es -> PList es
-;;
-
-let p_poption e =
- choice
- [ token "None" *> return (POption None)
- ; (token "Some" *> choice [ parens e; e ] >>| fun e -> POption (Some e))
- ]
-;;
-
-let p_pattern =
- fix
- @@ fun p ->
- let term =
- choice
- [ (p_variable >>| fun v -> PVar v)
- ; (p_unit >>| fun _ -> PConst CUnit)
- ; p_poption p (* ; p_ptype p *)
- ; p_plist p
- ; p_any
- ]
- in
- let tuples = p_ptuple term <|> term in
- tuples
-;;
-
-(* ========== exprs ========== *)
-
-let p_list e = token "[" *> sep_by (token ";" *> ws) e <* token "]" >>| fun es -> EList es
-
-let p_branch e =
- lift3
- (fun ei et ee -> EIf (ei, et, ee))
- (token "if" *> e)
- (token "then" *> e)
- (option None (token "else" *> e >>| fun ee -> Some ee))
-;;
-
-let p_binop tkn binop = token tkn *> return (fun el er -> EBinary (binop, el, er)) <* ws
-
-let p_unop e =
- lift2
- (fun unop e -> EUnary (unop, e))
- (choice [ token "-" *> return Neg <* ws; token "+" *> return Pos <* ws ])
- e
-;;
-
-let p_tuple e =
- let tuple =
- lift3
- (fun e1 e2 rest -> ETuple (e1, e2, rest))
- (e <* token ",")
- e
- (many (token "," *> e))
- <* ws
- in
- parens tuple <|> tuple
-;;
-
-let p_option e =
- choice
- [ token "None" *> return (EOption None)
- ; (token "Some" *> choice [ parens e; e ] >>| fun e -> EOption (Some e))
- ]
-;;
-
-let p_fun e =
- let* ps = token "fun" *> many1 p_pattern in
- let+ e = token "->" *> e in
- List.fold_right ps ~init:e ~f:(fun p e -> EFun (p, e))
-;;
-
-let p_binding expr =
- let* p = p_pattern in
- let* ps = many p_pattern <* token "=" <* ws in
- let+ e = p_etype expr <|> expr in
- p, List.fold_right ps ~init:e ~f:(fun p e -> EFun (p, e))
-;;
-
-let p_let expr =
- lift4
- (fun rf b bl e -> ELet (rf, b, bl, e))
- (token "let" *> p_rec_flag)
- (p_binding expr)
- (many (token "and" *> p_binding expr))
- (token "in" *> expr)
-;;
-
-let p_expression =
- fix
- @@ fun e ->
- let term = parens e in
- let term = p_const >>| (fun e -> EConst e) <|> term in
- let term = p_etype e <|> term in
- let term = p_variable >>| (fun v -> EVar v) <|> term in
- let term = p_list e <|> term in
- let apply = chainl1 term (return (fun e1 e2 -> EApply (e1, e2))) in
- let opt = p_option apply <|> apply in
- let branch = p_branch e <|> opt in
- let unary_op = branch <|> p_unop branch in
- let multiplydivide_op = chainl1 unary_op (p_binop "*" Mul <|> p_binop "/" Div) in
- let plusminus_op = chainl1 multiplydivide_op (p_binop "+" Add <|> p_binop "-" Sub) in
- let compare_op =
- chainl1
- plusminus_op
- (choice
- [ p_binop "=" Eq
- ; p_binop "<>" NEq
- ; p_binop "<=" Lte
- ; p_binop "<" Lt
- ; p_binop ">=" Gte
- ; p_binop ">" Gt
- ])
- in
- let bool_op = chainl1 compare_op (p_binop "&&" And <|> p_binop "||" Or) in
- let tuples = p_tuple bool_op <|> bool_op in
- choice [ tuples; p_let e; p_fun e ]
-;;
-
-(* ========== top level ========== *)
-
-let p_structure_item =
- lift3
- (fun rf b bl -> SValue (rf, b, bl))
- (token "let" *> p_rec_flag)
- (p_binding p_expression)
- (many (token "and" *> p_binding p_expression))
-;;
-
-let p_program = many p_structure_item <* ws
-
-(* parse *)
-
-let parse s = parse_string ~consume:All p_program s
diff --git a/EChirkov/lib/parser.mli b/EChirkov/lib/parser.mli
deleted file mode 100644
index 150f7cfd5..000000000
--- a/EChirkov/lib/parser.mli
+++ /dev/null
@@ -1,7 +0,0 @@
-(** Copyright 2024-2025, Dmitri Chirkov*)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-
-val parse : string -> (structure_item list, string) result
diff --git a/EChirkov/tests/dune b/EChirkov/tests/dune
deleted file mode 100644
index 6f2869d8a..000000000
--- a/EChirkov/tests/dune
+++ /dev/null
@@ -1,40 +0,0 @@
-(library
- (name tests)
- (public_name EChirkov.Tests)
- (libraries EChirkov)
- (preprocess
- (pps ppx_expect ppx_deriving.show))
- (inline_tests)
- (instrumentation
- (backend bisect_ppx)))
-
-(cram
- (applies_to test)
- (deps
- ../bin/main.exe
- manytests/typed/001fac.ml
- manytests/typed/001fac.ml
- manytests/typed/002fac.ml
- manytests/typed/003fib.ml
- manytests/typed/004manyargs.ml
- manytests/typed/005fix.ml
- manytests/typed/006partial2.ml
- manytests/typed/006partial3.ml
- manytests/typed/006partial.ml
- manytests/typed/007order.ml
- manytests/typed/008ascription.ml
- manytests/typed/009let_poly.ml
- manytests/typed/010sukharev.ml
- manytests/typed/015tuples.ml
- manytests/typed/016lists.ml
- manytests/do_not_type/001.ml
- manytests/do_not_type/002if.ml
- manytests/do_not_type/003occurs.ml
- manytests/do_not_type/004let_poly.ml
- manytests/do_not_type/005.ml
- manytests/do_not_type/015tuples.ml
- manytests/do_not_type/016tuples_mismatch.ml
- manytests/do_not_type/097fun_vs_list.ml
- manytests/do_not_type/097fun_vs_unit.ml
- manytests/do_not_type/098rec_int.ml
- manytests/do_not_type/099.ml))
diff --git a/EChirkov/tests/inferencer_tests.ml b/EChirkov/tests/inferencer_tests.ml
deleted file mode 100644
index 5e2270b0f..000000000
--- a/EChirkov/tests/inferencer_tests.ml
+++ /dev/null
@@ -1,277 +0,0 @@
-(** Copyright 2024-2025, Dmitri Chirkov*)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open EChirkov.Parser
-open EChirkov.Inferencer
-
-let test_inferencer s =
- match parse s with
- | Ok s ->
- (* print_endline (show_program s); *)
- (match inference s with
- | Ok env -> EChirkov.Inferencer.print_env env
- | Error e -> Format.printf "Type inference error: %a" EChirkov.Inferencer.pp_error e)
- | Error _ -> print_endline "Parsing error"
-;;
-
-let%expect_test "inference factorial function" =
- test_inferencer "let rec factorial n = if n < 2 then 1 else n * factorial(n - 1)";
- [%expect {|val factorial : (int -> int)|}]
-;;
-
-(* ========== const ========== *)
-
-let%expect_test "inference int" =
- test_inferencer "let x = 2";
- [%expect {|val x : int|}]
-;;
-
-let%expect_test "inference bool" =
- test_inferencer "let x = true";
- [%expect {|val x : bool|}]
-;;
-
-let%expect_test "inference unit" =
- test_inferencer "let x = ()";
- [%expect {|val x : unit|}]
-;;
-
-(* ========== bop ========== *)
-
-let%expect_test "inference bop add sub mul div" =
- test_inferencer "let x = 23 + 23 - 45 - (2 * 345) / (-98)";
- [%expect {|
- val x : int|}]
-;;
-
-let%expect_test "inference bop unit unify" =
- test_inferencer "let x = true || ()";
- [%expect {|
- Type inference error: Unification failed on unit and bool|}]
-;;
-
-let%expect_test "inference bop bool unify" =
- test_inferencer "let f x y = x && (y : int)";
- [%expect {|
- Type inference error: Unification failed on bool and int|}]
-;;
-
-(* ========== tuples ========== *)
-
-let%expect_test "inference tuple fst" =
- test_inferencer "let f t = let (x, y) = t in x";
- [%expect {|
- val f : ((🍏 * 🍎) -> 🍏)|}]
-;;
-
-let%expect_test "inference tuple 2" =
- test_inferencer "let (x, y) = (23, 12)";
- [%expect {|
- val x : int
- val y : int|}]
-;;
-
-let%expect_test "inference tuple 3" =
- test_inferencer "let (x, y, z) = (23, 12, true)";
- [%expect {|
- val x : int
- val y : int
- val z : bool|}]
-;;
-
-let%expect_test "inference tuples" =
- test_inferencer
- {|
- let rec fix f x = f (fix f) x
- let map f p = let (a,b) = p in (f a, f b)
- let fixpoly l =
- fix (fun self l -> map (fun li x -> li (self l) x) l) l
- let feven p n =
- let (e, o) = p in
- if n = 0 then 1 else o (n - 1)
- let fodd p n =
- let (e, o) = p in
- if n = 0 then 0 else e (n - 1)
- let tie = fixpoly (feven, fodd)
-
- let rec meven n = if n = 0 then 1 else modd (n - 1)
- and modd n = if n = 0 then 1 else meven (n - 1)
- let main =
- let () = print_int (modd 1) in
- let () = print_int (meven 2) in
- let (even,odd) = tie in
- let () = print_int (odd 3) in
- let () = print_int (even 4) in
- 0
- |};
- [%expect
- {|
- val feven : ((🍏 * ((int -> int))) -> (int -> int))
- val fix : (((🍏 -> 🍎) -> (🍏 -> 🍎)) -> (🍏 -> 🍎))
- val fixpoly : (((((((🍏 -> 🍎)) * ((🍏 -> 🍎))) -> (🍏 -> 🍎))) * (((((🍏 -> 🍎)) * ((🍏 -> 🍎))) -> (🍏 -> 🍎)))) -> (((🍏 -> 🍎)) * ((🍏 -> 🍎))))
- val fodd : ((((int -> int)) * 🍏) -> (int -> int))
- val main : int
- val map : ((🍏 -> 🍎) -> ((🍏 * 🍏) -> (🍎 * 🍎)))
- val meven : (int -> int)
- val modd : (int -> int)
- val tie : (((int -> int)) * ((int -> int))) |}]
-;;
-
-(* ========== list ========== *)
-
-let%expect_test "inference list pat" =
- test_inferencer "let [a] = [false]";
- [%expect {|
- val a : bool|}]
-;;
-
-let%expect_test "inference list integers" =
- test_inferencer "let l = [1; 2; 3]";
- [%expect {| val l : int list |}]
-;;
-
-(* ========== vars ========== *)
-
-let%expect_test "inference var simple" =
- test_inferencer "let a = 23 let b = a let c = b";
- [%expect {|
- val a : int
- val b : int
- val c : int|}]
-;;
-
-let%expect_test "inference var no" =
- test_inferencer "let a = 23 let b = 45 let c = d";
- [%expect {|
- Type inference error: Undefined variable 'd'|}]
-;;
-
-(* ========== fun ========== *)
-
-let%expect_test "2+2" =
- test_inferencer
- {|
- let two = fun f -> fun x -> f (f x)
- let plus = fun m -> fun n -> fun f -> fun x -> m f (n f x)
- let four = plus two two
- let x = four (fun x -> x + 1) 0
- |};
- [%expect
- {|
- val four : ((🍏 -> 🍏) -> (🍏 -> 🍏))
- val plus : ((🍏 -> (🍎 -> 🍐)) -> ((🍏 -> (🍊 -> 🍎)) -> (🍏 -> (🍊 -> 🍐))))
- val two : ((🍏 -> 🍏) -> (🍏 -> 🍏))
- val x : int|}]
-;;
-
-let%expect_test "2*2" =
- test_inferencer
- {|
- let two = fun f -> fun x -> f (f x)
- let mul = fun m -> fun n -> fun f -> fun x -> m (n f) x
- let four = mul two two
- let x = four (fun x -> x + 1) 0
- |};
- [%expect
- {|
- val four : ((🍏 -> 🍏) -> (🍏 -> 🍏))
- val mul : ((🍏 -> (🍎 -> 🍐)) -> ((🍊 -> 🍏) -> (🍊 -> (🍎 -> 🍐))))
- val two : ((🍏 -> 🍏) -> (🍏 -> 🍏))
- val x : int|}]
-;;
-
-let%expect_test "inference id" =
- test_inferencer "let id = fun x -> x";
- [%expect {| val id : (🍏 -> 🍏) |}]
-;;
-
-let%expect_test "inference app" =
- test_inferencer "let id = fun x -> x let x = id 42";
- [%expect {|
- val id : (🍏 -> 🍏)
- val x : int |}]
-;;
-
-let%expect_test "inference higher-order" =
- test_inferencer "let apply = fun f -> fun x -> f x";
- [%expect {| val apply : ((🍏 -> 🍎) -> (🍏 -> 🍎)) |}]
-;;
-
-let%expect_test "inference pattern on tuples" =
- test_inferencer "let fst = fun p -> let (x, y) = p in x";
- [%expect {| val fst : ((🍏 * 🍎) -> 🍏) |}]
-;;
-
-let%expect_test "inference composition" =
- test_inferencer "let compose = fun f -> fun g -> fun x -> f (g x)";
- [%expect {| val compose : ((🍏 -> 🍎) -> ((🍐 -> 🍏) -> (🍐 -> 🍎))) |}]
-;;
-
-(* ========== option ========== *)
-
-let%expect_test "inference option Some" =
- test_inferencer "let o = Some 42";
- [%expect {| val o : int option |}]
-;;
-
-let%expect_test "inference option None" =
- test_inferencer "let o = None";
- [%expect {| val o : 🍏 option |}]
-;;
-
-let%expect_test "inference wrap" =
- test_inferencer "let wrap = fun x -> Some x";
- [%expect {| val wrap : (🍏 -> 🍏 option) |}]
-;;
-
-(* ========== if ========== *)
-
-let%expect_test "inference simple if" =
- test_inferencer "let abs = fun x -> if x < 0 then -x else x";
- [%expect {| val abs : (int -> int) |}]
-;;
-
-let%expect_test "inference nested if" =
- test_inferencer "let sign = fun x -> if x > 0 then 1 else if x < 0 then -1 else 0";
- [%expect {| val sign : (int -> int) |}]
-;;
-
-(* ========== let ========== *)
-
-let%expect_test "inference shadowing" =
- test_inferencer "let x = let x = 42 in let x = true in x";
- [%expect {| val x : bool |}]
-;;
-
-let%expect_test "inference multiple let" =
- test_inferencer "let x = let a = 10 and b = 2 in a + b";
- [%expect {| val x : int |}]
-;;
-
-let%expect_test "inference let rec self" =
- test_inferencer "let rec x = x x";
- [%expect {| Type inference error: Cannot construct type: 🍏 appears within (🍏 -> 🍎) |}]
-;;
-
-let%expect_test "inference let rec lhs" =
- test_inferencer "let rec (x, y) = (23, 34)";
- [%expect {| Type inference error: Invalid left hand side |}]
-;;
-
-let%expect_test "inference let rec rhs" =
- test_inferencer "let rec f = f 23";
- [%expect {| Type inference error: Invalid right hand side |}]
-;;
-
-(* ========== constraint ========== *)
-
-let%expect_test "inference constraint" =
- test_inferencer "let f x y = y (x : bool)";
- [%expect {| val f : (bool -> ((bool -> 🍏) -> 🍏)) |}]
-;;
-
-let%expect_test "inference constraint 2" =
- test_inferencer "let f = fun x -> fun y -> (x x y : int)";
- [%expect {| Type inference error: Cannot construct type: 🍏 appears within (🍏 -> 🍎) |}]
-;;
diff --git a/EChirkov/tests/inferencer_tests.mli b/EChirkov/tests/inferencer_tests.mli
deleted file mode 100644
index a8c0d9e24..000000000
--- a/EChirkov/tests/inferencer_tests.mli
+++ /dev/null
@@ -1,3 +0,0 @@
-(** Copyright 2024-2025, Dmitri Chirkov*)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
diff --git a/EChirkov/tests/interpreter_tests.ml b/EChirkov/tests/interpreter_tests.ml
deleted file mode 100644
index 21b0a703e..000000000
--- a/EChirkov/tests/interpreter_tests.ml
+++ /dev/null
@@ -1,199 +0,0 @@
-(** Copyright 2024-2025, Dmitri Chirkov*)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open EChirkov.Parser
-open EChirkov.Interpreter
-
-let test_interpreter s =
- match parse s with
- | Ok s ->
- (* print_endline (show_program s); *)
- (match interpret s with
- | Ok _ -> ()
- | Error e -> print_endline ("Interpretation error: " ^ pp_error e))
- | Error _ -> print_endline "Parsing error"
-;;
-
-let%expect_test "interpret factorial function" =
- test_interpreter
- "let () = let rec factorial n = if n < 2 then 1 else n * factorial(n - 1) in \
- print_int (factorial 17)";
- [%expect {|355687428096000|}]
-;;
-
-(* ========== const ========== *)
-
-let%expect_test "interpret int" =
- test_interpreter "let () = print_int 23";
- [%expect {|23|}]
-;;
-
-(* ========== bop ========== *)
-
-let%expect_test "interpret addition" =
- test_interpreter "let () = print_int (23 + 23)";
- [%expect {|
- 46|}]
-;;
-
-let%expect_test "interpret subtraction" =
- test_interpreter "let () = print_int (23 - 21)";
- [%expect {|
- 2|}]
-;;
-
-let%expect_test "interpret multiplication" =
- test_interpreter "let () = print_int (123 * 23)";
- [%expect {|
- 2829|}]
-;;
-
-let%expect_test "interpret division whole" =
- test_interpreter "let () = print_int (240 / 4)";
- [%expect {|
- 60|}]
-;;
-
-let%expect_test "interpret division" =
- test_interpreter "let () = print_int (123 / 23)";
- [%expect {|
- 5|}]
-;;
-
-let%expect_test "interpret addition multiplication division" =
- test_interpreter "let () = print_int (6 / 2 * (1 + 2))";
- [%expect {|9|}]
-;;
-
-(* ========== unop ========== *)
-
-let%expect_test "interpret neg" =
- test_interpreter "let () = print_int (-1)";
- [%expect {|
- -1|}]
-;;
-
-let%expect_test "interpret neg" =
- test_interpreter "let () = print_int -1";
- [%expect {|
- Interpretation error: Type error|}]
-;;
-
-let%expect_test "interpret neg add" =
- test_interpreter "let () = print_int (-500 + +100)";
- [%expect {|
- -400|}]
-;;
-
-(* ========== tuples ========== *)
-
-let%expect_test "interpret tuple fst" =
- test_interpreter "let fst (x, y) = x let () = print_int (fst (23, 34))";
- [%expect {|
- 23|}]
-;;
-
-let%expect_test "interpret tuple multiple patterns" =
- test_interpreter
- {|
- let () =
- let a, b = 23, 34 in
- let c, d = a, b in
- let _ = print_int a in
- let _ = print_int b in
- let _ = print_int c in
- print_int d
- |};
- [%expect {|
- 23
- 34
- 23
- 34|}]
-;;
-
-(* ========== list ========== *)
-
-let%expect_test "interpret list empty" =
- test_interpreter "let () = print_int (if [] = [] then 1 else 0)";
- [%expect {|
- 1|}]
-;;
-
-let%expect_test "interpret list 1" =
- test_interpreter "let () = let [a] = [23] in print_int a";
- [%expect {|
- 23|}]
-;;
-
-(* ========== option ========== *)
-
-let%expect_test "interpret var simple" =
- test_interpreter
- {|
- let x = None
- let y = Some 23
- let z = Some 34
- let w = Some 23
- let () = print_int (if y = z then 1 else 0)
- let () = print_int (if x = y then 1 else 0)
- let () = print_int (if y = w then 1 else 0)
- let () = print_int (if x = w then 1 else 0)
- |};
- [%expect {|
- 0
- 0
- 1
- 0|}]
-;;
-
-(* ========== vars ========== *)
-
-let%expect_test "interpret var simple" =
- test_interpreter "let asd = 23 let () = print_int asd";
- [%expect {|
- 23|}]
-;;
-
-(* ========== fun ========== *)
-
-let%expect_test "interpret fun list" =
- test_interpreter
- {|
- let empty = fun f -> fun x -> x
- let cons x xs = fun f -> fun x0 -> xs f (f x x0)
- let print_list l = l (fun x rest -> let _ = print_int x in rest) ()
- let my_list = cons 1 (cons 2 (cons 3 empty))
- let () = print_list my_list
- |};
- [%expect {|
- 1
- 2
- 3|}]
-;;
-
-(* ========== let ========== *)
-
-let%expect_test "interpret let simple" =
- test_interpreter "let () = let x = 5 in let y = 2 in print_int (x + y)";
- [%expect {|
- 7|}]
-;;
-
-let%expect_test "interpret let unbound" =
- test_interpreter "let () = print_int a";
- [%expect {|
- Interpretation error: Unbound variable: a|}]
-;;
-
-let%expect_test "interpret let types" =
- test_interpreter "let a = 23 and () = print_int (a + false)";
- [%expect {|
- Interpretation error: Type error|}]
-;;
-
-let%expect_test "interpret let zero" =
- test_interpreter "let () = print_int (23 / 0)";
- [%expect {|
- Interpretation error: Division by zero|}]
-;;
diff --git a/EChirkov/tests/interpreter_tests.mli b/EChirkov/tests/interpreter_tests.mli
deleted file mode 100644
index a8c0d9e24..000000000
--- a/EChirkov/tests/interpreter_tests.mli
+++ /dev/null
@@ -1,3 +0,0 @@
-(** Copyright 2024-2025, Dmitri Chirkov*)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
diff --git a/EChirkov/tests/parser_tests.ml b/EChirkov/tests/parser_tests.ml
deleted file mode 100644
index 597bf76fc..000000000
--- a/EChirkov/tests/parser_tests.ml
+++ /dev/null
@@ -1,374 +0,0 @@
-(** Copyright 2024-2025, Dmitri Chirkov*)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open EChirkov.Parser
-open EChirkov.Ast
-
-let test_parser s =
- match parse s with
- | Ok s -> print_endline (show_program s)
- | Error _ -> print_endline "Parsing error"
-;;
-
-let%expect_test "parse simple let" =
- test_parser "let x = 23";
- [%expect {|[(SValue (Nonrecursive, ((PVar "x"), (EConst (CInt 23))), []))]|}]
-;;
-
-let%expect_test "parse factorial function" =
- test_parser "let rec factorial n = if n < 2 then 1 else n * factorial(n - 1)";
- [%expect
- {|
- [(SValue (Recursive,
- ((PVar "factorial"),
- (EFun ((PVar "n"),
- (EIf ((EBinary (Lt, (EVar "n"), (EConst (CInt 2)))),
- (EConst (CInt 1)),
- (Some (EBinary (Mul, (EVar "n"),
- (EApply ((EVar "factorial"),
- (EBinary (Sub, (EVar "n"), (EConst (CInt 1))))))
- )))
- ))
- ))),
- []))
- ]|}]
-;;
-
-(* ========== const ========== *)
-
-let%expect_test "parse int" =
- test_parser "let () = 23";
- [%expect {|[(SValue (Nonrecursive, ((PConst CUnit), (EConst (CInt 23))), []))]|}]
-;;
-
-let%expect_test "parse bool t" =
- test_parser "let () = true";
- [%expect {|[(SValue (Nonrecursive, ((PConst CUnit), (EConst (CBool true))), []))]|}]
-;;
-
-let%expect_test "parse bool f" =
- test_parser "let () = false";
- [%expect {|[(SValue (Nonrecursive, ((PConst CUnit), (EConst (CBool false))), []))]|}]
-;;
-
-(* ========== bop ========== *)
-
-let%expect_test "parse compare int" =
- test_parser "let () = 2 > 56";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PConst CUnit), (EBinary (Gt, (EConst (CInt 2)), (EConst (CInt 56))))),
- []))
- ]|}]
-;;
-
-let%expect_test "parse compare int" =
- test_parser "let () = 2 < 56";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PConst CUnit), (EBinary (Lt, (EConst (CInt 2)), (EConst (CInt 56))))),
- []))
- ]|}]
-;;
-
-let%expect_test "parse compare int" =
- test_parser "let () = 2 >= 56";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PConst CUnit), (EBinary (Gte, (EConst (CInt 2)), (EConst (CInt 56))))),
- []))
- ]|}]
-;;
-
-let%expect_test "parse compare int" =
- test_parser "let () = 2 <= 56";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PConst CUnit), (EBinary (Lte, (EConst (CInt 2)), (EConst (CInt 56))))),
- []))
- ]|}]
-;;
-
-let%expect_test "parse compare int" =
- test_parser "let () = 2 = 56";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PConst CUnit), (EBinary (Eq, (EConst (CInt 2)), (EConst (CInt 56))))),
- []))
- ]|}]
-;;
-
-let%expect_test "parse compare int" =
- test_parser "let () = 2 <> 56";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PConst CUnit), (EBinary (NEq, (EConst (CInt 2)), (EConst (CInt 56))))),
- []))
- ]|}]
-;;
-
-let%expect_test "parse compare and" =
- test_parser "let () = true && false";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PConst CUnit),
- (EBinary (And, (EConst (CBool true)), (EConst (CBool false))))),
- []))
- ]|}]
-;;
-
-let%expect_test "parse compare or" =
- test_parser "let () = false || true";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PConst CUnit),
- (EBinary (Or, (EConst (CBool false)), (EConst (CBool true))))),
- []))
- ]|}]
-;;
-
-(* ========== unop ========== *)
-
-let%expect_test "parse neg" =
- test_parser "let () = (-1)";
- [%expect
- {|
- [(SValue (Nonrecursive, ((PConst CUnit), (EUnary (Neg, (EConst (CInt 1))))),
- []))
- ]|}]
-;;
-
-let%expect_test "parse neg apply" =
- test_parser "let () = asd (-1)";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PConst CUnit),
- (EApply ((EVar "asd"), (EUnary (Neg, (EConst (CInt 1))))))),
- []))
- ]|}]
-;;
-
-let%expect_test "parse neg pos" =
- test_parser "let () = (-1) + (+5)";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PConst CUnit),
- (EBinary (Add, (EUnary (Neg, (EConst (CInt 1)))),
- (EUnary (Pos, (EConst (CInt 5))))))),
- []))
- ]|}]
-;;
-
-(* ========== tuples ========== *)
-
-let%expect_test "parse tuple 2" =
- test_parser "let () = (12, 23)";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PConst CUnit), (ETuple ((EConst (CInt 12)), (EConst (CInt 23)), []))),
- []))
- ]|}]
-;;
-
-let%expect_test "parse tuple 3" =
- test_parser "let () = (12, 23, 45)";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PConst CUnit),
- (ETuple ((EConst (CInt 12)), (EConst (CInt 23)), [(EConst (CInt 45))]))),
- []))
- ]|}]
-;;
-
-let%expect_test "parse tuple 2 d" =
- test_parser "let () = (12, true)";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PConst CUnit), (ETuple ((EConst (CInt 12)), (EConst (CBool true)), []))),
- []))
- ]|}]
-;;
-
-let%expect_test "parse tuple 3 d" =
- test_parser "let () = (12, true, ())";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PConst CUnit),
- (ETuple ((EConst (CInt 12)), (EConst (CBool true)), [(EConst CUnit)]))),
- []))
- ]|}]
-;;
-
-let%expect_test "parse tuple inn" =
- test_parser "let () = ((12, 23), 45, (345, false, true))";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PConst CUnit),
- (ETuple ((ETuple ((EConst (CInt 12)), (EConst (CInt 23)), [])),
- (EConst (CInt 45)),
- [(ETuple ((EConst (CInt 345)), (EConst (CBool false)),
- [(EConst (CBool true))]))
- ]
- ))),
- []))
- ]|}]
-;;
-
-let%expect_test "parse tuple pat" =
- test_parser "let (a, b) = (6, 9)";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PTuple ((PVar "a"), (PVar "b"), [])),
- (ETuple ((EConst (CInt 6)), (EConst (CInt 9)), []))),
- []))
- ]|}]
-;;
-
-(* ========== list ========== *)
-
-let%expect_test "parse list empty" =
- test_parser "let () = []";
- [%expect {|
- [(SValue (Nonrecursive, ((PConst CUnit), (EList [])), []))]|}]
-;;
-
-let%expect_test "parse list 1" =
- test_parser "let () = [23]";
- [%expect
- {|
- [(SValue (Nonrecursive, ((PConst CUnit), (EList [(EConst (CInt 23))])), []))]|}]
-;;
-
-let%expect_test "parse list 2" =
- test_parser "let () = [23; 45]";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PConst CUnit), (EList [(EConst (CInt 23)); (EConst (CInt 45))])),
- []))
- ]|}]
-;;
-
-let%expect_test "parse list list" =
- test_parser "let () = [[234; 456]; []]";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PConst CUnit),
- (EList [(EList [(EConst (CInt 234)); (EConst (CInt 456))]); (EList [])])),
- []))
- ]|}]
-;;
-
-let%expect_test "parse list pat" =
- test_parser "let [a] = [6]";
- [%expect
- {|
- [(SValue (Nonrecursive, ((PList [(PVar "a")]), (EList [(EConst (CInt 6))])),
- []))
- ]|}]
-;;
-
-(* ========== option ========== *)
-
-let%expect_test "parse option var" =
- test_parser "let () = Some x";
- [%expect
- {|
- [(SValue (Nonrecursive, ((PConst CUnit), (EOption (Some (EVar "x")))), []))]|}]
-;;
-
-let%expect_test "parse option p var" =
- test_parser "let () = Some (x)";
- [%expect
- {|
- [(SValue (Nonrecursive, ((PConst CUnit), (EOption (Some (EVar "x")))), []))]|}]
-;;
-
-let%expect_test "parse option none" =
- test_parser "let () = None";
- [%expect {|
- [(SValue (Nonrecursive, ((PConst CUnit), (EOption None)), []))]|}]
-;;
-
-(* ========== vars ========== *)
-
-let%expect_test "parse var simple" =
- test_parser "let () = asd";
- [%expect {|
- [(SValue (Nonrecursive, ((PConst CUnit), (EVar "asd")), []))]|}]
-;;
-
-let%expect_test "parse var start underscore" =
- test_parser "let () = _asd";
- [%expect {|
- [(SValue (Nonrecursive, ((PConst CUnit), (EVar "_asd")), []))]|}]
-;;
-
-let%expect_test "parse var underscore fail" =
- test_parser "let () = _";
- [%expect {|
- Parsing error|}]
-;;
-
-let%expect_test "parse var double underscore not fail" =
- test_parser "let () = __";
- [%expect {|
- [(SValue (Nonrecursive, ((PConst CUnit), (EVar "__")), []))]|}]
-;;
-
-let%expect_test "parse underscore number" =
- test_parser "let () = _0kajsndf";
- [%expect {|
- [(SValue (Nonrecursive, ((PConst CUnit), (EVar "_0kajsndf")), []))]|}]
-;;
-
-let%expect_test "parse number" =
- test_parser "let () = 0kajsndf";
- [%expect {|
- Parsing error|}]
-;;
-
-(* ========== fun ========== *)
-
-let%expect_test "parse fun simple" =
- test_parser "let () = fun x -> y";
- [%expect
- {|
- [(SValue (Nonrecursive, ((PConst CUnit), (EFun ((PVar "x"), (EVar "y")))),
- []))
- ]|}]
-;;
-
-(* ========== let ========== *)
-
-let%expect_test "parse fun simple" =
- test_parser "let () = let x = 5 in let y = 2 in x + y";
- [%expect
- {|
- [(SValue (Nonrecursive,
- ((PConst CUnit),
- (ELet (Nonrecursive, ((PVar "x"), (EConst (CInt 5))), [],
- (ELet (Nonrecursive, ((PVar "y"), (EConst (CInt 2))), [],
- (EBinary (Add, (EVar "x"), (EVar "y")))))
- ))),
- []))
- ]|}]
-;;
diff --git a/EChirkov/tests/parser_tests.mli b/EChirkov/tests/parser_tests.mli
deleted file mode 100644
index a8c0d9e24..000000000
--- a/EChirkov/tests/parser_tests.mli
+++ /dev/null
@@ -1,3 +0,0 @@
-(** Copyright 2024-2025, Dmitri Chirkov*)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
diff --git a/EChirkov/tests/test.t b/EChirkov/tests/test.t
deleted file mode 100644
index c06ee88eb..000000000
--- a/EChirkov/tests/test.t
+++ /dev/null
@@ -1,139 +0,0 @@
-(** Copyright 2024-2025, Dmitri Chirkov*)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
- $ ../bin/main.exe --interpret manytests/typed/001fac.ml
- 24
-
- $ ../bin/main.exe --interpret manytests/typed/002fac.ml
- 24
-
- $ ../bin/main.exe --interpret manytests/typed/003fib.ml
- 3
- 3
-
- $ ../bin/main.exe --interpret manytests/typed/004manyargs.ml
- 1111111111
- 1
- 10
- 100
-
- $ ../bin/main.exe --interpret manytests/typed/005fix.ml
- 720
-
- $ ../bin/main.exe --interpret manytests/typed/006partial.ml
- 1122
-
- $ ../bin/main.exe --interpret manytests/typed/006partial2.ml
- 1
- 2
- 3
- 7
-
- $ ../bin/main.exe --interpret manytests/typed/006partial3.ml
- 4
- 8
- 9
-
- $ ../bin/main.exe --interpret manytests/typed/007order.ml
- 1
- 2
- 4
- -1
- 103
- -555555
- 10000
-
- $ ../bin/main.exe --interpret manytests/typed/009let_poly.ml
-
- $ ../bin/main.exe --interpret manytests/typed/015tuples.ml
- 1
- 1
- 1
- 1
-
- $ ../bin/main.exe --infer manytests/typed/001fac.ml
- val fac : (int -> int)
- val main : int
-
- $ ../bin/main.exe --infer manytests/typed/002fac.ml
- val fac_cps : (int -> ((int -> 🍏) -> 🍏))
- val main : int
-
- $ ../bin/main.exe --infer manytests/typed/003fib.ml
- val fib : (int -> int)
- val fib_acc : (int -> (int -> (int -> int)))
- val main : int
-
- $ ../bin/main.exe --infer manytests/typed/004manyargs.ml
- val main : int
- val test10 : (int -> (int -> (int -> (int -> (int -> (int -> (int -> (int -> (int -> (int -> int))))))))))
- val test3 : (int -> (int -> (int -> int)))
- val wrap : (🍏 -> 🍏)
-
- $ ../bin/main.exe --infer manytests/typed/005fix.ml
- val fac : ((int -> int) -> (int -> int))
- val fix : (((🍏 -> 🍎) -> (🍏 -> 🍎)) -> (🍏 -> 🍎))
- val main : int
-
- $ ../bin/main.exe --infer manytests/typed/006partial.ml
- val foo : (int -> int)
- val main : int
-
- $ ../bin/main.exe --infer manytests/typed/006partial2.ml
- val foo : (int -> (int -> (int -> int)))
- val main : int
-
- $ ../bin/main.exe --infer manytests/typed/006partial3.ml
- val foo : (int -> (int -> (int -> unit)))
- val main : int
-
- $ ../bin/main.exe --infer manytests/typed/007order.ml
- val _start : (unit -> (unit -> (int -> (unit -> (int -> (int -> (unit -> (int -> (int -> int)))))))))
- val main : unit
-
- $ ../bin/main.exe --infer manytests/typed/008ascription.ml
- val addi : ((🍏 -> (bool -> int)) -> ((🍏 -> bool) -> (🍏 -> int)))
- val main : int
-
- $ ../bin/main.exe --infer manytests/typed/009let_poly.ml
- val temp : (int * bool)
-
- $ ../bin/main.exe --infer manytests/typed/015tuples.ml
- val feven : ((🍏 * ((int -> int))) -> (int -> int))
- val fix : (((🍏 -> 🍎) -> (🍏 -> 🍎)) -> (🍏 -> 🍎))
- val fixpoly : (((((((🍏 -> 🍎)) * ((🍏 -> 🍎))) -> (🍏 -> 🍎))) * (((((🍏 -> 🍎)) * ((🍏 -> 🍎))) -> (🍏 -> 🍎)))) -> (((🍏 -> 🍎)) * ((🍏 -> 🍎))))
- val fodd : ((((int -> int)) * 🍏) -> (int -> int))
- val main : int
- val map : ((🍏 -> 🍎) -> ((🍏 * 🍏) -> (🍎 * 🍎)))
- val meven : (int -> int)
- val modd : (int -> int)
- val tie : (((int -> int)) * ((int -> int)))
-
-
- $ ../bin/main.exe --infer manytests/do_not_type/001.ml
- Type inference error: Undefined variable 'fac'
-
- $ ../bin/main.exe --infer manytests/do_not_type/002if.ml
- Type inference error: Unification failed on int and bool
-
- $ ../bin/main.exe --infer manytests/do_not_type/003occurs.ml
- Type inference error: Cannot construct type: 🍏 appears within (🍏 -> 🍎)
-
- $ ../bin/main.exe --infer manytests/do_not_type/004let_poly.ml
- Type inference error: Unification failed on bool and int
-
- $ ../bin/main.exe --infer manytests/do_not_type/015tuples.ml
- Type inference error: Invalid left hand side
-
- $ ../bin/main.exe --infer manytests/do_not_type/016tuples_mismatch.ml
- Type inference error: Unification failed on (🍏 * 🍎) and (int * int * int)
-
- $ ../bin/main.exe --infer manytests/do_not_type/097fun_vs_list.ml
- Type inference error: Unification failed on 🍏 list and (🍏 -> 🍏)
-
- $ ../bin/main.exe --infer manytests/do_not_type/097fun_vs_unit.ml
- Type inference error: Unification failed on unit and (🍏 -> 🍏)
-
- $ ../bin/main.exe --infer manytests/do_not_type/098rec_int.ml
- Type inference error: Invalid right hand side
diff --git a/EIshbaev/.envrc b/EIshbaev/.envrc
deleted file mode 100644
index e6bd6786d..000000000
--- a/EIshbaev/.envrc
+++ /dev/null
@@ -1,3 +0,0 @@
-export OPAMSWITCH=4.14.2+flambda
-eval $(opam env)
-
diff --git a/EIshbaev/.gitignore b/EIshbaev/.gitignore
deleted file mode 100644
index 7102a822c..000000000
--- a/EIshbaev/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-_build
-_coverage
-/_esy
-/node_modules
-/esy.lock
-/.melange.eobjs
diff --git a/EIshbaev/.ocamlformat b/EIshbaev/.ocamlformat
deleted file mode 100644
index 97f970802..000000000
--- a/EIshbaev/.ocamlformat
+++ /dev/null
@@ -1,2 +0,0 @@
-profile=janestreet
-version=0.26.2
diff --git a/EIshbaev/.zanuda b/EIshbaev/.zanuda
deleted file mode 100644
index 0f09b19b2..000000000
--- a/EIshbaev/.zanuda
+++ /dev/null
@@ -1 +0,0 @@
-forward mutability_check ignore REPL.ml
diff --git a/EIshbaev/COPYING b/EIshbaev/COPYING
deleted file mode 100644
index f288702d2..000000000
--- a/EIshbaev/COPYING
+++ /dev/null
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is 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. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- 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.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- 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 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. Use with the GNU Affero General Public License.
-
- 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 Affero 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 special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU 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 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 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 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.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- Copyright (C)
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- 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 GPL, see
-.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-.
diff --git a/EIshbaev/COPYING.CC0 b/EIshbaev/COPYING.CC0
deleted file mode 100644
index 0e259d42c..000000000
--- a/EIshbaev/COPYING.CC0
+++ /dev/null
@@ -1,121 +0,0 @@
-Creative Commons Legal Code
-
-CC0 1.0 Universal
-
- CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
- LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
- ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
- INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
- REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
- PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
- THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
- HEREUNDER.
-
-Statement of Purpose
-
-The laws of most jurisdictions throughout the world automatically confer
-exclusive Copyright and Related Rights (defined below) upon the creator
-and subsequent owner(s) (each and all, an "owner") of an original work of
-authorship and/or a database (each, a "Work").
-
-Certain owners wish to permanently relinquish those rights to a Work for
-the purpose of contributing to a commons of creative, cultural and
-scientific works ("Commons") that the public can reliably and without fear
-of later claims of infringement build upon, modify, incorporate in other
-works, reuse and redistribute as freely as possible in any form whatsoever
-and for any purposes, including without limitation commercial purposes.
-These owners may contribute to the Commons to promote the ideal of a free
-culture and the further production of creative, cultural and scientific
-works, or to gain reputation or greater distribution for their Work in
-part through the use and efforts of others.
-
-For these and/or other purposes and motivations, and without any
-expectation of additional consideration or compensation, the person
-associating CC0 with a Work (the "Affirmer"), to the extent that he or she
-is an owner of Copyright and Related Rights in the Work, voluntarily
-elects to apply CC0 to the Work and publicly distribute the Work under its
-terms, with knowledge of his or her Copyright and Related Rights in the
-Work and the meaning and intended legal effect of CC0 on those rights.
-
-1. Copyright and Related Rights. A Work made available under CC0 may be
-protected by copyright and related or neighboring rights ("Copyright and
-Related Rights"). Copyright and Related Rights include, but are not
-limited to, the following:
-
- i. the right to reproduce, adapt, distribute, perform, display,
- communicate, and translate a Work;
- ii. moral rights retained by the original author(s) and/or performer(s);
-iii. publicity and privacy rights pertaining to a person's image or
- likeness depicted in a Work;
- iv. rights protecting against unfair competition in regards to a Work,
- subject to the limitations in paragraph 4(a), below;
- v. rights protecting the extraction, dissemination, use and reuse of data
- in a Work;
- vi. database rights (such as those arising under Directive 96/9/EC of the
- European Parliament and of the Council of 11 March 1996 on the legal
- protection of databases, and under any national implementation
- thereof, including any amended or successor version of such
- directive); and
-vii. other similar, equivalent or corresponding rights throughout the
- world based on applicable law or treaty, and any national
- implementations thereof.
-
-2. Waiver. To the greatest extent permitted by, but not in contravention
-of, applicable law, Affirmer hereby overtly, fully, permanently,
-irrevocably and unconditionally waives, abandons, and surrenders all of
-Affirmer's Copyright and Related Rights and associated claims and causes
-of action, whether now known or unknown (including existing as well as
-future claims and causes of action), in the Work (i) in all territories
-worldwide, (ii) for the maximum duration provided by applicable law or
-treaty (including future time extensions), (iii) in any current or future
-medium and for any number of copies, and (iv) for any purpose whatsoever,
-including without limitation commercial, advertising or promotional
-purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
-member of the public at large and to the detriment of Affirmer's heirs and
-successors, fully intending that such Waiver shall not be subject to
-revocation, rescission, cancellation, termination, or any other legal or
-equitable action to disrupt the quiet enjoyment of the Work by the public
-as contemplated by Affirmer's express Statement of Purpose.
-
-3. Public License Fallback. Should any part of the Waiver for any reason
-be judged legally invalid or ineffective under applicable law, then the
-Waiver shall be preserved to the maximum extent permitted taking into
-account Affirmer's express Statement of Purpose. In addition, to the
-extent the Waiver is so judged Affirmer hereby grants to each affected
-person a royalty-free, non transferable, non sublicensable, non exclusive,
-irrevocable and unconditional license to exercise Affirmer's Copyright and
-Related Rights in the Work (i) in all territories worldwide, (ii) for the
-maximum duration provided by applicable law or treaty (including future
-time extensions), (iii) in any current or future medium and for any number
-of copies, and (iv) for any purpose whatsoever, including without
-limitation commercial, advertising or promotional purposes (the
-"License"). The License shall be deemed effective as of the date CC0 was
-applied by Affirmer to the Work. Should any part of the License for any
-reason be judged legally invalid or ineffective under applicable law, such
-partial invalidity or ineffectiveness shall not invalidate the remainder
-of the License, and in such case Affirmer hereby affirms that he or she
-will not (i) exercise any of his or her remaining Copyright and Related
-Rights in the Work or (ii) assert any associated claims and causes of
-action with respect to the Work, in either case contrary to Affirmer's
-express Statement of Purpose.
-
-4. Limitations and Disclaimers.
-
- a. No trademark or patent rights held by Affirmer are waived, abandoned,
- surrendered, licensed or otherwise affected by this document.
- b. Affirmer offers the Work as-is and makes no representations or
- warranties of any kind concerning the Work, express, implied,
- statutory or otherwise, including without limitation warranties of
- title, merchantability, fitness for a particular purpose, non
- infringement, or the absence of latent or other defects, accuracy, or
- the present or absence of errors, whether or not discoverable, all to
- the greatest extent permissible under applicable law.
- c. Affirmer disclaims responsibility for clearing rights of other persons
- that may apply to the Work or any use thereof, including without
- limitation any person's Copyright and Related Rights in the Work.
- Further, Affirmer disclaims responsibility for obtaining any necessary
- consents, permissions or other rights required for any use of the
- Work.
- d. Affirmer understands and acknowledges that Creative Commons is not a
- party to this document and has no duty or obligation with respect to
- this CC0 or use of the Work.
diff --git a/EIshbaev/COPYING.LESSER b/EIshbaev/COPYING.LESSER
deleted file mode 100644
index 0a041280b..000000000
--- a/EIshbaev/COPYING.LESSER
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser 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
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/EIshbaev/EIshbaev.opam b/EIshbaev/EIshbaev.opam
deleted file mode 100644
index e62b04460..000000000
--- a/EIshbaev/EIshbaev.opam
+++ /dev/null
@@ -1,35 +0,0 @@
-# This file is generated by dune, edit dune-project instead
-opam-version: "2.0"
-version: "0.1"
-synopsis: "An interpreter for MiniML"
-description:
- "FIXME. A longer description, for example, which are the most interesing features being supported, etc."
-maintainer: ["Ishbaev Azamat "]
-authors: ["Ishbaev Azamat "]
-license: "LGPL-3.0-or-later"
-homepage: "https://github.com/Kakadu/fp2024"
-doc: "https://kakadu.github.io/fp2024/docs/Lambda"
-bug-reports: "https://github.com/Kakadu/fp2024"
-depends: [
- "dune" {>= "3.7"}
- "ppx_inline_test" {with-test}
- "ppx_expect"
- "ppx_deriving"
- "bisect_ppx"
- "odoc" {with-doc}
- "ocamlformat" {build}
-]
-build: [
- ["dune" "subst"] {dev}
- [
- "dune"
- "build"
- "-p"
- name
- "-j"
- jobs
- "@install"
- "@runtest" {with-test}
- "@doc" {with-doc}
- ]
-]
diff --git a/EIshbaev/Makefile b/EIshbaev/Makefile
deleted file mode 100644
index e234db4bf..000000000
--- a/EIshbaev/Makefile
+++ /dev/null
@@ -1,49 +0,0 @@
-.PHONY: repl tests test fmt lint celan
-
-all:
- dune build
-
-repl:
- dune build ./REPL.exe && rlwrap _build/default/REPL.exe
-
-tests: test
-test:
- dune runtest
-
-celan: clean
-clean:
- @$(RM) -r _build _coverage
-
-fmt:
- dune build @fmt --auto-promote
-
-lint:
- dune build @lint --force
-
-release:
- dune build --profile=release
- dune runtest --profile=release
-
-install:
- dune b @install --profile=release
- dune install
-
-ODIG_SWITCHES = --odoc-theme=odig.gruvbox.light
-ODIG_SWITCHES += --no-tag-index
-ODIG_SWITCHES += --no-pkg-deps
-odig:
- odig odoc $(ODIG_SWITCHES) Lambda
-
-TEST_COV_D = /tmp/cov
-COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect tests/
-
-.PHONY: test_coverage coverage
-test_coverage: coverage
-coverage:
- $(RM) -r $(TEST_COV_D)
- mkdir -p $(TEST_COV_D)
- BISECT_FILE=$(TEST_COV_D)/language dune runtest --no-print-directory \
- --instrument-with bisect_ppx --force
- bisect-ppx-report html $(COVERAGE_OPTS)
- bisect-ppx-report summary $(COVERAGE_OPTS)
- @echo "Use 'xdg-open _coverage/index.html' to see coverage report"
diff --git a/EIshbaev/bin/dune b/EIshbaev/bin/dune
deleted file mode 100644
index 4acbd36ec..000000000
--- a/EIshbaev/bin/dune
+++ /dev/null
@@ -1,6 +0,0 @@
-(executable
- (name main)
- (public_name EIshbaev)
- (libraries EIshbaev_lib)
- (instrumentation
- (backend bisect_ppx)))
diff --git a/EIshbaev/bin/main.ml b/EIshbaev/bin/main.ml
deleted file mode 100644
index f8a74740a..000000000
--- a/EIshbaev/bin/main.ml
+++ /dev/null
@@ -1,29 +0,0 @@
-(** Copyright 2024-2025, Azamat Ishbaev *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open EIshbaev_lib.Ast
-
-let () =
- let fact : structure =
- [ ExprLet
- ( Rec
- , [ ( PatVar "fact"
- , ExprFunc
- ( "x"
- , ExprCond
- ( ExprBinop (Lesq, ExprVar "x", ExprConst (ConstInt 1))
- , ExprConst (ConstInt 1)
- , ExprBinop
- ( Mul
- , ExprVar "x"
- , ExprApp
- ( ExprVar "fact"
- , ExprBinop (Sub, ExprVar "x", ExprConst (ConstInt 1)) ) ) )
- ) )
- ]
- , ExprVar "n" )
- ]
- in
- print_endline (show_structure fact)
-;;
diff --git a/EIshbaev/dune b/EIshbaev/dune
deleted file mode 100644
index 98e54536a..000000000
--- a/EIshbaev/dune
+++ /dev/null
@@ -1,7 +0,0 @@
-(env
- (dev
- (flags
- (:standard -alert @deprecated -warn-error -A -w -3-9-32-34-58)))
- (release
- (flags
- (:standard -alert @deprecated -warn-error +A -w +A-4-40-42-44-70))))
diff --git a/EIshbaev/dune-project b/EIshbaev/dune-project
deleted file mode 100644
index 0432d90a9..000000000
--- a/EIshbaev/dune-project
+++ /dev/null
@@ -1,34 +0,0 @@
-(lang dune 3.7)
-
-(generate_opam_files true)
-
-(cram enable)
-
-(license LGPL-3.0-or-later)
-
-(authors "Ishbaev Azamat ")
-
-(maintainers "Ishbaev Azamat ")
-
-(bug_reports "https://github.com/Kakadu/fp2024")
-
-(homepage "https://github.com/Kakadu/fp2024")
-
-(package
- (name EIshbaev) ; FIXME and regenerate .opam file using 'dune build @install'
- (synopsis "An interpreter for MiniML")
- (description
- "FIXME. A longer description, for example, which are the most interesing features being supported, etc.")
- (documentation "https://kakadu.github.io/fp2024/docs/Lambda")
- (version 0.1)
- (depends
- dune
- (ppx_inline_test :with-test)
- ppx_expect
- ppx_deriving
- bisect_ppx
- (odoc :with-doc)
- (ocamlformat :build)
- ; base
- ; After adding dependencies to 'dune' files add the same dependecies here too
- ))
diff --git a/EIshbaev/lib/ast.ml b/EIshbaev/lib/ast.ml
deleted file mode 100644
index 5a146ede2..000000000
--- a/EIshbaev/lib/ast.ml
+++ /dev/null
@@ -1,59 +0,0 @@
-(** Copyright 2024-2025, Azamat Ishbaev *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-type name = string [@@deriving show { with_path = false }]
-
-(** Constants *)
-type const =
- | ConstInt of int (** integers *)
- | ConstBool of bool (** true or false *)
- | ConstUnit (** Unit () *)
- | ConstNil (** [] *)
-[@@deriving show { with_path = false }]
-
-(** Binary operations *)
-type binop =
- | Add (** "+" *)
- | Sub (** "-" *)
- | Div (** "/" *)
- | Mul (** "*" *)
- | Lesq (** "<=" *)
- | Greq (** ">=" *)
- | Gre (** ">" *)
- | Les (** "<" *)
- | Eql (** "=" *)
- | Neq (** "!=" *)
- | And (** "&&" *)
- | Or (** "||" *)
-[@@deriving show { with_path = false }]
-
-(** Recursive flag *)
-type recursive =
- | Rec (** recursive function *)
- | NotRec (** Non-recursive functions *)
-[@@deriving show { with_path = false }]
-
-type pattern =
- | PatConst of const (** const -> ... *)
- | PatVar of name (** var -> ... *)
- | PatWild (** _ -> ... *)
- | PatEmpty (** [] -> ... *)
- | PatTuple of pattern * pattern * pattern list (** x_1 :: x_2, x_3 :: x_4 *)
- | PatConc of pattern * pattern * pattern list (** x_1 :: x_2 -> ... *)
- | PatOr of pattern * pattern * pattern list (** x_1 | x_2 -> ... *)
-[@@deriving show { with_path = false }]
-
-type expr =
- | ExprConst of const (** consts *)
- | ExprVar of name (** variebles with names *)
- | ExprBinop of binop * expr * expr (** x_1 binop x_2 *)
- | ExprTuple of expr * expr * expr list (** list with x_i separeted via "," *)
- | ExprFunc of name * expr (** anonymous functions *)
- | ExprCond of expr * expr * expr (** if then else *)
- | ExprLet of recursive * (pattern * expr) list * expr (** let rec fun *)
- | ExprApp of expr * expr (** application *)
- | ExprMatch of expr * (pattern * expr) list (** match x_1 with | x_2 -> x_3 | ... *)
-[@@deriving show { with_path = false }]
-
-type structure = expr list [@@deriving show { with_path = false }]
diff --git a/EIshbaev/lib/ast.mli b/EIshbaev/lib/ast.mli
deleted file mode 100644
index 5a146ede2..000000000
--- a/EIshbaev/lib/ast.mli
+++ /dev/null
@@ -1,59 +0,0 @@
-(** Copyright 2024-2025, Azamat Ishbaev *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-type name = string [@@deriving show { with_path = false }]
-
-(** Constants *)
-type const =
- | ConstInt of int (** integers *)
- | ConstBool of bool (** true or false *)
- | ConstUnit (** Unit () *)
- | ConstNil (** [] *)
-[@@deriving show { with_path = false }]
-
-(** Binary operations *)
-type binop =
- | Add (** "+" *)
- | Sub (** "-" *)
- | Div (** "/" *)
- | Mul (** "*" *)
- | Lesq (** "<=" *)
- | Greq (** ">=" *)
- | Gre (** ">" *)
- | Les (** "<" *)
- | Eql (** "=" *)
- | Neq (** "!=" *)
- | And (** "&&" *)
- | Or (** "||" *)
-[@@deriving show { with_path = false }]
-
-(** Recursive flag *)
-type recursive =
- | Rec (** recursive function *)
- | NotRec (** Non-recursive functions *)
-[@@deriving show { with_path = false }]
-
-type pattern =
- | PatConst of const (** const -> ... *)
- | PatVar of name (** var -> ... *)
- | PatWild (** _ -> ... *)
- | PatEmpty (** [] -> ... *)
- | PatTuple of pattern * pattern * pattern list (** x_1 :: x_2, x_3 :: x_4 *)
- | PatConc of pattern * pattern * pattern list (** x_1 :: x_2 -> ... *)
- | PatOr of pattern * pattern * pattern list (** x_1 | x_2 -> ... *)
-[@@deriving show { with_path = false }]
-
-type expr =
- | ExprConst of const (** consts *)
- | ExprVar of name (** variebles with names *)
- | ExprBinop of binop * expr * expr (** x_1 binop x_2 *)
- | ExprTuple of expr * expr * expr list (** list with x_i separeted via "," *)
- | ExprFunc of name * expr (** anonymous functions *)
- | ExprCond of expr * expr * expr (** if then else *)
- | ExprLet of recursive * (pattern * expr) list * expr (** let rec fun *)
- | ExprApp of expr * expr (** application *)
- | ExprMatch of expr * (pattern * expr) list (** match x_1 with | x_2 -> x_3 | ... *)
-[@@deriving show { with_path = false }]
-
-type structure = expr list [@@deriving show { with_path = false }]
diff --git a/EIshbaev/lib/dune b/EIshbaev/lib/dune
deleted file mode 100644
index 612e5786b..000000000
--- a/EIshbaev/lib/dune
+++ /dev/null
@@ -1,18 +0,0 @@
-(library
- (name EIshbaev_lib)
- (public_name EIshbaev.Lib)
- (modules Ast)
- (preprocess
- (pps ppx_deriving.show))
- (instrumentation
- (backend bisect_ppx)))
-
-; (library
-; (name tests)
-; (modules tests)
-; (libraries lambda_lib)
-; (preprocess
-; (pps ppx_expect ppx_deriving.show))
-; (instrumentation
-; (backend bisect_ppx))
-; (inline_tests))
diff --git a/EIshbaev/tests/ast_test.t b/EIshbaev/tests/ast_test.t
deleted file mode 100644
index 3a71fdb44..000000000
--- a/EIshbaev/tests/ast_test.t
+++ /dev/null
@@ -1,17 +0,0 @@
- $ ../bin/main.exe
- [(ExprLet (Rec,
- [((PatVar "fact"),
- (ExprFunc ("x",
- (ExprCond (
- (ExprBinop (Lesq, (ExprVar "x"), (ExprConst (ConstInt 1)))),
- (ExprConst (ConstInt 1)),
- (ExprBinop (Mul, (ExprVar "x"),
- (ExprApp ((ExprVar "fact"),
- (ExprBinop (Sub, (ExprVar "x"), (ExprConst (ConstInt 1))))
- ))
- ))
- ))
- )))
- ],
- (ExprVar "n")))
- ]
diff --git a/EIshbaev/tests/dune b/EIshbaev/tests/dune
deleted file mode 100644
index 1c7c3c129..000000000
--- a/EIshbaev/tests/dune
+++ /dev/null
@@ -1,3 +0,0 @@
-(cram
- (applies_to ast_test)
- (deps ../bin/main.exe))
diff --git a/ELutsyuk/.envrc b/ELutsyuk/.envrc
deleted file mode 100644
index 686a37170..000000000
--- a/ELutsyuk/.envrc
+++ /dev/null
@@ -1,2 +0,0 @@
-export OPAMSWITCH=4.14.2+flambda
-eval $(opam env)
diff --git a/ELutsyuk/.gitignore b/ELutsyuk/.gitignore
deleted file mode 100644
index 7102a822c..000000000
--- a/ELutsyuk/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-_build
-_coverage
-/_esy
-/node_modules
-/esy.lock
-/.melange.eobjs
diff --git a/ELutsyuk/.ocamlformat b/ELutsyuk/.ocamlformat
deleted file mode 100644
index 97f970802..000000000
--- a/ELutsyuk/.ocamlformat
+++ /dev/null
@@ -1,2 +0,0 @@
-profile=janestreet
-version=0.26.2
diff --git a/ELutsyuk/.zanuda b/ELutsyuk/.zanuda
deleted file mode 100644
index be4445a2b..000000000
--- a/ELutsyuk/.zanuda
+++ /dev/null
@@ -1 +0,0 @@
-forward mutability_check ignore print_ast.ml
diff --git a/ELutsyuk/ELutsyuk.opam b/ELutsyuk/ELutsyuk.opam
deleted file mode 100644
index 2786b53fc..000000000
--- a/ELutsyuk/ELutsyuk.opam
+++ /dev/null
@@ -1,36 +0,0 @@
-# This file is generated by dune, edit dune-project instead
-opam-version: "2.0"
-version: "0.1"
-synopsis: "An interpreter for miniML"
-description: "An interpreter for a subset of the ML language (WIP)"
-maintainer: ["Victoria Lutsyuk "]
-authors: ["Victoria Lutsyuk "]
-license: "MIT"
-homepage: "https://github.com/vicitori/miniML-interpreter"
-doc: "https://kakadu.github.io/fp2024/docs/ELutsyuk"
-bug-reports: "https://github.com/vicitori/miniML-interpreter"
-depends: [
- "dune" {>= "3.7"}
- "angstrom"
- "ppx_inline_test" {with-test}
- "ppx_expect"
- "ppx_deriving"
- "bisect_ppx"
- "odoc" {with-doc}
- "ocamlformat" {build}
- "base"
-]
-build: [
- ["dune" "subst"] {dev}
- [
- "dune"
- "build"
- "-p"
- name
- "-j"
- jobs
- "@install"
- "@runtest" {with-test}
- "@doc" {with-doc}
- ]
-]
diff --git a/ELutsyuk/LICENSE b/ELutsyuk/LICENSE
deleted file mode 100644
index 3a5c8e1ae..000000000
--- a/ELutsyuk/LICENSE
+++ /dev/null
@@ -1,22 +0,0 @@
-MIT License
-
-Copyright (c) 2024 Anastasia Migunova, Victoria Lutsyuk
-
-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:
-
-The above copyright notice and this permission notice 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.
diff --git a/ELutsyuk/Makefile b/ELutsyuk/Makefile
deleted file mode 100644
index 79fbb624c..000000000
--- a/ELutsyuk/Makefile
+++ /dev/null
@@ -1,49 +0,0 @@
-.PHONY: repl tests test fmt lint celan
-
-all:
- dune build
-
-repl:
- dune build ./REPL.exe && rlwrap _build/default/REPL.exe
-
-tests: test
-test:
- dune runtest
-
-celan: clean
-clean:
- @$(RM) -r _build _coverage
-
-fmt:
- dune build @fmt --auto-promote
-
-lint:
- dune build @lint --force
-
-release:
- dune build --profile=release
- dune runtest --profile=release
-
-install:
- dune b @install --profile=release
- dune install
-
-ODIG_SWITCHES = --odoc-theme=odig.gruvbox.light
-ODIG_SWITCHES += --no-tag-index
-ODIG_SWITCHES += --no-pkg-deps
-odig:
- odig odoc $(ODIG_SWITCHES) Lambda
-
-TEST_COV_D = /tmp/cov
-COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect tests/
-
-.PHONY: test_coverage coverage
-test_coverage: coverage
-coverage:
- $(RM) -r $(TEST_COV_D)
- mkdir -p $(TEST_COV_D)
- BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \
- --instrument-with bisect_ppx --force
- bisect-ppx-report html $(COVERAGE_OPTS)
- bisect-ppx-report summary $(COVERAGE_OPTS)
- @echo "Use 'xdg-open _coverage/index.html' to see coverage report"
diff --git a/ELutsyuk/bin/dune b/ELutsyuk/bin/dune
deleted file mode 100644
index a94d15ea4..000000000
--- a/ELutsyuk/bin/dune
+++ /dev/null
@@ -1,10 +0,0 @@
-(executable
- (name main)
- (public_name main)
- (libraries
- ELutsyuk.MiniML_Forest
- ELutsyuk.MiniML_Parser
- ELutsyuk.MiniML_Inferencer
- ELutsyuk.MiniML_Interpreter)
- (instrumentation
- (backend bisect_ppx)))
diff --git a/ELutsyuk/bin/main.ml b/ELutsyuk/bin/main.ml
deleted file mode 100644
index 2a6773355..000000000
--- a/ELutsyuk/bin/main.ml
+++ /dev/null
@@ -1,94 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Forest
-open Parser
-open Inferencer.InfAuxilary
-open Inferencer.Inference
-open Interpreter.Interpret
-open Stdlib.Format
-
-let run_infer input =
- match parse input with
- | Ok program ->
- (match inference program with
- | Ok (_, env) ->
- (* Getting the environment without builtin *)
- let remove_builtins env =
- let env = TypeEnv.remove env "print_int" in
- TypeEnv.remove env "print_endline"
- in
- Base.Map.iteri (remove_builtins env) ~f:(fun ~key ~data:(Scheme (_, ty)) ->
- printf "val %s: %a\n" key TypesTree.pp_typ ty)
- | Error err -> printf "Inferencing error: %a.\n" TypesTree.pp_error err)
- | Error err -> printf "Parsing error: %s.\n" err
-;;
-
-let run_eval input =
- match parse input with
- | Ok program ->
- (match Interpreter.IntAuxilary.Res.run (interpret program) with
- | Ok _ -> ()
- | Error err -> printf "Interpretation error: %a.\n" ValuesTree.pp_error err)
- | Error err -> printf "Parsing error: %s.\n" err
-;;
-
-let get_input filename =
- let channel = open_in filename in
- let input = really_input_string channel (in_channel_length channel) in
- close_in channel;
- input
-;;
-
-type config =
- { is_infer : bool
- ; is_eval : bool
- ; file : string option
- ; input : string option
- }
-
-let parse_args () =
- let rec prs_args args flags =
- match args with
- | [] -> flags
- | "-infer" :: rest -> prs_args rest { flags with is_infer = true }
- | "-eval" :: rest -> prs_args rest { flags with is_eval = true }
- | "-file" :: filename :: rest -> prs_args rest { flags with file = Some filename }
- | arg :: rest -> prs_args rest { flags with input = Some arg }
- in
- let default_flags = { is_infer = false; is_eval = false; file = None; input = None } in
- let args =
- match Array.to_list Sys.argv with
- | _ :: list -> list
- | _ -> []
- in
- prs_args args default_flags
-;;
-
-let main () =
- let config = parse_args () in
- let input =
- match config.file with
- | Some filename -> get_input filename
- | None ->
- (match config.input with
- | Some s -> s
- | None -> "")
- in
- if config.is_infer
- then run_infer input
- else if config.is_eval
- then run_eval input
- else if config.is_infer && config.is_eval
- then (
- let _ = run_infer input in
- let _ = run_eval input in
- ())
- else
- printf
- "Error: Could not parse arguments: Please restart program and put -infer or -eval \
- flag.\n"
-;;
-
-let () = main ()
diff --git a/ELutsyuk/dune b/ELutsyuk/dune
deleted file mode 100644
index 2b55f5424..000000000
--- a/ELutsyuk/dune
+++ /dev/null
@@ -1,16 +0,0 @@
-(env
- (dev
- (flags
- (:standard -alert @deprecated -warn-error -A -w +A-4-40-42-44-70)))
- (release
- (flags
- (:standard -alert @deprecated -warn-error +A -w +A-4-40-42-44-70))))
-
-; (executable
-; (name REPL)
-; (public_name REPL)
-; (modules REPL)
-; (libraries lambda_lib stdio))
-
-; (cram
-; (deps ./REPL.exe %{bin:REPL}))
diff --git a/ELutsyuk/dune-project b/ELutsyuk/dune-project
deleted file mode 100644
index 765beff2e..000000000
--- a/ELutsyuk/dune-project
+++ /dev/null
@@ -1,32 +0,0 @@
-(lang dune 3.7)
-
-(generate_opam_files true)
-
-(cram enable)
-
-(license MIT)
-
-(authors "Victoria Lutsyuk ")
-
-(maintainers "Victoria Lutsyuk ")
-
-(bug_reports "https://github.com/vicitori/miniML-interpreter")
-
-(homepage "https://github.com/vicitori/miniML-interpreter")
-
-(package
- (name ELutsyuk)
- (synopsis "An interpreter for miniML")
- (description "An interpreter for a subset of the ML language (WIP)")
- (documentation "https://kakadu.github.io/fp2024/docs/ELutsyuk")
- (version 0.1)
- (depends
- dune
- angstrom
- (ppx_inline_test :with-test)
- ppx_expect
- ppx_deriving
- bisect_ppx
- (odoc :with-doc)
- (ocamlformat :build)
- base))
diff --git a/ELutsyuk/lib/forest/Ast.ml b/ELutsyuk/lib/forest/Ast.ml
deleted file mode 100644
index 2341f6095..000000000
--- a/ELutsyuk/lib/forest/Ast.ml
+++ /dev/null
@@ -1,98 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open TypesTree
-
-(** Expression identifier *)
-type id = string [@@deriving show { with_path = false }]
-
-(** Represents constant values. *)
-type const =
- | Int of int (** Integer constants, e.g. [-1], [ 2], [0]. *)
- | Str of string (** String constants, e.g. [{|meow|}], ["miniML"]. *)
- | Bool of bool (** Boolean constants, e.g. [true], [false]. *)
- | Unit (** [()] *)
-[@@deriving show { with_path = false }]
-
-(** Represents binary operators, such as arithmetic or logical operations. *)
-type binop =
- | Mul (** Multiplication, e.g. [a * b]. *)
- | Div (** Division, e.g. [a / b]. *)
- | Add (** Addition, e.g. [a + b]. *)
- | Sub (** Subtraction, e.g. [a - b]. *)
- | Eq (** Equality comparison, e.g. [a = b]. *)
- | Ne (** Inequality comparison, e.g. [a <> b]. *)
- | Lt (** Less-than comparison, e.g. [a < b]. *)
- | Le (** Less-than-or-equal comparison, e.g. [a <= b]. *)
- | Gt (** Greater-than comparison, e.g. [a > b]. *)
- | Ge (** Greater-than-or-equal comparison, e.g. [a >= b]. *)
- | And (** Logical AND, e.g. [a && b]. *)
- | Or (** Logical OR, e.g. [a || b]. *)
-[@@deriving show { with_path = false }]
-
-type unary =
- | Minus
- | Plus
- | Not
-[@@deriving show { with_path = false }]
-
-(** Represents patterns for matching values in expressions. *)
-type pat =
- | PatAny (** Matches any value without binding it, e.g. [_]. *)
- (* | PatUnit *)
- | PatConst of const (** Matches a constant value, e.g. [42], [true]. *)
- | PatListCons of pat * pat (** Matches a cons pattern for lists, e.g. [x::y]. *)
- | PatVar of id (** Matches any value and binds it to a variable, e.g. [x]. *)
- | PatTup of pat * pat * pat list (** Matches tuples, e.g. [x, y], [a, b, c]. *)
- | PatList of pat list (** *)
- | PatType of pat * typ
-[@@deriving show { with_path = false }]
-
-(** Indicates whether a [let] binding is recursive or non-recursive. *)
-type rec_state =
- | Rec (** Recursive binding, e.g. [let rec fact = ...]. *)
- | NonRec (** Non-recursive binding, e.g. [let x = ...]. *)
-[@@deriving show { with_path = false }]
-
-(** Represents expressions in the language. *)
-type expr =
- | Var of id (** Variable reference, e.g. [x], [my_var]. *)
- | Const of const (** Constant value, e.g. [42], ["hello"], [true]. *)
- | Unary of unary * expr
- | BinOp of binop * expr * expr (** Binary operation, e.g. [x + y], [a >= b]. *)
- | Option of expr option (** Options, e.g. [Some("meow"), None]. *)
- | Let of rec_state * let_binding * let_binding list * expr
- (** [let] expression, e.g. [let x = 5 in e] *)
- | App of expr * expr (** Function application, e.g. [e1 e2], [(fun x -> x) 42]. *)
- | Fun of pat * pat list * expr (** Function definition, e.g. [fun p -> e]. *)
- | Branch of expr * expr * expr
- (** Conditional expression, e.g. [if e1 then e2 else e3]. *)
- | Tup of expr * expr * expr list (** Tuple expression, e.g. [(e1, e2)], [(x, y, z)]. *)
- | List of expr list (** List expression, e.g. [[]], [[e1; e2; e3]]. *)
- | Type of expr * typ
-[@@deriving show { with_path = false }]
-
-(** Represents a binding in a [let] expression. *)
-and let_binding =
- | Binding of pat * expr
- (** The pattern being bound, e.g. [x], [(a, b)]. The expression being assigned, e.g. [42], [fun x -> x + 1]. *)
-[@@deriving show { with_path = false }]
-
-(* Represents a single case in a [match] expression.
-and match_case =
- { match_pat : pat (** The pattern to match, e.g. [0], [_], [(x, y)]. *)
- ; match_expr : expr (** The expression to evaluate if the pattern matches. *)
- }
-[@@deriving show { with_path = false }] *)
-
-(** Represents a top-level item in a program. *)
-type structure_item =
- | Eval of expr
- (** An expression to be evaluated but not bound, e.g. [1 + 2], [print_endline "Hi"]. *)
- | Value of rec_state * let_binding * let_binding list
- (** A value or function binding, e.g. [let x = 5], [let rec fact n = ...]. *)
-[@@deriving show { with_path = false }]
-
-(** Represents an entire program as a list of top-level items. *)
-type program = structure_item list [@@deriving show { with_path = false }]
diff --git a/ELutsyuk/lib/forest/Ast.mli b/ELutsyuk/lib/forest/Ast.mli
deleted file mode 100644
index 856a464de..000000000
--- a/ELutsyuk/lib/forest/Ast.mli
+++ /dev/null
@@ -1,98 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open TypesTree
-
-(** Expression identifier *)
-type id = string [@@deriving show { with_path = false }]
-
-(** Represents constant values. *)
-type const =
- | Int of int (** Integer constants, e.g. [-1], [ 2], [0]. *)
- | Str of string (** String constants, e.g. [{|meow|}], ["miniML"]. *)
- | Bool of bool (** Boolean constants, e.g. [true], [false]. *)
- | Unit (** [()] *)
-[@@deriving show { with_path = false }]
-
-(** Represents binary operators, such as arithmetic or logical operations. *)
-type binop =
- | Mul (** Multiplication, e.g. [a * b]. *)
- | Div (** Division, e.g. [a / b]. *)
- | Add (** Addition, e.g. [a + b]. *)
- | Sub (** Subtraction, e.g. [a - b]. *)
- | Eq (** Equality comparison, e.g. [a = b]. *)
- | Ne (** Inequality comparison, e.g. [a <> b]. *)
- | Lt (** Less-than comparison, e.g. [a < b]. *)
- | Le (** Less-than-or-equal comparison, e.g. [a <= b]. *)
- | Gt (** Greater-than comparison, e.g. [a > b]. *)
- | Ge (** Greater-than-or-equal comparison, e.g. [a >= b]. *)
- | And (** Logical AND, e.g. [a && b]. *)
- | Or (** Logical OR, e.g. [a || b]. *)
-[@@deriving show { with_path = false }]
-
-(** Represents patterns for matching values in expressions. *)
-type pat =
- | PatAny (** Matches any value without binding it, e.g. [_]. *)
- (* | PatUnit *)
- | PatConst of const (** Matches a constant value, e.g. [42], [true]. *)
- | PatListCons of pat * pat (** Matches a cons pattern for lists, e.g. [x::y]. *)
- | PatVar of id (** Matches any value and binds it to a variable, e.g. [x]. *)
- | PatTup of pat * pat * pat list (** Matches tuples, e.g. [x, y], [a, b, c]. *)
- | PatList of pat list (** *)
- | PatType of pat * typ
-[@@deriving show { with_path = false }]
-
-type unary =
- | Minus
- | Plus
- | Not
-[@@deriving show { with_path = false }]
-
-(** Indicates whether a [let] binding is recursive or non-recursive. *)
-type rec_state =
- | Rec (** Recursive binding, e.g. [let rec fact = ...]. *)
- | NonRec (** Non-recursive binding, e.g. [let x = ...]. *)
-[@@deriving show { with_path = false }]
-
-(** Represents expressions in the language. *)
-type expr =
- | Var of id (** Variable reference, e.g. [x], [my_var]. *)
- | Const of const (** Constant value, e.g. [42], ["hello"], [true]. *)
- | Unary of unary * expr
- | BinOp of binop * expr * expr (** Binary operation, e.g. [x + y], [a >= b]. *)
- | Option of expr option (** Options, e.g. [Some("meow"), None]. *)
- | Let of rec_state * let_binding * let_binding list * expr
- (** [let] expression, e.g. [let x = 5 in e] *)
- | App of expr * expr (** Function application, e.g. [e1 e2], [(fun x -> x) 42]. *)
- | Fun of pat * pat list * expr (** Function definition, e.g. [fun p -> e]. *)
- | Branch of expr * expr * expr
- (** Conditional expression, e.g. [if e1 then e2 else e3]. *)
- | Tup of expr * expr * expr list (** Tuple expression, e.g. [(e1, e2)], [(x, y, z)]. *)
- | List of expr list (** List expression, e.g. [[]], [[e1; e2; e3]]. *)
- | Type of expr * typ
-[@@deriving show { with_path = false }]
-
-(** Represents a binding in a [let] expression. *)
-and let_binding =
- | Binding of pat * expr
- (** The pattern being bound, e.g. [x], [(a, b)]. The expression being assigned, e.g. [42], [fun x -> x + 1]. *)
-[@@deriving show { with_path = false }]
-
-(* Represents a single case in a [match] expression.
-and match_case =
- { match_pat : pat (** The pattern to match, e.g. [0], [_], [(x, y)]. *)
- ; match_expr : expr (** The expression to evaluate if the pattern matches. *)
- }
-[@@deriving show { with_path = false }] *)
-
-(** Represents a top-level item in a program. *)
-type structure_item =
- | Eval of expr
- (** An expression to be evaluated but not bound, e.g. [1 + 2], [print_endline "Hi"]. *)
- | Value of rec_state * let_binding * let_binding list
- (** A value or function binding, e.g. [let x = 5], [let rec fact n = ...]. *)
-[@@deriving show { with_path = false }]
-
-(** Represents an entire program as a list of top-level items. *)
-type program = structure_item list [@@deriving show { with_path = false }]
diff --git a/ELutsyuk/lib/forest/TypesTree.ml b/ELutsyuk/lib/forest/TypesTree.ml
deleted file mode 100644
index c78af169e..000000000
--- a/ELutsyuk/lib/forest/TypesTree.ml
+++ /dev/null
@@ -1,93 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Stdlib.Format
-
-type var = int [@@deriving show { with_path = false }]
-
-type constant =
- | TInt
- | TStr
- | TBool
- | TUnit
-[@@deriving show { with_path = false }]
-
-type typ =
- | TypConst of constant
- | TypVar of var
- | TypArrow of typ * typ
- | TypTuple of typ list
- | TypList of typ
- | TypOption of typ
-
-type error =
- | OccursCheckFailed of int * typ
- | UnificationFailed of typ * typ
- | UnboundVariable of string
- | InvalidRecursivePattern
- | UnexpectedFuncType of typ
- | IllegalLHS
- | IllegalRHS
-
-(* Type constructors *)
-let int_typ = TypConst TInt
-let bool_typ = TypConst TBool
-let string_typ = TypConst TStr
-let unit_typ = TypConst TUnit
-let constant_typ ty = TypConst ty
-let var_typ name = TypVar name
-let arrow_typ ty1 ty2 = TypArrow (ty1, ty2)
-let tup_typ ty = TypTuple ty
-let list_typ ty = TypList ty
-let option_typ ty = TypOption ty
-
-let rec pp_typ ppf = function
- | TypConst TInt -> fprintf ppf "int"
- | TypConst TBool -> fprintf ppf "bool"
- | TypConst TStr -> fprintf ppf "string"
- | TypConst TUnit -> fprintf ppf "unit"
- | TypVar ty -> fprintf ppf "'%d" ty
- | TypArrow (ty1, ty2) ->
- (match ty1 with
- | TypArrow _ -> fprintf ppf "(%a) -> %a" pp_typ ty1 pp_typ ty2
- | _ -> fprintf ppf "%a -> %a" pp_typ ty1 pp_typ ty2)
- | TypList ty -> fprintf ppf "%a list" pp_typ ty
- | TypTuple ty ->
- fprintf ppf "(%a)" (pp_print_list ~pp_sep:(fun fmt () -> fprintf fmt " * ") pp_typ) ty
- | TypOption ty -> fprintf ppf "%a option" pp_typ ty
-;;
-
-let pp_error ppf = function
- | OccursCheckFailed (id, ty) ->
- fprintf
- ppf
- "occurs check failed: variable '%d' cannot appear in its own type %a"
- id
- pp_typ
- ty
- | UnificationFailed (t1, t2) ->
- fprintf
- ppf
- "type unification failed: cannot unify types %a and %a"
- pp_typ
- t1
- pp_typ
- t2
- | UnboundVariable name ->
- fprintf ppf "unbound variable: '%s' is not defined in the current scope" name
- | InvalidRecursivePattern ->
- fprintf ppf "invalid recursive pattern: recursive patterns can only be variables"
- | UnexpectedFuncType ty ->
- fprintf ppf "unexpected function type: expected a function type but got %a" pp_typ ty
- | IllegalLHS ->
- fprintf
- ppf
- "illegal left-hand side: only variables can appear on the left-hand side of a \
- 'let' binding"
- | IllegalRHS ->
- fprintf
- ppf
- "illegal right-hand side: the right-hand side of a 'let' binding must be an \
- expression, not a pattern"
-;;
diff --git a/ELutsyuk/lib/forest/TypesTree.mli b/ELutsyuk/lib/forest/TypesTree.mli
deleted file mode 100644
index f046b8cda..000000000
--- a/ELutsyuk/lib/forest/TypesTree.mli
+++ /dev/null
@@ -1,42 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-type var = int [@@deriving show { with_path = false }]
-
-type constant =
- | TInt
- | TStr
- | TBool
- | TUnit
-[@@deriving show { with_path = false }]
-
-type typ =
- | TypConst of constant
- | TypVar of var
- | TypArrow of typ * typ
- | TypTuple of typ list
- | TypList of typ
- | TypOption of typ
-
-type error =
- | OccursCheckFailed of int * typ
- | UnificationFailed of typ * typ
- | UnboundVariable of string
- | InvalidRecursivePattern
- | UnexpectedFuncType of typ
- | IllegalLHS
- | IllegalRHS
-
-val int_typ : typ
-val bool_typ : typ
-val string_typ : typ
-val unit_typ : typ
-val constant_typ : constant -> typ
-val var_typ : var -> typ
-val arrow_typ : typ -> typ -> typ
-val tup_typ : typ list -> typ
-val list_typ : typ -> typ
-val option_typ : typ -> typ
-val pp_typ : Format.formatter -> typ -> unit
-val pp_error : Format.formatter -> error -> unit
diff --git a/ELutsyuk/lib/forest/ValuesTree.ml b/ELutsyuk/lib/forest/ValuesTree.ml
deleted file mode 100644
index 54e703c36..000000000
--- a/ELutsyuk/lib/forest/ValuesTree.ml
+++ /dev/null
@@ -1,66 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Base
-open Stdlib.Format
-open Ast
-
-type value =
- | ValInt of int
- | ValStr of string
- | ValBool of bool
- | ValUnit
- | ValList of value list
- | ValTup of value * value * value list
- | ValFun of rec_state * pat * pat list * expr * env
- | ValBuiltIn of string
- | ValOption of value option
-
-and env = (id, value, String.comparator_witness) Map.t
-
-type error =
- | NoVariable of string
- | TypeError
- | PatternMatchingFail
-
-let rec pp_value ppf = function
- | ValInt v -> fprintf ppf "%i" v
- | ValBool v -> fprintf ppf "'%b'" v
- | ValStr v -> fprintf ppf "%S" v
- | ValUnit -> fprintf ppf "()"
- | ValList v ->
- fprintf ppf "[%a]" (pp_print_list ~pp_sep:(fun ppf () -> fprintf ppf "; ") pp_value) v
- | ValTup (v1, v2, vs) ->
- fprintf
- ppf
- "(%a, %a%a)"
- pp_value
- v1
- pp_value
- v2
- (fun ppf -> function
- | [] -> ()
- | rest ->
- fprintf
- ppf
- ", %a"
- (pp_print_list ~pp_sep:(fun ppf () -> fprintf ppf ", ") pp_value)
- rest)
- vs
- | ValFun _ | ValBuiltIn _ -> fprintf ppf ""
- | ValOption v ->
- (match v with
- | Some v -> fprintf ppf "Some %a" pp_value v
- | None -> fprintf ppf "None")
-;;
-
-let pp_error ppf = function
- | NoVariable str -> fprintf ppf "Variable '%S' is not defined in the current scope" str
- | TypeError ->
- fprintf ppf "type error: the types do not match or an invalid type was encountered"
- | PatternMatchingFail ->
- fprintf
- ppf
- "pattern matching failed: no matching pattern was found for the given input"
-;;
diff --git a/ELutsyuk/lib/forest/ValuesTree.mli b/ELutsyuk/lib/forest/ValuesTree.mli
deleted file mode 100644
index 73a528c23..000000000
--- a/ELutsyuk/lib/forest/ValuesTree.mli
+++ /dev/null
@@ -1,28 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Base
-open Stdlib.Format
-open Ast
-
-type value =
- | ValInt of int
- | ValStr of string
- | ValBool of bool
- | ValUnit
- | ValList of value list
- | ValTup of value * value * value list
- | ValFun of rec_state * pat * pat list * expr * env
- | ValBuiltIn of string
- | ValOption of value option
-
-and env = (id, value, String.comparator_witness) Map.t
-
-type error =
- | NoVariable of string
- | TypeError
- | PatternMatchingFail
-
-val pp_value : formatter -> value -> unit
-val pp_error : formatter -> error -> unit
diff --git a/ELutsyuk/lib/forest/dune b/ELutsyuk/lib/forest/dune
deleted file mode 100644
index db3f8929b..000000000
--- a/ELutsyuk/lib/forest/dune
+++ /dev/null
@@ -1,10 +0,0 @@
-(include_subdirs qualified)
-
-(library
- (name forest)
- (public_name ELutsyuk.MiniML_Forest)
- (libraries base angstrom)
- (preprocess
- (pps ppx_deriving.show))
- (instrumentation
- (backend bisect_ppx)))
diff --git a/ELutsyuk/lib/inferencer/Inference.ml b/ELutsyuk/lib/inferencer/Inference.ml
deleted file mode 100644
index 448c1899d..000000000
--- a/ELutsyuk/lib/inferencer/Inference.ml
+++ /dev/null
@@ -1,375 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Forest.Ast
-open Forest.TypesTree
-open InfAuxilary
-open InfAuxilary.FreshResult
-
-let fresh_var =
- let* fresh = fresh in
- return @@ var_typ fresh
-;;
-
-(* Makes type scheme copy. *)
-let instantiate (Scheme (vars, ty)) =
- VarSet.fold
- (fun old_var ty ->
- let* ty = ty in
- let* fresh_var = fresh_var in
- let* sub = Subst.singleton old_var fresh_var in
- return @@ Subst.apply sub ty)
- vars
- (return ty)
-;;
-
-(* Generalizes a type by quantifying over its free variables that are not bound in the environment. *)
-let generalize env typ =
- let vars = VarSet.diff (Type.type_vars typ) (TypeEnv.free env) in
- Scheme (vars, typ)
-;;
-
-let inf_const = function
- | Int _ -> int_typ
- | Bool _ -> bool_typ
- | Str _ -> string_typ
- | Unit -> unit_typ
-;;
-
-let rec inf_pat env = function
- | PatAny ->
- let* ty_var = fresh_var in
- return (Subst.empty, env, ty_var)
- | PatConst pat -> return (Subst.empty, env, inf_const pat)
- | PatListCons (pat1, pat2) ->
- let* sub1, env1, ty1 = inf_pat env pat1 in
- let* _, env2, ty2 = inf_pat (TypeEnv.apply sub1 env1) pat2 in
- let* final_sub = Subst.unify (list_typ ty1) ty2 in
- let env = TypeEnv.apply final_sub env2 in
- return (final_sub, env, Subst.apply final_sub ty2)
- | PatVar name ->
- let* ty_var = fresh_var in
- let sch = Scheme (VarSet.empty, ty_var) in
- let env = TypeEnv.extend env name sch in
- return (Subst.empty, env, ty_var)
- | PatTup (pat1, pat2, pats) ->
- let pats = pat1 :: pat2 :: pats in
- let* sub, env, ty =
- List.fold_left
- (fun acc pat ->
- let* sub1, env, tys = acc in
- let* sub2, env_upd, ty1 = inf_pat env pat in
- let* final_sub = Subst.compose sub1 sub2 in
- return (final_sub, env_upd, ty1 :: tys))
- (return (Subst.empty, env, []))
- pats
- in
- return (sub, env, tup_typ ty)
- | PatList [] ->
- let* ty_var = fresh_var in
- return (Subst.empty, env, list_typ ty_var)
- | PatList pat ->
- let* fresh_typ = fresh_var in
- let* sub, env =
- List.fold_left
- (fun acc pat ->
- let* prev_sub, prev_env = acc in
- let* new_sub, curr_env, el_typ = inf_pat prev_env pat in
- let* unified_sub = Subst.compose prev_sub new_sub in
- let* final_sub = Subst.unify (Subst.apply prev_sub fresh_typ) el_typ in
- let* sub = Subst.compose unified_sub final_sub in
- return (sub, TypeEnv.apply final_sub curr_env))
- (return (Subst.empty, env))
- pat
- in
- return (sub, env, list_typ @@ Subst.apply sub fresh_typ)
- | PatType (pat, ty) ->
- let* sub, env, ty1 = inf_pat env pat in
- let ty = Subst.apply sub ty in
- let* sub = Subst.unify ty1 ty in
- return (sub, TypeEnv.apply sub env, Subst.apply sub ty)
-;;
-
-(* Returns operands type and result type *)
-let binop_signature = function
- | Eq | Ne | Lt | Le | Gt | Ge ->
- let* ty_var = fresh_var in
- return (ty_var, bool_typ)
- | Mul | Div | Add | Sub -> return (int_typ, int_typ)
- | And | Or -> return (bool_typ, bool_typ)
-;;
-
-(* Checks that the left-hand side of a 'let rec' is a variable. *)
-let check_rec_lhs pat =
- match pat with
- | PatVar _ -> return pat
- | _ -> fail @@ IllegalLHS
-;;
-
-(* Checks that the right-hand side of a 'let rec' is a function. *)
-let check_rec_rhs expr =
- match expr with
- | Fun _ -> return expr
- | _ -> fail @@ IllegalRHS
-;;
-
-let rec inf_expr env = function
- | Var name ->
- (match TypeEnv.find env name with
- | Some sch ->
- let* ty = instantiate sch in
- return (Subst.empty, ty)
- | None -> fail @@ UnboundVariable name)
- | Const exp -> return (Subst.empty, inf_const exp)
- | Unary (op, exp) ->
- let* sub1, exp_ty = inf_expr env exp in
- let* op_ty =
- match op with
- | Minus | Plus -> return int_typ
- | Not -> return bool_typ
- in
- let* sub2 = Subst.unify exp_ty op_ty in
- let* sub = Subst.compose_many_sub [ sub1; sub2 ] in
- return @@ (sub, Subst.apply sub op_ty)
- | BinOp (op, exp1, exp2) ->
- let* args_ty, res_ty = binop_signature op in
- let* sub1, ty1 = inf_expr env exp1 in
- let* sub2, ty2 = inf_expr (TypeEnv.apply sub1 env) exp2 in
- let* sub3 = Subst.unify (Subst.apply sub2 ty1) args_ty in
- let* sub4 = Subst.unify (Subst.apply sub3 ty2) args_ty in
- let* final_sub = Subst.compose_many_sub [ sub1; sub2; sub3; sub4 ] in
- return (final_sub, Subst.apply final_sub res_ty)
- | Option (Some exp) ->
- let* sub, ty = inf_expr env exp in
- return (sub, option_typ ty)
- | Option None ->
- let* ty_var = fresh_var in
- return (Subst.empty, option_typ ty_var)
- | List exp ->
- (match exp with
- | [] ->
- let* ty_var = fresh_var in
- return (Subst.empty, list_typ ty_var)
- | _ :: _ ->
- let* s, tys =
- List.fold_left
- (fun acc e ->
- let* acc_sub, acc_ty = acc in
- let* inf_sub, inf_ty = inf_expr (TypeEnv.apply acc_sub env) e in
- let* composed_sub = Subst.compose inf_sub acc_sub in
- return (composed_sub, inf_ty :: acc_ty))
- (return (Subst.empty, []))
- exp
- in
- return (s, list_typ (List.hd tys)))
- | Let (NonRec, Binding (PatVar x, exp1), _, exp2) ->
- let* sub1, ty1 = inf_expr env exp1 in
- let ty_copy = generalize (TypeEnv.apply sub1 env) ty1 in
- let env3 = TypeEnv.extend env x ty_copy in
- let* sub2, ty2 = inf_expr (TypeEnv.apply sub1 env3) exp2 in
- let* final_sub = Subst.compose sub1 sub2 in
- return (final_sub, ty2)
- | Let (NonRec, Binding (pat, exp1), bindings, exp2) ->
- let* s1, t1 = inf_expr env exp1 in
- let* s2, env1, ty_pat = inf_pat env pat in
- let* sub1 = Subst.compose s1 s2 in
- let* unified_sub = Subst.unify (Subst.apply sub1 ty_pat) t1 in
- let initial_env = TypeEnv.apply unified_sub env1 in
- let* extended_env =
- List.fold_left
- (fun acc_env (Binding (pat, expr)) ->
- let* acc_env = acc_env in
- let* sub_bind, ty_bind = inf_expr acc_env expr in
- let* sub_pat, env_pat, ty_pat = inf_pat acc_env pat in
- let* combined_subst = Subst.compose sub_bind sub_pat in
- let* final_subst = Subst.unify (Subst.apply combined_subst ty_pat) ty_bind in
- let updated_env = TypeEnv.merge_envs final_subst acc_env env_pat in
- return updated_env)
- (return initial_env)
- bindings
- in
- let* sub3, ty2 = inf_expr extended_env exp2 in
- let* full_subst = Subst.compose_many_sub [ sub3; unified_sub; sub1 ] in
- return (full_subst, ty2)
- | Let (Rec, Binding (PatVar x, exp1), [], exp2) ->
- let* exp1 = check_rec_rhs exp1 in
- let* var_ty = fresh_var in
- let env2 = TypeEnv.extend env x (Scheme (VarSet.empty, var_ty)) in
- let* s1, t1 = inf_expr env2 exp1 in
- let* s2 = Subst.unify (Subst.apply s1 var_ty) t1 in
- let* sub_final = Subst.compose s1 s2 in
- let env3 = TypeEnv.apply sub_final env in
- let env4 = TypeEnv.apply s1 env3 in
- let ty_gen = generalize env4 (Subst.apply sub_final var_ty) in
- let* s3, t2 = inf_expr (TypeEnv.extend env4 x ty_gen) exp2 in
- let* s_final = Subst.compose sub_final s3 in
- return (s_final, t2)
- | Let (Rec, binding, bindings, exp2) ->
- let* env_ext, sub_acc =
- List.fold_left
- (fun acc_env (Binding (pat, expr)) ->
- let* expr = check_rec_rhs expr in
- let* pattern = check_rec_lhs pat in
- let* env_acc, _ = acc_env in
- let* s_expr, ty_expr = inf_expr env_acc expr in
- let* s_pat, env_pat, ty_pat = inf_pat env_acc pattern in
- let* subst = Subst.compose s_expr s_pat in
- let* unified_sub = Subst.unify ty_expr ty_pat in
- let* combined_sub = Subst.compose subst unified_sub in
- let extended_env = TypeEnv.apply combined_sub env_pat in
- return (extended_env, combined_sub))
- (return (env, Subst.empty))
- (binding :: bindings)
- in
- let* sub2, t2 = inf_expr env_ext exp2 in
- let* final_subst = Subst.compose sub_acc sub2 in
- return (final_subst, t2)
- | App (fun_exp, arg_exp) ->
- let* sub1, fun_ty = inf_expr env fun_exp in
- let* sub2, arg_ty = inf_expr (TypeEnv.apply sub1 env) arg_exp in
- let* res_typ = fresh_var in
- let ty1 = Subst.apply sub2 fun_ty in
- let ty2 = arrow_typ arg_ty res_typ in
- let* sub3 = Subst.unify ty1 ty2 in
- let* sub = Subst.compose_many_sub [ sub1; sub2; sub3 ] in
- let ty = Subst.apply sub res_typ in
- return (sub, ty)
- | Fun (pat, pats, exp) ->
- let* env, tys =
- List.fold_left
- (fun acc pat ->
- let* env, pat_types = acc in
- let* _, env, typ = inf_pat env pat in
- return (env, typ :: pat_types))
- (return (env, []))
- (pat :: pats)
- in
- let* sub, ty = inf_expr env exp in
- let arrow_type =
- List.fold_right
- (fun pat_type acc -> TypArrow (Subst.apply sub pat_type, acc))
- (List.rev tys)
- ty
- in
- return (sub, arrow_type)
- | Branch (cond, br1, br2) ->
- let* sub1, ty1 = inf_expr env cond in
- let* sub2, ty2 = inf_expr (TypeEnv.apply sub1 env) br1 in
- let* sub3, ty3 = inf_expr (TypeEnv.apply sub2 env) br2 in
- let* sub4 = Subst.unify ty1 bool_typ in
- let* sub5 = Subst.unify ty2 ty3 in
- let* final_sub = Subst.compose_many_sub [ sub1; sub2; sub3; sub4; sub5 ] in
- let ty = Subst.apply final_sub ty3 in
- return (final_sub, ty)
- | Tup (el1, el2, els) ->
- let* sub, ty =
- List.fold_left
- (fun acc expr ->
- let* sub, ty = acc in
- let* sub1, ty1 = inf_expr (TypeEnv.apply sub env) expr in
- let* sub2 = Subst.compose sub sub1 in
- return (sub2, ty1 :: ty))
- (return (Subst.empty, []))
- (el1 :: el2 :: els)
- in
- return (sub, tup_typ (List.rev_map (Subst.apply sub) ty))
- | Type (el, typ) ->
- let* sub1, typ1 = inf_expr env el in
- let* sub2 = Subst.unify typ1 (Subst.apply sub1 typ) in
- let* final_sub = Subst.compose sub1 sub2 in
- return (final_sub, Subst.apply sub2 typ1)
-;;
-
-let inf_struct_item env = function
- | Eval expr ->
- let* subst, _ = inf_expr env expr in
- let updated_env = TypeEnv.apply subst env in
- return (subst, updated_env)
- | Value (Rec, Binding (PatVar x, expr), []) ->
- let* expr = check_rec_rhs expr in
- let* tv = fresh_var in
- let env = TypeEnv.extend env x (Scheme (VarSet.empty, tv)) in
- let* subst, inferred_ty = inf_expr env expr in
- let* subst2 = Subst.unify (Subst.apply subst tv) inferred_ty in
- let* composed_subst = Subst.compose subst subst2 in
- let env2 = TypeEnv.apply composed_subst env in
- let generalized_ty = generalize env2 (Subst.apply composed_subst inferred_ty) in
- let env = TypeEnv.extend env2 x generalized_ty in
- return (composed_subst, env)
- | Value (Rec, binding, bindings) ->
- let all_bindings = binding :: bindings in
- let* env_with_placeholders =
- List.fold_left
- (fun acc_env (Binding (pattern, _)) ->
- let* ty_pattern = check_rec_lhs pattern in
- let* env_acc = acc_env in
- let* s_pat, env_pat, _ = inf_pat env_acc ty_pattern in
- let extended_env = TypeEnv.apply s_pat env_pat in
- return extended_env)
- (return env)
- all_bindings
- in
- let* env_ext, s_acc =
- List.fold_left
- (fun acc_env (Binding (ty_pattern, expr)) ->
- let* expr = check_rec_rhs expr in
- let* env_acc, _ = acc_env in
- let* s_expr, t_expr = inf_expr env_acc expr in
- let* s_pat, env_pat, t_pat = inf_pat env_acc ty_pattern in
- let* subst = Subst.compose s_expr s_pat in
- let* unified_subst = Subst.unify t_expr t_pat in
- let* combined_subst = Subst.compose subst unified_subst in
- let extended_env = TypeEnv.apply combined_subst env_pat in
- return (extended_env, combined_subst))
- (return (env_with_placeholders, Subst.empty))
- all_bindings
- in
- return (s_acc, env_ext)
- | Value (NonRec, Binding (PatVar x, expr), _) ->
- let* subst, inferred_ty = inf_expr env expr in
- let env2 = TypeEnv.apply subst env in
- let generalized_ty = generalize env2 inferred_ty in
- let env = TypeEnv.extend (TypeEnv.apply subst env) x generalized_ty in
- return (subst, env)
- | Value (NonRec, Binding (pattern, expr), _) ->
- let* subst_expr, inferred_ty = inf_expr env expr in
- let* subst_pat, env_pat, t_pat = inf_pat env pattern in
- let* combined_subst =
- let* composed = Subst.compose subst_expr subst_pat in
- return composed
- in
- let* unified_subst = Subst.unify (Subst.apply combined_subst t_pat) inferred_ty in
- let updated_env = TypeEnv.apply unified_subst env_pat in
- let* final_subst = Subst.compose unified_subst combined_subst in
- return (final_subst, updated_env)
-;;
-
-let inf_program env structure =
- let rec process_structure env subst = function
- | [] -> return (subst, env)
- | item :: rest ->
- let* subst', env' = inf_struct_item env item in
- let* composed_subst = Subst.compose subst subst' in
- process_structure env' composed_subst rest
- in
- process_structure env Subst.empty structure
-;;
-
-let start_env =
- let print_env =
- TypeEnv.extend
- TypeEnv.empty
- "print_int"
- (Scheme (VarSet.empty, arrow_typ int_typ unit_typ))
- in
- let env =
- TypeEnv.extend
- print_env
- "print_endline"
- (Scheme (VarSet.empty, arrow_typ string_typ unit_typ))
- in
- env
-;;
-
-let inference tree = run (inf_program start_env tree)
diff --git a/ELutsyuk/lib/inferencer/Inference.mli b/ELutsyuk/lib/inferencer/Inference.mli
deleted file mode 100644
index 4b06fd259..000000000
--- a/ELutsyuk/lib/inferencer/Inference.mli
+++ /dev/null
@@ -1,9 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Forest.Ast
-open Forest.TypesTree
-open InfAuxilary
-
-val inference : structure_item list -> (Subst.t * TypeEnv.t, error) result
diff --git a/ELutsyuk/lib/inferencer/dune b/ELutsyuk/lib/inferencer/dune
deleted file mode 100644
index c97154547..000000000
--- a/ELutsyuk/lib/inferencer/dune
+++ /dev/null
@@ -1,10 +0,0 @@
-(include_subdirs qualified)
-
-(library
- (name inferencer)
- (public_name ELutsyuk.MiniML_Inferencer)
- (libraries base angstrom forest)
- (preprocess
- (pps ppx_deriving.show))
- (instrumentation
- (backend bisect_ppx)))
diff --git a/ELutsyuk/lib/inferencer/infAuxilary.ml b/ELutsyuk/lib/inferencer/infAuxilary.ml
deleted file mode 100644
index afab54207..000000000
--- a/ELutsyuk/lib/inferencer/infAuxilary.ml
+++ /dev/null
@@ -1,215 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Base
-open Forest.Ast
-open Forest.TypesTree
-
-module FreshResult : sig
- type 'a t
-
- val return : 'a -> 'a t
- val fail : error -> 'a t
- val ( >>= ) : 'a t -> ('a -> 'b t) -> 'b t
- val fresh : int t
- val run : 'a t -> ('a, error) Result.t
- val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t
-end = struct
- type 'a t = int -> int * ('a, error) Result.t
-
- let ( >>= ) monad bind_func state =
- match monad state with
- | state, Result.Error err -> state, Error err
- | state, Result.Ok value -> bind_func value state
- ;;
-
- let return res state = state, Result.return res
- let fail res state = state, Result.fail res
-
- (* let bind value f = value >>= f *)
- let fresh state = return state (state + 1)
- let run monad = snd (monad 0)
- let ( let* ) = ( >>= )
-end
-
-module VarSet = struct
- include Stdlib.Set.Make (Int)
-end
-
-module Type : sig
- val has_type_var : int -> typ -> bool
- val type_vars : typ -> VarSet.t
-end = struct
- (* Checks whether the given type contains a specific type variable. *)
- let rec has_type_var var = function
- | TypConst _ -> false
- | TypVar ty -> ty = var
- | TypArrow (ty1, ty2) -> has_type_var var ty1 || has_type_var var ty2
- | TypTuple ty -> List.exists ty ~f:(has_type_var var)
- | TypList ty -> has_type_var var ty
- | TypOption ty -> has_type_var var ty
- ;;
-
- (* Collects all free type variables occurring in the given type. *)
- let type_vars typ =
- let rec collect_vars acc = function
- | TypConst _ -> acc
- | TypVar var_name -> VarSet.add var_name acc
- | TypArrow (ty1, ty2) -> collect_vars (collect_vars acc ty1) ty2
- | TypTuple ty ->
- let free ty = collect_vars VarSet.empty ty in
- List.fold ty ~init:acc ~f:(fun acc ty -> VarSet.union acc (free ty))
- | TypList ty -> collect_vars acc ty
- | TypOption ty -> collect_vars acc ty
- in
- collect_vars VarSet.empty typ
- ;;
-end
-
-module Subst : sig
- type t
-
- val empty : t
- val singleton : var -> typ -> t FreshResult.t
- val find : t -> var -> typ option
- val remove : t -> var -> t
- val apply : t -> typ -> typ
- val unify : typ -> typ -> t FreshResult.t
- val compose_many_sub : t list -> t FreshResult.t
- val compose : t -> t -> t FreshResult.t
-end = struct
- open FreshResult
-
- type t = (var, typ, Int.comparator_witness) Map.t
-
- let empty : t = Map.empty (module Int)
-
- let singleton var typ =
- if Type.has_type_var var typ
- then fail (OccursCheckFailed (var, typ))
- else return (Map.singleton (module Int) var typ)
- ;;
-
- let find sub var = Map.find sub var
- let remove sub var = Map.remove sub var
-
- (* Applies a substitutions to a type, recursively replacing all matching type variables. *)
- let apply sub_map =
- let rec upd_typ = function
- | TypConst ty -> constant_typ ty
- | TypVar var_name ->
- (match find sub_map var_name with
- | Some ty -> ty
- | None -> var_typ var_name)
- | TypArrow (ty1, ty2) -> arrow_typ (upd_typ ty1) (upd_typ ty2)
- | TypTuple ty -> tup_typ (List.map ty ~f:upd_typ)
- | TypList ty -> list_typ (upd_typ ty)
- | TypOption ty -> option_typ (upd_typ ty)
- in
- upd_typ
- ;;
-
- (* Tries to unify two types, returning a substitution that makes them equal, or fails. *)
- let rec unify typ1 typ2 =
- match typ1, typ2 with
- | TypConst ty1, TypConst ty2 when Poly.(ty1 = ty2) -> return empty
- | TypVar a, TypVar b when a = b -> return empty
- | TypVar var, typ | typ, TypVar var -> singleton var typ
- | TypArrow (a1, a2), TypArrow (b1, b2) ->
- let* sub1 = unify a1 b1 in
- let* sub2 = unify a2 b2 in
- compose sub1 sub2
- | TypTuple ty1, TypTuple ty2 ->
- let rec unify_tup sub = function
- | [], [] -> return sub
- | t1 :: ts1, t2 :: ts2 ->
- if List.length ts1 <> List.length ts2
- then fail @@ UnificationFailed (typ1, typ2)
- else
- let* sub1 = unify (apply sub t1) (apply sub t2) in
- let* final_sub = compose sub sub1 in
- unify_tup final_sub (ts1, ts2)
- | _, _ -> fail @@ UnificationFailed (typ1, typ2)
- in
- unify_tup empty (ty1, ty2)
- | TypList a, TypList b -> unify a b
- | TypOption a, TypOption b -> unify a b
- | _ -> fail @@ UnificationFailed (typ1, typ2)
-
- (* Extends an existing substitution with a new variable binding, applying substitution recursively to maintain consistency. *)
- and extend sub_map new_var new_typ =
- match find sub_map new_var with
- | None ->
- let new_typ = apply sub_map new_typ in
- let* new_sub = singleton new_var new_typ in
- Map.fold sub_map ~init:(return new_sub) ~f:(fun ~key:new_var ~data:new_typ acc ->
- let* acc = acc in
- let new_typ = apply new_sub new_typ in
- return (Map.set acc ~key:new_var ~data:new_typ))
- | Some ty ->
- let* new_sub = unify new_typ ty in
- compose sub_map new_sub
-
- (* Composes two substitutions, applying the second to the first and merging them. *)
- and compose sub_map1 sub_map2 =
- Map.fold sub_map1 ~init:(return sub_map2) ~f:(fun ~key:var ~data:typ acc ->
- let* acc = acc in
- extend acc var typ)
- ;;
-
- (* Composition of several substitutions. *)
- let compose_many_sub sub_list =
- List.fold_left sub_list ~init:(return empty) ~f:(fun acc sub ->
- let* acc = acc in
- compose sub acc)
- ;;
-end
-
-type scheme = Scheme of VarSet.t * typ
-
-module Scheme = struct
- (* Returns the set of free type variables in a type scheme, excluding the bound ones. *)
- let free = function
- | Scheme (bind_vars, ty) -> VarSet.diff (Type.type_vars ty) bind_vars
- ;;
-
- (* Applies a substitution to a type scheme, skipping its bound variables. *)
- let apply sub (Scheme (bind_vars, ty)) =
- let subst = VarSet.fold (fun var sub -> Subst.remove sub var) bind_vars sub in
- Scheme (bind_vars, Subst.apply subst ty)
- ;;
-end
-
-module TypeEnv : sig
- type t = (id, scheme, String.comparator_witness) Map.t
-
- val empty : t
- val free : t -> VarSet.t
- val apply : Subst.t -> t -> t
- val extend : t -> id -> scheme -> t
- val find : t -> id -> scheme option
- val remove : t -> id -> t
- val merge_envs : Subst.t -> t -> t -> t
-end = struct
- type t = (id, scheme, String.comparator_witness) Map.t
-
- let empty = Map.empty (module String)
-
- (* Returns the set of free type variables in a type scheme, excluding the bound variables that are part of the environment. *)
- let free env =
- Map.fold env ~init:VarSet.empty ~f:(fun ~key:_ ~data:sch acc ->
- VarSet.union acc (Scheme.free sch))
- ;;
-
- let apply sub env = Map.map env ~f:(Scheme.apply sub)
- let extend env id scheme = Map.update env id ~f:(fun _ -> scheme)
- let find env id = Map.find env id
- let remove = Map.remove
-
- let merge_envs subst acc_env env_pat =
- let acc_env = apply subst acc_env in
- let env_pat = apply subst env_pat in
- Map.fold env_pat ~init:acc_env ~f:(fun ~key ~data acc_env -> extend acc_env key data)
- ;;
-end
diff --git a/ELutsyuk/lib/inferencer/infAuxilary.mli b/ELutsyuk/lib/inferencer/infAuxilary.mli
deleted file mode 100644
index a54882ae2..000000000
--- a/ELutsyuk/lib/inferencer/infAuxilary.mli
+++ /dev/null
@@ -1,58 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Forest.Ast
-open Forest.TypesTree
-
-module FreshResult : sig
- type 'a t
-
- val return : 'a -> 'a t
- val fail : error -> 'a t
- val ( >>= ) : 'a t -> ('a -> 'b t) -> 'b t
- val fresh : int t
- val run : 'a t -> ('a, error) Result.t
- val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t
-end
-
-module Subst : sig
- type t
-
- val empty : t
- val singleton : var -> typ -> t FreshResult.t
- val find : t -> var -> typ option
- val remove : t -> var -> t
- val apply : t -> typ -> typ
- val unify : typ -> typ -> t FreshResult.t
- val compose_many_sub : t list -> t FreshResult.t
- val compose : t -> t -> t FreshResult.t
-end
-
-module VarSet : sig
- type elt = int
- type t = Set.Make(Base.Int).t
-
- val empty : t
- val diff : t -> t -> t
- val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a
-end
-
-module Type : sig
- val has_type_var : int -> typ -> bool
- val type_vars : typ -> VarSet.t
-end
-
-type scheme = Scheme of VarSet.t * typ
-
-module TypeEnv : sig
- type t = (id, scheme, Base.String.comparator_witness) Base.Map.t
-
- val empty : t
- val free : t -> VarSet.t
- val apply : Subst.t -> t -> t
- val extend : t -> id -> scheme -> t
- val find : t -> id -> scheme option
- val remove : t -> id -> t
- val merge_envs : Subst.t -> t -> t -> t
-end
diff --git a/ELutsyuk/lib/interpreter/IntAuxilary.ml b/ELutsyuk/lib/interpreter/IntAuxilary.ml
deleted file mode 100644
index bd64b72a3..000000000
--- a/ELutsyuk/lib/interpreter/IntAuxilary.ml
+++ /dev/null
@@ -1,54 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Base
-open Forest.ValuesTree
-
-module Res : sig
- type 'a t
-
- val return : 'a -> 'a t
- val fail : error -> 'a t
- val ( >>= ) : 'a t -> ('a -> 'b t) -> 'b t
- val run : 'a t -> ('a, error) Result.t
- val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t
-end = struct
- type 'a t = ('a, error) Result.t
-
- let return = Result.return
- let fail = Result.fail
- let run m = m
-
- let ( >>= ) monad func =
- match monad with
- | Ok res -> func res
- | Error err -> fail err
- ;;
-
- let ( let* ) = ( >>= )
-end
-
-module EvalEnv : sig
- type t = env
-
- val empty : t
- val extend : t -> string -> value -> t
- val compose : t -> t -> t
- val find_val : t -> string -> value Res.t
-end = struct
- type t = env
-
- let empty = Map.empty (module String)
- let extend env id value = Map.update env id ~f:(fun _ -> value)
-
- let compose env1 env2 =
- Map.fold env2 ~f:(fun ~key ~data acc -> extend acc key data) ~init:env1
- ;;
-
- let find_val env id =
- match Map.find env id with
- | Some value -> Res.return value
- | None -> Res.fail (NoVariable id)
- ;;
-end
diff --git a/ELutsyuk/lib/interpreter/IntAuxilary.mli b/ELutsyuk/lib/interpreter/IntAuxilary.mli
deleted file mode 100644
index be0739068..000000000
--- a/ELutsyuk/lib/interpreter/IntAuxilary.mli
+++ /dev/null
@@ -1,24 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Forest.ValuesTree
-
-module Res : sig
- type 'a t
-
- val return : 'a -> 'a t
- val fail : error -> 'a t
- val ( >>= ) : 'a t -> ('a -> 'b t) -> 'b t
- val run : 'a t -> ('a, error) Result.t
- val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t
-end
-
-module EvalEnv : sig
- type t = env
-
- val empty : t
- val extend : t -> string -> value -> t
- val compose : t -> t -> t
- val find_val : t -> string -> value Res.t
-end
diff --git a/ELutsyuk/lib/interpreter/Interpret.ml b/ELutsyuk/lib/interpreter/Interpret.ml
deleted file mode 100644
index 8c90a437a..000000000
--- a/ELutsyuk/lib/interpreter/Interpret.ml
+++ /dev/null
@@ -1,253 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open IntAuxilary.EvalEnv
-open IntAuxilary.Res
-open Forest.ValuesTree
-open Forest.Ast
-
-let rec match_pattern env = function
- | PatAny, _ -> Some env
- | PatConst (Int x), ValInt v when x = v -> Some env
- | PatConst (Bool x), ValBool v when x = v -> Some env
- | PatConst (Str x), ValStr v when x = v -> Some env
- | PatConst Unit, ValUnit -> Some env
- | PatVar x, v -> Some (extend env x v)
- | PatList pats, ValList vals -> match_list_pat env pats vals
- | PatTup (p1, p2, ps), ValTup (v1, v2, vs) ->
- match_list_pat env (p1 :: p2 :: ps) (v1 :: v2 :: vs)
- | PatListCons (p1, p2), ValList (v :: vs) ->
- let env = match_pattern env (p2, ValList vs) in
- (match env with
- | Some env -> match_pattern env (p1, v)
- | None -> None)
- | _ -> None
-
-and match_list_pat env pats vals =
- let helper acc p v =
- match acc with
- | None -> None
- | Some env -> match_pattern env (p, v)
- in
- match Base.List.fold2 pats vals ~f:helper ~init:(Some env) with
- | Ok res -> res
- | _ -> None
-;;
-
-let eval_const = function
- | Int v -> return @@ ValInt v
- | Str v -> return @@ ValStr v
- | Bool v -> return @@ ValBool v
- | Unit -> return @@ ValUnit
-;;
-
-let eval_unary_op = function
- | Minus, ValInt v -> return @@ ValInt (-v)
- | Plus, ValInt v -> return @@ ValInt v
- | Not, ValBool v -> return @@ ValBool (not v)
- | _ -> fail TypeError
-;;
-
-(* thanks to Homka122 for such beautiful bin_op evaluation *)
-let arithmetic_int_operators = [ Mul, ( * ); Div, ( / ); Add, ( + ); Sub, ( - ) ]
-
-let comparison_operators =
- [ Eq, ( = ); Le, ( <= ); Lt, ( < ); Gt, ( > ); Ge, ( >= ); Ne, ( <> ) ]
-;;
-
-let logical_operators = [ And, ( && ); Or, ( || ) ]
-
-let is_arithmetic_operator name =
- List.exists (fun (list_op, _) -> name = list_op) arithmetic_int_operators
-;;
-
-let is_comparison_operator name =
- List.exists (fun (list_op, _) -> name = list_op) comparison_operators
-;;
-
-let is_logical_operator name =
- List.exists (fun (list_op, _) -> name = list_op) logical_operators
-;;
-
-let eval_arithmetic_int_binop op_name v1 v2 =
- let operator =
- snd (List.find (fun (op_list, _) -> op_list = op_name) arithmetic_int_operators)
- in
- match v1, v2 with
- | ValInt v1, ValInt v2 -> return (ValInt (operator v1 v2))
- | _ -> fail TypeError
-;;
-
-let rec eval_comparison_binop eval_expr env op_name v1 v2 =
- let operator () =
- snd (List.find (fun (op_list, _) -> op_list = op_name) comparison_operators)
- in
- let rec eval_list_comparison list1 list2 =
- match list1, list2 with
- | [], [] -> return (ValBool true)
- | l :: ls, r :: rs ->
- let* res = eval_comparison_binop eval_expr env op_name l r in
- (match res with
- | ValBool false -> return (ValBool false)
- | ValBool true -> eval_list_comparison ls rs
- | _ -> fail TypeError)
- | _, _ -> return (ValBool false)
- in
- match v1, v2 with
- | ValInt v1, ValInt v2 -> return (ValBool ((operator ()) v1 v2))
- | ValStr v1, ValStr v2 -> return (ValBool ((operator ()) v1 v2))
- | ValBool v1, ValBool v2 -> return (ValBool ((operator ()) v1 v2))
- | ValUnit, ValUnit -> return (ValBool ((operator ()) () ()))
- | ValList v1, ValList v2 -> eval_list_comparison v1 v2
- | ValTup (l1, l2, ls), ValTup (r1, r2, rs) ->
- eval_list_comparison (l1 :: l2 :: ls) (r1 :: r2 :: rs)
- | ValOption v1, ValOption v2 ->
- (match v1, v2 with
- | Some v1, Some v2 -> eval_comparison_binop eval_expr env op_name v1 v2
- | None, None -> return (ValBool ((operator ()) None None))
- | _ -> return (ValBool false))
- | _ -> fail TypeError
-;;
-
-let eval_logical_binop op_name v1 v2 =
- let operator =
- snd (List.find (fun (op_list, _) -> op_list = op_name) logical_operators)
- in
- match v1, v2 with
- | ValBool v1, ValBool v2 -> return (ValBool (operator v1 v2))
- | _ -> fail TypeError
-;;
-
-let rec eval_expr (env : env) = function
- | Var name -> find_val env name
- | Const exp -> eval_const exp
- | Unary (op, exp) ->
- let* v = eval_expr env exp in
- eval_unary_op (op, v)
- | BinOp (op, exp1, exp2) when is_comparison_operator op ->
- let* v1 = eval_expr env exp1 in
- let* v2 = eval_expr env exp2 in
- eval_comparison_binop eval_expr env op v1 v2
- | BinOp (op, exp1, exp2) when is_arithmetic_operator op ->
- let* v1 = eval_expr env exp1 in
- let* v2 = eval_expr env exp2 in
- eval_arithmetic_int_binop op v1 v2
- | BinOp (op, exp1, exp2) when is_logical_operator op ->
- let* v1 = eval_expr env exp1 in
- let* v2 = eval_expr env exp2 in
- eval_logical_binop op v1 v2
- | BinOp (_, _, _) -> fail TypeError
- | Option (Some exp) ->
- let* v = eval_expr env exp in
- return (ValOption (Some v))
- | Option None -> return (ValOption None)
- | Let (NonRec, Binding (pat, exp_bind), _, exp_in) ->
- let* v = eval_expr env exp_bind in
- (match match_pattern env (pat, v) with
- | Some env -> eval_expr env exp_in
- | None -> fail PatternMatchingFail)
- | Let (Rec, binding, bindings, exp_in) ->
- let* env = eval_let_bindings env (binding :: bindings) in
- eval_expr env exp_in
- | App (exp1, exp2) ->
- let* v1 = eval_expr env exp1 in
- let* v2 = eval_expr env exp2 in
- (match v1 with
- | ValFun (_, pat, pats, body, func_env) ->
- (match match_pattern func_env (pat, v2) with
- | Some extended_env ->
- let env' = compose env extended_env in
- (match pats with
- | [] -> eval_expr env' body
- | p :: pl -> return (ValFun (NonRec, p, pl, body, env')))
- | None -> fail PatternMatchingFail)
- | ValBuiltIn "print_int" ->
- (match v2 with
- | ValInt v ->
- Format.printf "%d\n" v;
- return ValUnit
- | _ -> fail TypeError)
- | _ -> fail TypeError)
- | Fun (pat, pats, exp) -> return (ValFun (NonRec, pat, pats, exp, env))
- | Branch (cond, _then, Const Unit) ->
- let* v_cond = eval_expr env cond in
- (match v_cond with
- | ValBool true -> eval_expr env _then
- | ValBool false -> return ValUnit
- | _ -> fail TypeError)
- | Branch (cond, _then, _else) ->
- let* v_cond = eval_expr env cond in
- (match v_cond with
- | ValBool true -> eval_expr env _then
- | ValBool false -> eval_expr env _else
- | _ -> fail TypeError)
- | Tup (exp1, exp2, exps) ->
- let* v1 = eval_expr env exp1 in
- let* v2 = eval_expr env exp2 in
- let* vs =
- List.fold_left
- (fun acc exp ->
- let* acc = acc in
- let* v = eval_expr env exp in
- return (v :: acc))
- (return [])
- exps
- in
- return (ValTup (v1, v2, List.rev vs))
- | List exp ->
- let* vl =
- List.fold_left
- (fun acc e ->
- let* acc = acc in
- let* v = eval_expr env e in
- return (v :: acc))
- (return [])
- exp
- in
- return (ValList (List.rev vl))
- | Type (exp, _) -> eval_expr env exp
-
-and eval_let_bindings env binding_list =
- let bindings = List.map (fun (Binding (pat, exp)) -> pat, exp) binding_list in
- let rec update_env acc_env = function
- | [] -> return acc_env
- | (PatVar id, exp) :: list_rest ->
- let* value =
- match exp with
- | Fun (pat, pats, exp) -> return (ValFun (Rec, pat, pats, exp, acc_env))
- | _ -> eval_expr acc_env exp
- in
- let upd_env = extend acc_env id value in
- update_env upd_env list_rest
- | _ -> fail TypeError
- in
- let* env = update_env env bindings in
- return env
-;;
-
-let eval_structure_item env = function
- | Eval exp ->
- let* _ = eval_expr env exp in
- return env
- | Value (NonRec, Binding (pat, exp), _) ->
- let* v = eval_expr env exp in
- (match match_pattern env (pat, v) with
- | Some env -> return env
- | None -> fail PatternMatchingFail)
- | Value (Rec, binding, binding_list) ->
- let* env = eval_let_bindings env (binding :: binding_list) in
- return env
-;;
-
-let start_env = extend empty "print_int" (ValBuiltIn "print_int")
-
-let interpret tree =
- List.fold_left
- (fun env str_item ->
- let* env = env in
- let* env = eval_structure_item env str_item in
- return env)
- (return start_env)
- tree
-;;
diff --git a/ELutsyuk/lib/interpreter/Interpret.mli b/ELutsyuk/lib/interpreter/Interpret.mli
deleted file mode 100644
index f817577d1..000000000
--- a/ELutsyuk/lib/interpreter/Interpret.mli
+++ /dev/null
@@ -1,8 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Forest.Ast
-open Forest.ValuesTree
-
-val interpret : program -> env IntAuxilary.Res.t
diff --git a/ELutsyuk/lib/interpreter/dune b/ELutsyuk/lib/interpreter/dune
deleted file mode 100644
index 1962c5770..000000000
--- a/ELutsyuk/lib/interpreter/dune
+++ /dev/null
@@ -1,10 +0,0 @@
-(include_subdirs qualified)
-
-(library
- (name interpreter)
- (public_name ELutsyuk.MiniML_Interpreter)
- (libraries base angstrom forest parser inferencer)
- (preprocess
- (pps ppx_deriving.show))
- (instrumentation
- (backend bisect_ppx)))
diff --git a/ELutsyuk/lib/parser/Constants.ml b/ELutsyuk/lib/parser/Constants.ml
deleted file mode 100644
index 665837e6a..000000000
--- a/ELutsyuk/lib/parser/Constants.ml
+++ /dev/null
@@ -1,91 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Angstrom
-open Forest.Ast
-open Base
-open PrsAuxilary
-
-(* https://ocaml.org/manual/5.3/lex.html#sss:character-literals *)
-
-let prs_escape_sequence =
- let p_ascii =
- choice
- [ (let* num_opt = take_while1 Char.is_digit >>| Stdlib.int_of_string_opt in
- match num_opt with
- | Some char_code when char_code >= 0 && char_code <= 255 ->
- return @@ Char.of_int_exn char_code
- | _ -> fail "Invalid decimal escape sequence")
- ; (char 'x'
- *>
- let* scanned =
- take_while (function
- | '0' .. '9' | 'A' .. 'F' | 'a' .. 'f' -> true
- | _ -> false)
- in
- let num_opt = Stdlib.int_of_string_opt ("0x" ^ scanned) in
- match num_opt with
- | Some char_code when char_code >= 0 && char_code <= 255 ->
- return @@ Char.of_int_exn char_code
- | _ -> fail "Invalid hex escape sequence")
- ; (char 'o'
- *>
- let* scanned = take 3 in
- let num_opt = Stdlib.int_of_string_opt ("0o" ^ scanned) in
- match num_opt with
- | Some char_code when char_code >= 0 && char_code <= 255 ->
- return @@ Char.of_int_exn char_code
- | _ -> fail "Invalid octal escape sequence")
- ]
- in
- char '\\'
- *> choice
- [ char '\\' *> return '\\'
- ; char '\"' *> return '\"'
- ; char '\'' *> return '\''
- ; char 'n' *> return '\n'
- ; char 't' *> return '\t'
- ; char 'b' *> return '\b'
- ; char 'r' *> return '\r'
- ; string "space" *> return ' '
- ; p_ascii
- ]
-;;
-
-let prs_str =
- let p_regular_str =
- let is_content ch = Char.( <> ) ch '"' && Char.( <> ) ch '\\' in
- let p_content = choice [ prs_escape_sequence; satisfy is_content ] in
- let+ content_char_list = string "\"" *> many p_content <* string "\"" in
- String.of_char_list content_char_list
- in
- let p_quoted_str =
- string "{|" *> take_while (fun ch -> Char.( <> ) ch '|') <* string "|}"
- in
- let+ parsed = p_regular_str <|> p_quoted_str in
- Str parsed
-;;
-
-let prs_int =
- trim
- @@
- let+ parsed = take_while1 Char.is_digit >>| Int.of_string in
- Int parsed
-;;
-
-let prs_bool =
- trim
- @@
- let+ parsed = choice [ token "true" *> return true; token "false" *> return false ] in
- Bool parsed
-;;
-
-let prs_unit =
- trim
- @@
- let+ _ = token "()" in
- Unit
-;;
-
-let prs_const = choice [ prs_int; prs_str; prs_bool; prs_unit ]
diff --git a/ELutsyuk/lib/parser/Constants.mli b/ELutsyuk/lib/parser/Constants.mli
deleted file mode 100644
index b55f22b9e..000000000
--- a/ELutsyuk/lib/parser/Constants.mli
+++ /dev/null
@@ -1,12 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Angstrom
-open Forest.Ast
-
-val prs_int : const t
-val prs_str : const t
-val prs_bool : const t
-val prs_unit : const t
-val prs_const : const t
diff --git a/ELutsyuk/lib/parser/Expressions.ml b/ELutsyuk/lib/parser/Expressions.ml
deleted file mode 100644
index b97e67148..000000000
--- a/ELutsyuk/lib/parser/Expressions.ml
+++ /dev/null
@@ -1,172 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Angstrom
-open Forest.Ast
-open PrsAuxilary
-open Constants
-open Patterns
-open Types
-
-let prs_expr_var =
- trim
- @@
- let+ parsed = prs_id in
- Var parsed
-;;
-
-let prs_expr_const =
- trim
- @@
- let+ parsed = prs_const in
- Const parsed
-;;
-
-let prs_expr_list expr =
- square_par
- @@
- let+ parsed = sep_by (token ";") expr in
- List parsed
-;;
-
-let prs_expr_tuple expr =
- let* el1 = expr in
- let* el2 = token "," *> expr in
- let+ rest = many (token "," *> expr) in
- Tup (el1, el2, rest)
-;;
-
-let prs_expr_fun expr =
- let* pat = token "fun" *> prs_pat in
- let* params = many prs_pat in
- let+ body_expr = token "->" *> expr in
- Fun (pat, params, body_expr)
-;;
-
-let rec prs_expr_body expr =
- let* pat = prs_pat in
- let* pats = many prs_pat in
- choice
- [ prs_expr_body expr
- ; (let+ exp = token "=" *> expr in
- Fun (pat, pats, exp))
- ]
-;;
-
-let prs_let_binding expr =
- let* pat = prs_pat in
- let+ body_expr = choice [ token "=" *> expr; prs_expr_body expr ] in
- Binding (pat, body_expr)
-;;
-
-let prs_expr_let expr =
- trim
- @@ (token "let"
- *>
- let* is_rec = token "rec" *> return Rec <|> return NonRec in
- let* binding = prs_let_binding expr in
- let* bindings_list = many (token "and" *> prs_let_binding expr) in
- let+ in_expr = token "in" *> expr in
- Let (is_rec, binding, bindings_list, in_expr))
-;;
-
-let prs_expr_branch prs_expr =
- let* if_cond = token "if" *> prs_expr in
- let* then_cond = token "then" *> prs_expr in
- let+ else_cond = token "else" *> prs_expr <|> return @@ Const Unit in
- Branch (if_cond, then_cond, else_cond)
-;;
-
-let chainl1 expr oper =
- let rec go acc = lift2 (fun f x -> f acc x) oper expr >>= go <|> return acc in
- expr >>= go
-;;
-
-let prs_bin_op binop sign =
- trim @@ (token sign *> return (fun exp1 exp2 -> BinOp (binop, exp1, exp2)))
-;;
-
-let prs_logical = choice [ prs_bin_op And "&&"; prs_bin_op Or "||" ]
-let prs_mul = prs_bin_op Mul "*"
-let prs_add = prs_bin_op Add "+"
-let prs_sub = prs_bin_op Sub "-"
-let prs_div = prs_bin_op Div "/"
-
-let prs_rel =
- choice
- [ prs_bin_op Eq "="
- ; prs_bin_op Ne "<>"
- ; prs_bin_op Le "<="
- ; prs_bin_op Ge ">="
- ; prs_bin_op Lt "<"
- ; prs_bin_op Gt ">"
- ]
-;;
-
-let prs_unary op sign = trim @@ (token sign *> return (fun exp -> Unary (op, exp)))
-let prs_minus = prs_unary Minus "-"
-let prs_plus = prs_unary Plus "+"
-let prs_not = prs_unary Not "not" <* skip_ws
-
-let prs_option expr =
- let p_some_expr =
- token "Some"
- *>
- let* p_expr = round_par expr <|> expr in
- return (Some p_expr)
- in
- let p_none = token "None" *> return None in
- let+ parsed = p_some_expr <|> p_none in
- Option parsed
-;;
-
-let prs_expr_app expr =
- let app = return @@ fun exp1 exp2 -> App (exp1, exp2) in
- chainl1 expr app
-;;
-
-let prs_expr_type expr =
- let expr_with_type =
- let* exp = expr in
- let* _ = token ":" in
- let+ typ = prs_typ in
- Type (exp, typ)
- in
- expr_with_type <|> round_par expr_with_type
-;;
-
-let unary_chain exp op =
- fix (fun self -> op >>= (fun unop -> self >>= fun exp -> return (unop exp)) <|> exp)
-;;
-
-let prs_expr =
- fix (fun expr ->
- let atom_expr =
- choice
- [ prs_expr_const
- ; prs_expr_var
- ; round_par expr
- ; prs_expr_list expr
- ; prs_expr_fun expr
- ; prs_option expr
- ; round_par (prs_expr_type expr)
- ]
- in
- let let_expr = prs_expr_let expr in
- let ite_expr = prs_expr_branch (expr <|> atom_expr) <|> atom_expr in
- let app_expr = prs_expr_app (ite_expr <|> atom_expr) <|> ite_expr in
- let un_expr =
- choice
- [ unary_chain app_expr prs_not
- ; unary_chain app_expr prs_minus
- ; unary_chain app_expr prs_plus
- ]
- in
- let factor_expr = chainl1 un_expr (prs_mul <|> prs_div) in
- let sum_expr = chainl1 factor_expr (prs_add <|> prs_sub) in
- let rel_expr = chainl1 sum_expr prs_rel in
- let log_expr = chainl1 rel_expr prs_logical in
- let tup_expr = prs_expr_tuple log_expr <|> log_expr in
- choice [ let_expr; tup_expr ])
-;;
diff --git a/ELutsyuk/lib/parser/Expressions.mli b/ELutsyuk/lib/parser/Expressions.mli
deleted file mode 100644
index 449e4312f..000000000
--- a/ELutsyuk/lib/parser/Expressions.mli
+++ /dev/null
@@ -1,22 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Angstrom
-open Forest.Ast
-
-val prs_expr_var : expr t
-val prs_expr_const : expr t
-val prs_expr_list : expr t -> expr t
-val prs_expr_tuple : expr t -> expr t
-val prs_expr_app : expr t -> expr t
-val prs_expr_branch : expr t -> expr t
-val prs_expr_fun : expr t -> expr t
-val prs_expr_let : expr t -> expr t
-val prs_let_binding : expr t -> let_binding t
-
-(* val prs_expr_unary : expr t -> expr t *)
-val prs_bin_op : binop -> id -> (expr -> expr -> expr) t
-val prs_option : expr t -> expr t
-val prs_expr_type : expr t -> expr t
-val prs_expr : expr t
diff --git a/ELutsyuk/lib/parser/Parser.ml b/ELutsyuk/lib/parser/Parser.ml
deleted file mode 100644
index 7d748f164..000000000
--- a/ELutsyuk/lib/parser/Parser.ml
+++ /dev/null
@@ -1,26 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Angstrom
-open Forest.Ast
-open PrsAuxilary
-open Expressions
-
-let prs_structure =
- let p_struct_binding =
- let* _ = token "let" in
- let* rec_state = choice [ string "rec " *> return Rec; return NonRec ] in
- let* binding = prs_let_binding prs_expr in
- let+ bindings_list = many (token "and" *> prs_let_binding prs_expr) in
- Value (rec_state, binding, bindings_list)
- in
- let p_struct_eval =
- let+ eval = prs_expr in
- Eval eval
- in
- p_struct_binding <|> p_struct_eval
-;;
-
-let prs_program = sep_by (many (token ";;")) prs_structure <* many (token ";;") <* skip_ws
-let parse str = parse_string ~consume:All prs_program str
diff --git a/ELutsyuk/lib/parser/Parser.mli b/ELutsyuk/lib/parser/Parser.mli
deleted file mode 100644
index 2d2bd812a..000000000
--- a/ELutsyuk/lib/parser/Parser.mli
+++ /dev/null
@@ -1,11 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Angstrom
-open Forest.Ast
-
-val prs_program : program t
-
-(* val parse_program : program t *)
-val parse : id -> (program, string) result
diff --git a/ELutsyuk/lib/parser/Types.ml b/ELutsyuk/lib/parser/Types.ml
deleted file mode 100644
index 0ba660cf3..000000000
--- a/ELutsyuk/lib/parser/Types.ml
+++ /dev/null
@@ -1,49 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Angstrom
-open Forest.TypesTree
-open PrsAuxilary
-
-let prs_typ_constant =
- choice
- [ (token "int" >>| fun _ -> TypConst TInt)
- ; (token "string" >>| fun _ -> TypConst TStr)
- ; (token "bool" >>| fun _ -> TypConst TBool)
- ; (token "unit" >>| fun _ -> TypConst TUnit)
- ]
-;;
-
-let rec prs_typ_arrow prs_typ =
- let* left_ty = prs_typ in
- let+ right_ty = token "->" *> (prs_typ_arrow prs_typ <|> prs_typ) in
- TypArrow (left_ty, right_ty)
-;;
-
-let prs_typ_tup prs_typ =
- let* ty1 = prs_typ in
- let+ tys = many1 (token "*" *> prs_typ) in
- TypTuple (ty1 :: tys)
-;;
-
-let rec prs_typ_list prs_typ =
- let* ty = prs_typ in
- let* _ = token "list" in
- prs_typ_list (return (TypList ty)) <|> return (TypList ty)
-;;
-
-let rec prs_typ_option prs_typ =
- let* ty = prs_typ in
- let* _ = token "option" in
- prs_typ_option (return (TypOption ty)) <|> return (TypOption ty)
-;;
-
-let prs_typ =
- fix (fun typ ->
- let atom = prs_typ_constant <|> round_par typ in
- let list_or_option = prs_typ_list atom <|> prs_typ_option atom <|> atom in
- let tuple = prs_typ_tup list_or_option <|> list_or_option in
- let arrow = prs_typ_arrow tuple <|> tuple in
- arrow)
-;;
diff --git a/ELutsyuk/lib/parser/Types.mli b/ELutsyuk/lib/parser/Types.mli
deleted file mode 100644
index ffffde3a3..000000000
--- a/ELutsyuk/lib/parser/Types.mli
+++ /dev/null
@@ -1,13 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Angstrom
-open Forest.TypesTree
-
-val prs_typ_constant : typ t
-val prs_typ_arrow : typ t -> typ t
-val prs_typ_tup : typ t -> typ t
-val prs_typ_list : typ t -> typ t
-val prs_typ_option : typ t -> typ t
-val prs_typ : typ t
diff --git a/ELutsyuk/lib/parser/dune b/ELutsyuk/lib/parser/dune
deleted file mode 100644
index a74d0d411..000000000
--- a/ELutsyuk/lib/parser/dune
+++ /dev/null
@@ -1,11 +0,0 @@
-(include_subdirs qualified)
-
-(library
- (name parser)
- (public_name ELutsyuk.MiniML_Parser)
- (libraries base angstrom forest)
- (preprocess
- (pps ppx_expect))
- (inline_tests)
- (instrumentation
- (backend bisect_ppx)))
diff --git a/ELutsyuk/lib/parser/patterns.ml b/ELutsyuk/lib/parser/patterns.ml
deleted file mode 100644
index 814cbcdbb..000000000
--- a/ELutsyuk/lib/parser/patterns.ml
+++ /dev/null
@@ -1,89 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Angstrom
-open Forest.Ast
-open Types
-open Constants
-open PrsAuxilary
-
-let prs_pat_var =
- trim
- @@
- let* parsed = prs_id in
- if String.equal parsed "_" then fail "Any pattern" else return @@ PatVar parsed
-;;
-
-let prs_pat_constant =
- trim
- @@
- let+ parsed = prs_const in
- PatConst parsed
-;;
-
-let prs_pat_any =
- trim
- @@
- let* _ = token "_" in
- let* rest = take_while Base.Char.is_alphanum in
- match rest with
- | "" -> return PatAny
- | _ -> fail "Not any pattern"
-;;
-
-let prs_pat_tuple pat =
- trim
- @@
- let* el1 = pat in
- let* el2 = token "," *> pat in
- let+ rest = many (token "," *> pat) in
- PatTup (el1, el2, rest)
-;;
-
-let prs_pat_cons pat =
- trim
- @@
- let* el1 = pat in
- let* rest = many (token "::" *> pat) in
- let rec helper = function
- | [] -> el1
- | [ el2 ] -> el2
- | el2 :: rest -> PatListCons (el2, helper rest)
- in
- return (helper (el1 :: rest))
-;;
-
-let prs_pat_list pat =
- square_par
- @@
- let+ parsed = sep_by (token ";") pat in
- PatList parsed
-;;
-
-let prs_pat_type pat =
- round_par
- @@
- let* pat = pat in
- let* _ = token ":" in
- let+ typ = prs_typ in
- PatType (pat, typ)
-;;
-
-let prs_pat =
- fix
- @@ fun pat ->
- let atomary =
- choice
- [ prs_pat_var
- ; prs_pat_any
- ; prs_pat_constant
- ; round_par pat
- ; prs_pat_type pat
- ; prs_pat_list pat
- ]
- in
- let cons = prs_pat_cons atomary in
- let tuple = prs_pat_tuple atomary <|> cons in
- tuple
-;;
diff --git a/ELutsyuk/lib/parser/patterns.mli b/ELutsyuk/lib/parser/patterns.mli
deleted file mode 100644
index a4f34c506..000000000
--- a/ELutsyuk/lib/parser/patterns.mli
+++ /dev/null
@@ -1,14 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Angstrom
-open Forest.Ast
-
-val prs_pat_var : pat t
-val prs_pat_constant : pat t
-val prs_pat_any : pat t
-val prs_pat_tuple : pat t -> pat t
-val prs_pat_cons : pat t -> pat t
-val prs_pat_list : pat t -> pat t
-val prs_pat : pat t
diff --git a/ELutsyuk/lib/parser/prsAuxilary.ml b/ELutsyuk/lib/parser/prsAuxilary.ml
deleted file mode 100644
index f9c7aae28..000000000
--- a/ELutsyuk/lib/parser/prsAuxilary.ml
+++ /dev/null
@@ -1,46 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Angstrom
-open Base
-
-(* https://ocaml.org/manual/4.07/manual049.html *)
-let is_keyword = function
- | "if"
- | "then"
- | "else"
- | "fun"
- | "let"
- | "rec"
- | "and"
- | "in"
- | "match"
- | "with"
- | "true"
- | "false"
- | "Some"
- | "None"
- | "val" -> true
- | _ -> false
-;;
-
-let skip_ws = skip_while Char.is_whitespace
-let trim t = skip_ws *> t <* skip_ws
-let token t = skip_ws *> string t <* skip_ws
-let round_par p = token "(" *> p <* token ")"
-let square_par p = token "[" *> p <* token "]"
-
-(** Parses first letter then try parse the rest of id *)
-let prs_id =
- trim
- @@
- let is_first_letter ch =
- Char.is_lowercase ch || Char.is_uppercase ch || Char.equal '_' ch
- in
- let is_rest_letter ch = Char.is_alphanum ch || Char.equal '_' ch in
- let* p_first = satisfy is_first_letter >>| Char.escaped in
- let* p_rest = take_while is_rest_letter in
- let id = p_first ^ p_rest in
- if is_keyword id then fail "Error: parse_id: id match the keyword." else return id
-;;
diff --git a/ELutsyuk/lib/parser/prsAuxilary.mli b/ELutsyuk/lib/parser/prsAuxilary.mli
deleted file mode 100644
index c66e75095..000000000
--- a/ELutsyuk/lib/parser/prsAuxilary.mli
+++ /dev/null
@@ -1,13 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Angstrom
-open Forest.Ast
-
-val skip_ws : unit t
-val trim : 'a t -> 'a t
-val token : string -> string t
-val round_par : 'a t -> 'a t
-val square_par : 'a t -> 'a t
-val prs_id : id t
diff --git a/ELutsyuk/lib/parser/unitTests.ml b/ELutsyuk/lib/parser/unitTests.ml
deleted file mode 100644
index 50412b34a..000000000
--- a/ELutsyuk/lib/parser/unitTests.ml
+++ /dev/null
@@ -1,355 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Angstrom
-open Forest.Ast
-open Forest.TypesTree
-open PrsAuxilary
-open Constants
-open Patterns
-open Expressions
-open Types
-
-let pp printer parser str =
- match parse_string ~consume:Angstrom.Consume.All parser str with
- | Ok res -> printer Format.std_formatter res
- | Error _ -> print_endline "Syntax error"
-;;
-
-(* ================================= auxiliary ================================= *)
-
-let%expect_test "normal_id" =
- pp Format.pp_print_string prs_id "_id";
- [%expect {| _id |}]
-;;
-
-let%expect_test "incorrect_id_num" =
- pp Format.pp_print_string prs_id "1id";
- [%expect {| Syntax error |}]
-;;
-
-let%expect_test "keyword_id" =
- pp Format.pp_print_string prs_id "let";
- [%expect {| Syntax error |}]
-;;
-
-(* ================================= constants ================================= *)
-
-let%expect_test "num_without_sign_before" =
- pp pp_const prs_int "2024";
- [%expect {| (Int 2024) |}]
-;;
-
-let%expect_test "quoted_string_with_double_slash" =
- pp pp_const prs_str "{|str\\meow|}";
- [%expect {| (Str "str\\meow") |}]
-;;
-
-let%expect_test "regular_string_with_double_slash" =
- pp pp_const prs_str {|"str\\meow"|};
- [%expect {| (Str "str\\meow") |}]
-;;
-
-let%expect_test "regular_string_with_slash" =
- pp pp_const prs_str {|"str\meow"|};
- [%expect {| Syntax error |}]
-;;
-
-let%expect_test "regular_unclosed_string" =
- pp pp_const prs_str {|"str|};
- [%expect {| Syntax error |}]
-;;
-
-let%expect_test "quoted_unclosed_string" =
- pp pp_const prs_str "{|str";
- [%expect {| Syntax error |}]
-;;
-
-let%expect_test "quoted_empty_string" =
- pp pp_const prs_str "\"\"";
- [%expect {| (Str "") |}]
-;;
-
-let%expect_test "regular_empty_string" =
- pp pp_const prs_str "{||}";
- [%expect {| (Str "") |}]
-;;
-
-let%expect_test "regular_string_one_space" =
- pp pp_const prs_str "\" \"";
- [%expect {| (Str " ") |}]
-;;
-
-let%expect_test "quoted_string_one_space" =
- pp pp_const prs_str "{| |}";
- [%expect {| (Str " ") |}]
-;;
-
-let%expect_test "quoted_string_two_spaces" =
- pp pp_const prs_str "{| |}";
- [%expect {| (Str " ") |}]
-;;
-
-let%expect_test "quoted_string_with_text" =
- pp pp_const prs_str "{| hello |}";
- [%expect {| (Str " hello ") |}]
-;;
-
-let%expect_test "regular_string_escape_sequence" =
- pp pp_const prs_str "\"Hex\\x41\\x42\\x43\"";
- [%expect {| (Str "HexABC") |}]
-;;
-
-let%expect_test "regular_string_incorrect_escape_sequence" =
- pp pp_const prs_str "\"meow\n\"";
- [%expect {| (Str "meow\n") |}]
-;;
-
-let%expect_test "true" =
- pp pp_const prs_bool "true";
- [%expect {| (Bool true) |}]
-;;
-
-let%expect_test "false" =
- pp pp_const prs_bool "false";
- [%expect {| (Bool false) |}]
-;;
-
-let%expect_test "incorrect_bool_with_char_after" =
- pp pp_const prs_bool "truee";
- [%expect {| Syntax error |}]
-;;
-
-let%expect_test "unit" =
- pp pp_const prs_unit "()";
- [%expect {| Unit |}]
-;;
-
-(* ================================== patterns ================================= *)
-
-let%expect_test "pat_var" =
- pp pp_pat prs_pat_var "meow\n";
- [%expect {| (PatVar "meow") |}]
-;;
-
-let%expect_test "pat_constant" =
- pp pp_pat prs_pat_constant " \r{|meow|}\n";
- [%expect {| (PatConst (Str "meow")) |}]
-;;
-
-let%expect_test "pat_constructor" =
- pp pp_pat (prs_pat_cons prs_pat) "a :: []";
- [%expect {| (PatListCons ((PatVar "a"), (PatList []))) |}]
-;;
-
-let%expect_test "pat_empty_str" =
- pp pp_pat prs_pat_constant " \r{||}\n";
- [%expect {| (PatConst (Str "")) |}]
-;;
-
-let%expect_test "pat_any" =
- pp pp_pat prs_pat_any "\r_\n";
- [%expect {| PatAny |}]
-;;
-
-let%expect_test "pat_simple_tuple" =
- pp pp_pat prs_pat "1, 2, 3";
- [%expect
- {|
- (PatTup ((PatConst (Int 1)), (PatConst (Int 2)), [(PatConst (Int 3))])) |}]
-;;
-
-let%expect_test "incorrect_pat_tuple_of_one_element" =
- pp pp_pat (prs_pat_tuple prs_pat) "1";
- [%expect {| Syntax error |}]
-;;
-
-let%expect_test "parse_empty_list" =
- pp pp_pat (prs_pat_list prs_pat) "[]";
- [%expect {|
- (PatList []) |}]
-;;
-
-(* ================================ expressions ================================ *)
-
-let%expect_test "expr_cons_int" =
- pp pp_expr prs_expr_const "1";
- [%expect {|
- (Const (Int 1)) |}]
-;;
-
-let%expect_test "expr_cons_str" =
- pp pp_expr prs_expr_const " {|meow|} ";
- [%expect {|
- (Const (Str "meow")) |}]
-;;
-
-let%expect_test "expr_cons_unit" =
- pp pp_expr prs_expr_const " () ";
- [%expect {|
- (Const Unit) |}]
-;;
-
-let%expect_test "simple_list" =
- pp pp_expr (prs_expr_list prs_expr) " [ 1 ; 2\n; 3] ";
- [%expect {| (List [(Const (Int 1)); (Const (Int 2)); (Const (Int 3))]) |}]
-;;
-
-let%expect_test "complex_list" =
- pp pp_expr (prs_expr_list prs_expr) " [ [1;2;3] ; 2\n; 3] ";
- [%expect
- {|
- (List
- [(List [(Const (Int 1)); (Const (Int 2)); (Const (Int 3))]);
- (Const (Int 2)); (Const (Int 3))]) |}]
-;;
-
-let%expect_test "empty_list" =
- pp pp_expr (prs_expr_list prs_expr) "[]";
- [%expect {| (List []) |}]
-;;
-
-let%expect_test "incorrect_tuple_one_el" =
- pp pp_expr (prs_expr_tuple prs_expr) "(1)";
- [%expect {| Syntax error |}]
-;;
-
-let%expect_test "simple_fun" =
- pp pp_expr (prs_expr_fun prs_expr) "fun x -> x";
- [%expect {| (Fun ((PatVar "x"), [], (Var "x"))) |}]
-;;
-
-let%expect_test "fun_two_var" =
- pp pp_expr (prs_expr_fun prs_expr) "fun x y -> x + y";
- [%expect
- {|
- (Fun ((PatVar "x"), [(PatVar "y")], (BinOp (Add, (Var "x"), (Var "y"))))) |}]
-;;
-
-let%expect_test "fun_of_fun" =
- pp pp_expr (prs_expr_fun prs_expr) "fun x -> fun _ -> x";
- [%expect {| (Fun ((PatVar "x"), [], (Fun (PatAny, [], (Var "x"))))) |}]
-;;
-
-let%expect_test "let_with_in" =
- pp pp_expr (prs_expr_let prs_expr) "let meow = 5 in meow + 1";
- [%expect
- {|
- (Let (NonRec, (Binding ((PatVar "meow"), (Const (Int 5)))), [],
- (BinOp (Add, (Var "meow"), (Const (Int 1)))))) |}]
-;;
-
-let%expect_test "simple_app" =
- pp pp_expr (prs_expr_app prs_expr) "fact 1";
- [%expect {|
- (App ((Var "fact"), (Const (Int 1)))) |}]
-;;
-
-let%expect_test "app_two_par" =
- pp pp_expr (prs_expr_app prs_expr) "foo 1 2";
- [%expect {|
- (App ((App ((Var "foo"), (Const (Int 1)))), (Const (Int 2)))) |}]
-;;
-
-let%expect_test "app_in_app" =
- pp pp_expr (prs_expr_app prs_expr) "foo (g 1) 2";
- [%expect
- {|
- (App ((App ((Var "foo"), (App ((Var "g"), (Const (Int 1)))))),
- (Const (Int 2)))) |}]
-;;
-
-let%expect_test "simple_branch" =
- pp pp_expr (prs_expr_branch prs_expr) "if x = 5 then 7 else 6";
- [%expect
- {|
- (Branch ((BinOp (Eq, (Var "x"), (Const (Int 5)))), (Const (Int 7)),
- (Const (Int 6)))) |}]
-;;
-
-let%expect_test "branch_in_branch" =
- pp pp_expr (prs_expr_branch prs_expr) "if x = 5 then (if x = 7 then 7) else 4";
- [%expect
- {|
- (Branch ((BinOp (Eq, (Var "x"), (Const (Int 5)))),
- (Branch ((BinOp (Eq, (Var "x"), (Const (Int 7)))), (Const (Int 7)),
- (Const Unit))),
- (Const (Int 4)))) |}]
-;;
-
-let%expect_test "prs_some" =
- pp pp_expr (prs_option prs_expr) "Some (n - 1) ";
- [%expect {|
- (Option (Some (BinOp (Sub, (Var "n"), (Const (Int 1)))))) |}]
-;;
-
-let%expect_test "prs_none" =
- pp pp_expr (prs_option prs_expr) "None ";
- [%expect {|
- (Option None) |}]
-;;
-
-let%expect_test "prs_expr_binop_with_some" =
- pp pp_expr prs_expr "Some n - 1 ";
- [%expect {|
- (Option (Some (BinOp (Sub, (Var "n"), (Const (Int 1)))))) |}]
-;;
-
-let%expect_test "prs_expr_some" =
- pp pp_expr prs_expr "Some (n - 1) ";
- [%expect {|
- (Option (Some (BinOp (Sub, (Var "n"), (Const (Int 1)))))) |}]
-;;
-
-(* =================================== types =================================== *)
-
-let%expect_test "prs_typ_constant_int" =
- pp pp_typ prs_typ_constant "int";
- [%expect {| int |}]
-;;
-
-let%expect_test "prs_typ_constant_string" =
- pp pp_typ prs_typ_constant "string";
- [%expect {| string |}]
-;;
-
-let%expect_test "prs_typ_arrow_simple" =
- pp pp_typ (prs_typ_arrow prs_typ_constant) "int -> string";
- [%expect {| int -> string |}]
-;;
-
-let%expect_test "prs_typ_arrow_nested" =
- pp pp_typ (prs_typ_arrow prs_typ_constant) "int -> string -> bool";
- [%expect {| int -> string -> bool |}]
-;;
-
-let%expect_test "prs_typ_tup_pair" =
- pp pp_typ (prs_typ_tup prs_typ_constant) "int * string";
- [%expect {| (int * string) |}]
-;;
-
-let%expect_test "prs_typ_tup_triple" =
- pp pp_typ (prs_typ_tup prs_typ_constant) "int * string * bool";
- [%expect {| (int * string * bool) |}]
-;;
-
-let%expect_test "prs_typ_list" =
- pp pp_typ (prs_typ_list prs_typ_constant) "int list";
- [%expect {| int list |}]
-;;
-
-let%expect_test "prs_typ_list_nested" =
- pp pp_typ (prs_typ_list prs_typ_constant) "int list list";
- [%expect {| int list list |}]
-;;
-
-let%expect_test "prs_typ_option" =
- pp pp_typ (prs_typ_option prs_typ_constant) "int option";
- [%expect {| int option |}]
-;;
-
-let%expect_test "prs_typ_option_nested" =
- pp pp_typ (prs_typ_option prs_typ_constant) "int option option";
- [%expect {| int option option |}]
-;;
diff --git a/ELutsyuk/lib/parser/unitTests.mli b/ELutsyuk/lib/parser/unitTests.mli
deleted file mode 100644
index e027138eb..000000000
--- a/ELutsyuk/lib/parser/unitTests.mli
+++ /dev/null
@@ -1,3 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
diff --git a/ELutsyuk/tests/InferTests.ml b/ELutsyuk/tests/InferTests.ml
deleted file mode 100644
index 50e17f3ad..000000000
--- a/ELutsyuk/tests/InferTests.ml
+++ /dev/null
@@ -1,85 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Inferencer.Inference
-open Parser
-
-let test_inference str =
- let open Stdlib.Format in
- match parse str with
- | Ok parsed ->
- (match inference parsed with
- | Ok (_, env) ->
- Base.Map.iteri env ~f:(fun ~key ~data:(Scheme (_, typ)) ->
- if String.equal key "print_int" || String.equal key "print_endline"
- then ()
- else Stdlib.Format.printf "val %s : %a\n" key Forest.TypesTree.pp_typ typ)
- | Error err -> printf "Infer error: %a\n" Forest.TypesTree.pp_error err)
- | Error err -> printf "Parsing error: %s\n" err
-;;
-
-let%expect_test "inference_arithmetic" =
- test_inference "let cat = 1 + 2 * 3 / 10";
- [%expect {|
- val cat : int |}]
-;;
-
-let%expect_test "inference_fun_with_argument" =
- test_inference {| let foo x = x + 100 |};
- [%expect {|
- val foo : int -> int |}]
-;;
-
-let%expect_test "inference_rec_fun_with_argument" =
- test_inference {| let rec foo x = foo 5 - 1 |};
- [%expect {|
- val foo : int -> int |}]
-;;
-
-let%expect_test "inference_fun_with_nesting" =
- test_inference {| let add_one x = let double y = y * 2 in double (x + 1) |};
- [%expect {| val add_one : int -> int |}]
-;;
-
-let%expect_test "inference_polymorphic_fun" =
- test_inference "let identity x = x";
- [%expect {| val identity : '0 -> '0 |}]
-;;
-
-let%expect_test "inference_fun_with_tuple_argument" =
- test_inference {| let sum (x, y) = x + y|};
- [%expect {| val sum : (int * int) -> int |}]
-;;
-
-let%expect_test "inference_unbound_variable" =
- test_inference {| let foo x = x + a |};
- [%expect
- {|
- Infer error: unbound variable: 'a' is not defined in the current scope |}]
-;;
-
-let%expect_test "inference_many_fun" =
- test_inference {| let a = fun x y -> fun z -> fun w -> fun c -> x + y + z + w+ c |};
- [%expect {|
-val a : int -> int -> int -> int -> int -> int |}]
-;;
-
-let%expect_test "inference_unit" =
- test_inference {| let x = () |};
- [%expect {|
- val x : unit |}]
-;;
-
-let%expect_test "inference_tuple" =
- test_inference {| let meow = ();; let x = (1, "a", meow ) |};
- [%expect {|
- val meow : unit
- val x : (int * string * unit) |}]
-;;
-
-let%expect_test "inference_combined_type" =
- test_inference {| let foo x = if x then [Some x; Some x] else [None; None]|};
- [%expect {|
- val foo : bool -> bool option list |}]
-;;
diff --git a/ELutsyuk/tests/InferTests.mli b/ELutsyuk/tests/InferTests.mli
deleted file mode 100644
index e027138eb..000000000
--- a/ELutsyuk/tests/InferTests.mli
+++ /dev/null
@@ -1,3 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
diff --git a/ELutsyuk/tests/ParserTests.ml b/ELutsyuk/tests/ParserTests.ml
deleted file mode 100644
index 9d2b1fbd8..000000000
--- a/ELutsyuk/tests/ParserTests.ml
+++ /dev/null
@@ -1,130 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
-open Forest.Ast
-open Parser
-
-let test_parse str =
- let open Stdlib.Format in
- match parse str with
- | Ok program -> printf "%s\n" (show_program program)
- | Error err -> printf "%s\n" err
-;;
-
-let%expect_test "parse_arithmetic" =
- test_parse "1 + 2 * 3";
- [%expect
- {|
- [(Eval
- (BinOp (Add, (Const (Int 1)),
- (BinOp (Mul, (Const (Int 2)), (Const (Int 3)))))))
- ] |}]
-;;
-
-let%expect_test "parse_application" =
- test_parse "fact (n - 1)";
- [%expect
- {|
- [(Eval (App ((Var "fact"), (BinOp (Sub, (Var "n"), (Const (Int 1)))))))] |}]
-;;
-
-let%expect_test "parse_application" =
- test_parse "foo -1";
- [%expect {|
- [(Eval (BinOp (Sub, (Var "foo"), (Const (Int 1)))))] |}]
-;;
-
-let%expect_test "parse_multiple_bindings" =
- test_parse "let x = 10\n let y = x + 5";
- [%expect
- {|
-[(Value (NonRec, (Binding ((PatVar "x"), (Const (Int 10)))), []));
- (Value (NonRec,
- (Binding ((PatVar "y"), (BinOp (Add, (Var "x"), (Const (Int 5)))))),
- []))
- ] |}]
-;;
-
-let%expect_test "parse_brackets" =
- test_parse "(1 + 2) * 3";
- [%expect
- {|
- [(Eval
- (BinOp (Mul, (BinOp (Add, (Const (Int 1)), (Const (Int 2)))),
- (Const (Int 3)))))
- ] |}]
-;;
-
-let%expect_test "complex_tuple" =
- test_parse "((1, 1, 1), (2, 2, 2), {|meow|})";
- [%expect
- {|
- [(Eval
- (Tup ((Tup ((Const (Int 1)), (Const (Int 1)), [(Const (Int 1))])),
- (Tup ((Const (Int 2)), (Const (Int 2)), [(Const (Int 2))])),
- [(Const (Str "meow"))])))
- ] |}]
-;;
-
-let%expect_test "parse_tuple" =
- test_parse "(1, 2, 3)";
- [%expect {|
- [(Eval (Tup ((Const (Int 1)), (Const (Int 2)), [(Const (Int 3))])))] |}]
-;;
-
-let%expect_test "parse_two_func" =
- test_parse
- "let rec fac n = if n<=1 then 1 else n * fac (n-1)\n\
- let main =\n\
- \ let () = print_int (fac 4) in\n\
- \ 0\n\
- ;;";
- [%expect
- {|
- [(Value (Rec,
- (Binding ((PatVar "fac"),
- (Fun ((PatVar "n"), [],
- (Branch ((BinOp (Le, (Var "n"), (Const (Int 1)))), (Const (Int 1)),
- (BinOp (Mul, (Var "n"),
- (App ((Var "fac"), (BinOp (Sub, (Var "n"), (Const (Int 1))))
- ))
- ))
- ))
- ))
- )),
- []));
- (Value (NonRec,
- (Binding ((PatVar "main"),
- (Let (NonRec,
- (Binding ((PatConst Unit),
- (App ((Var "print_int"), (App ((Var "fac"), (Const (Int 4))))))
- )),
- [], (Const (Int 0))))
- )),
- []))
- ] |}]
-;;
-
-let%expect_test "parse_sub_without_ws" =
- test_parse "a-1";
- [%expect {|
- [(Eval (BinOp (Sub, (Var "a"), (Const (Int 1)))))] |}]
-;;
-
-let%expect_test "parse_sub_with_ws" =
- test_parse "a - 1";
- [%expect {|
- [(Eval (BinOp (Sub, (Var "a"), (Const (Int 1)))))] |}]
-;;
-
-let%expect_test "parse_unary_minus" =
- test_parse "a -1";
- [%expect {|
- [(Eval (BinOp (Sub, (Var "a"), (Const (Int 1)))))] |}]
-;;
-
-let%expect_test "parse_unary_plus" =
- test_parse "a +1";
- [%expect {| [(Eval (BinOp (Add, (Var "a"), (Const (Int 1)))))] |}]
-;;
diff --git a/ELutsyuk/tests/ParserTests.mli b/ELutsyuk/tests/ParserTests.mli
deleted file mode 100644
index e027138eb..000000000
--- a/ELutsyuk/tests/ParserTests.mli
+++ /dev/null
@@ -1,3 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
diff --git a/ELutsyuk/tests/dune b/ELutsyuk/tests/dune
deleted file mode 100644
index c623642bc..000000000
--- a/ELutsyuk/tests/dune
+++ /dev/null
@@ -1,42 +0,0 @@
-(library
- (name tests)
- (libraries
- ELutsyuk.MiniML_Forest
- ELutsyuk.MiniML_Parser
- ELutsyuk.MiniML_Interpreter
- ELutsyuk.MiniML_Inferencer)
- (preprocess
- (pps ppx_expect ppx_deriving.show))
- (inline_tests)
- (instrumentation
- (backend bisect_ppx)))
-
-(cram
- (applies_to tests)
- (deps
- ../bin/main.exe
- manytests/do_not_type/001.ml
- manytests/do_not_type/002if.ml
- manytests/do_not_type/003occurs.ml
- manytests/do_not_type/004let_poly.ml
- manytests/do_not_type/005.ml
- manytests/do_not_type/015tuples.ml
- manytests/do_not_type/016tuples_mismatch.ml
- manytests/do_not_type/097fun_vs_list.ml
- manytests/do_not_type/097fun_vs_unit.ml
- manytests/do_not_type/098rec_int.ml
- manytests/do_not_type/099.ml
- manytests/typed/001fac.ml
- manytests/typed/002fac.ml
- manytests/typed/003fib.ml
- manytests/typed/004manyargs.ml
- manytests/typed/005fix.ml
- manytests/typed/006partial.ml
- manytests/typed/006partial2.ml
- manytests/typed/006partial3.ml
- manytests/typed/007order.ml
- manytests/typed/008ascription.ml
- manytests/typed/009let_poly.ml
- manytests/typed/010sukharev.ml
- manytests/typed/015tuples.ml
- manytests/typed/016lists.ml))
diff --git a/ELutsyuk/tests/manytests b/ELutsyuk/tests/manytests
deleted file mode 120000
index 0bd48791d..000000000
--- a/ELutsyuk/tests/manytests
+++ /dev/null
@@ -1 +0,0 @@
-../../manytests
\ No newline at end of file
diff --git a/ELutsyuk/tests/tests.t b/ELutsyuk/tests/tests.t
deleted file mode 100644
index 1ab675ada..000000000
--- a/ELutsyuk/tests/tests.t
+++ /dev/null
@@ -1,152 +0,0 @@
-(** Copyright 2024, Victoria Lutsyuk *)
-
-(** SPDX-License-Identifier: MIT *)
-
- $ ../bin/main.exe -eval -file manytests/typed/001fac.ml
- 24
-
- $ ../bin/main.exe -eval -file manytests/typed/002fac.ml
- 24
-
- $ ../bin/main.exe -eval -file manytests/typed/003fib.ml
- 3
- 3
-
- $ ../bin/main.exe -eval -file manytests/typed/004manyargs.ml
- 1111111111
- 1
- 10
- 100
-
- $ ../bin/main.exe -eval -file manytests/typed/005fix.ml
- 720
-
- $ ../bin/main.exe -eval -file manytests/typed/006partial.ml
- 1122
-
-
- $ ../bin/main.exe -eval -file manytests/typed/006partial2.ml
- 1
- 2
- 3
- 7
-
-
- $ ../bin/main.exe -eval -file manytests/typed/006partial3.ml
- 4
- 8
- 9
-
- $ ../bin/main.exe -eval -file manytests/typed/007order.ml
- 1
- 2
- 4
- -1
- 103
- -555555
- 10000
-
-
- $ ../bin/main.exe -eval -file manytests/typed/008ascription.ml
- 8
-
- $ ../bin/main.exe -eval -file manytests/typed/009let_poly.ml
-
- $ ../bin/main.exe -eval -file manytests/typed/015tuples.ml
- 1
- 1
- 1
- 1
-
- $ ../bin/main.exe -infer -file manytests/typed/001fac.ml
- val fac: int -> int
- val main: int
-
- $ ../bin/main.exe -infer -file manytests/typed/002fac.ml
- val fac_cps: int -> (int -> int) -> int
- val main: int
-
- $ ../bin/main.exe -infer -file manytests/typed/003fib.ml
- val fib: int -> int
- val fib_acc: int -> int -> int -> int
- val main: int
-
- $ ../bin/main.exe -infer -file manytests/typed/004manyargs.ml
- val main: int
- val test10: int -> int -> int -> int -> int -> int -> int -> int -> int -> int -> int
- val test3: int -> int -> int -> int
- val wrap: '0 -> '0
-
- $ ../bin/main.exe -infer -file manytests/typed/005fix.ml
- val fac: (int -> int) -> int -> int
- val fix: ((int -> int) -> int -> int) -> int -> int
- val main: int
-
- $ ../bin/main.exe -infer -file manytests/typed/006partial.ml
- val foo: int -> int
- val main: int
-
- $ ../bin/main.exe -infer -file manytests/typed/006partial2.ml
- val foo: int -> int -> int -> int
- val main: int
-
- $ ../bin/main.exe -infer -file manytests/typed/006partial3.ml
- val foo: int -> int -> int -> unit
- val main: int
-
- $ ../bin/main.exe -infer -file manytests/typed/007order.ml
- val _start: unit -> unit -> int -> unit -> int -> int -> unit -> int -> int -> int
- val main: unit
-
-
- $ ../bin/main.exe -infer -file manytests/typed/008ascription.ml
- val addi: ('2 -> bool -> int) -> ('2 -> bool) -> '2 -> int
- val main: int
-
-
-
- $ ../bin/main.exe -infer -file manytests/typed/009let_poly.ml
- val temp: (int * bool)
-
-
- $ ../bin/main.exe -infer -file manytests/typed/015tuples.ml
- val feven: (int -> int * '28) -> int -> int
- val fix: ((((int -> int * int -> int) -> int -> int * (int -> int * int -> int) -> int -> int) -> (int -> int * int -> int)) -> ((int -> int * int -> int) -> int -> int * (int -> int * int -> int) -> int -> int) -> (int -> int * int -> int)) -> ((int -> int * int -> int) -> int -> int * (int -> int * int -> int) -> int -> int) -> (int -> int * int -> int)
- val fixpoly: ((int -> int * int -> int) -> int -> int * (int -> int * int -> int) -> int -> int) -> (int -> int * int -> int)
- val fodd: ('35 * int -> int) -> int -> int
- val main: int
- val map: ('9 -> '11) -> ('9 * '9) -> ('11 * '11)
- val meven: int -> int
- val modd: int -> int
- val tie: (int -> int * int -> int)
-
-
-
- $ ../bin/main.exe -infer -file manytests/do_not_type/001.ml
- Inferencing error: unbound variable: 'fac' is not defined in the current scope.
-
- $ ../bin/main.exe -infer -file manytests/do_not_type/002if.ml
- Inferencing error: type unification failed: cannot unify types int and bool.
-
-
- $ ../bin/main.exe -infer -file manytests/do_not_type/003occurs.ml
- Inferencing error: occurs check failed: variable '1' cannot appear in its own type '1 -> '3.
-
-
- $ ../bin/main.exe -infer -file manytests/do_not_type/004let_poly.ml
- Inferencing error: type unification failed: cannot unify types int and bool.
-
- $ ../bin/main.exe -infer -file manytests/do_not_type/015tuples.ml
- Inferencing error: illegal left-hand side: only variables can appear on the left-hand side of a 'let' binding.
-
- $ ../bin/main.exe -infer -file manytests/do_not_type/016tuples_mismatch.ml
- Inferencing error: type unification failed: cannot unify types ('1 * '0) and (int * int * int).
-
- $ ../bin/main.exe -infer -file manytests/do_not_type/097fun_vs_list.ml
- Inferencing error: type unification failed: cannot unify types '2 list and '0 -> '0.
-
- $ ../bin/main.exe -infer -file manytests/do_not_type/097fun_vs_unit.ml
- Inferencing error: type unification failed: cannot unify types unit and '0 -> '0.
-
- $ ../bin/main.exe -infer -file manytests/do_not_type/098rec_int.ml
- Inferencing error: illegal right-hand side: the right-hand side of a 'let' binding must be an expression, not a pattern.
diff --git a/EMigunova/.envrc b/EMigunova/.envrc
deleted file mode 100644
index e6bd6786d..000000000
--- a/EMigunova/.envrc
+++ /dev/null
@@ -1,3 +0,0 @@
-export OPAMSWITCH=4.14.2+flambda
-eval $(opam env)
-
diff --git a/EMigunova/.gitignore b/EMigunova/.gitignore
deleted file mode 100644
index 7102a822c..000000000
--- a/EMigunova/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-_build
-_coverage
-/_esy
-/node_modules
-/esy.lock
-/.melange.eobjs
diff --git a/EMigunova/.ocamlformat b/EMigunova/.ocamlformat
deleted file mode 100644
index 97f970802..000000000
--- a/EMigunova/.ocamlformat
+++ /dev/null
@@ -1,2 +0,0 @@
-profile=janestreet
-version=0.26.2
diff --git a/EMigunova/.ocamlinit b/EMigunova/.ocamlinit
deleted file mode 100644
index 57cb5691b..000000000
--- a/EMigunova/.ocamlinit
+++ /dev/null
@@ -1,10 +0,0 @@
-#require "base";;
-#require "angstrom";;
-#load "parse.cmo";;
-#load "inference.cmo";;
-#load "interpreter.cmo";;
-open Ast;;
-open Parse;;
-open Inference;;
-open Interpreter;;
-
diff --git a/EMigunova/.zanuda b/EMigunova/.zanuda
deleted file mode 100644
index 0f09b19b2..000000000
--- a/EMigunova/.zanuda
+++ /dev/null
@@ -1 +0,0 @@
-forward mutability_check ignore REPL.ml
diff --git a/EMigunova/COPYING b/EMigunova/COPYING
deleted file mode 100644
index f288702d2..000000000
--- a/EMigunova/COPYING
+++ /dev/null
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is 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. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- 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.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- 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 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. Use with the GNU Affero General Public License.
-
- 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 Affero 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 special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU 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 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 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 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.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- Copyright (C)
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- 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 GPL, see
-.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-.
diff --git a/EMigunova/COPYING.CC0 b/EMigunova/COPYING.CC0
deleted file mode 100644
index 0e259d42c..000000000
--- a/EMigunova/COPYING.CC0
+++ /dev/null
@@ -1,121 +0,0 @@
-Creative Commons Legal Code
-
-CC0 1.0 Universal
-
- CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
- LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
- ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
- INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
- REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
- PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
- THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
- HEREUNDER.
-
-Statement of Purpose
-
-The laws of most jurisdictions throughout the world automatically confer
-exclusive Copyright and Related Rights (defined below) upon the creator
-and subsequent owner(s) (each and all, an "owner") of an original work of
-authorship and/or a database (each, a "Work").
-
-Certain owners wish to permanently relinquish those rights to a Work for
-the purpose of contributing to a commons of creative, cultural and
-scientific works ("Commons") that the public can reliably and without fear
-of later claims of infringement build upon, modify, incorporate in other
-works, reuse and redistribute as freely as possible in any form whatsoever
-and for any purposes, including without limitation commercial purposes.
-These owners may contribute to the Commons to promote the ideal of a free
-culture and the further production of creative, cultural and scientific
-works, or to gain reputation or greater distribution for their Work in
-part through the use and efforts of others.
-
-For these and/or other purposes and motivations, and without any
-expectation of additional consideration or compensation, the person
-associating CC0 with a Work (the "Affirmer"), to the extent that he or she
-is an owner of Copyright and Related Rights in the Work, voluntarily
-elects to apply CC0 to the Work and publicly distribute the Work under its
-terms, with knowledge of his or her Copyright and Related Rights in the
-Work and the meaning and intended legal effect of CC0 on those rights.
-
-1. Copyright and Related Rights. A Work made available under CC0 may be
-protected by copyright and related or neighboring rights ("Copyright and
-Related Rights"). Copyright and Related Rights include, but are not
-limited to, the following:
-
- i. the right to reproduce, adapt, distribute, perform, display,
- communicate, and translate a Work;
- ii. moral rights retained by the original author(s) and/or performer(s);
-iii. publicity and privacy rights pertaining to a person's image or
- likeness depicted in a Work;
- iv. rights protecting against unfair competition in regards to a Work,
- subject to the limitations in paragraph 4(a), below;
- v. rights protecting the extraction, dissemination, use and reuse of data
- in a Work;
- vi. database rights (such as those arising under Directive 96/9/EC of the
- European Parliament and of the Council of 11 March 1996 on the legal
- protection of databases, and under any national implementation
- thereof, including any amended or successor version of such
- directive); and
-vii. other similar, equivalent or corresponding rights throughout the
- world based on applicable law or treaty, and any national
- implementations thereof.
-
-2. Waiver. To the greatest extent permitted by, but not in contravention
-of, applicable law, Affirmer hereby overtly, fully, permanently,
-irrevocably and unconditionally waives, abandons, and surrenders all of
-Affirmer's Copyright and Related Rights and associated claims and causes
-of action, whether now known or unknown (including existing as well as
-future claims and causes of action), in the Work (i) in all territories
-worldwide, (ii) for the maximum duration provided by applicable law or
-treaty (including future time extensions), (iii) in any current or future
-medium and for any number of copies, and (iv) for any purpose whatsoever,
-including without limitation commercial, advertising or promotional
-purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
-member of the public at large and to the detriment of Affirmer's heirs and
-successors, fully intending that such Waiver shall not be subject to
-revocation, rescission, cancellation, termination, or any other legal or
-equitable action to disrupt the quiet enjoyment of the Work by the public
-as contemplated by Affirmer's express Statement of Purpose.
-
-3. Public License Fallback. Should any part of the Waiver for any reason
-be judged legally invalid or ineffective under applicable law, then the
-Waiver shall be preserved to the maximum extent permitted taking into
-account Affirmer's express Statement of Purpose. In addition, to the
-extent the Waiver is so judged Affirmer hereby grants to each affected
-person a royalty-free, non transferable, non sublicensable, non exclusive,
-irrevocable and unconditional license to exercise Affirmer's Copyright and
-Related Rights in the Work (i) in all territories worldwide, (ii) for the
-maximum duration provided by applicable law or treaty (including future
-time extensions), (iii) in any current or future medium and for any number
-of copies, and (iv) for any purpose whatsoever, including without
-limitation commercial, advertising or promotional purposes (the
-"License"). The License shall be deemed effective as of the date CC0 was
-applied by Affirmer to the Work. Should any part of the License for any
-reason be judged legally invalid or ineffective under applicable law, such
-partial invalidity or ineffectiveness shall not invalidate the remainder
-of the License, and in such case Affirmer hereby affirms that he or she
-will not (i) exercise any of his or her remaining Copyright and Related
-Rights in the Work or (ii) assert any associated claims and causes of
-action with respect to the Work, in either case contrary to Affirmer's
-express Statement of Purpose.
-
-4. Limitations and Disclaimers.
-
- a. No trademark or patent rights held by Affirmer are waived, abandoned,
- surrendered, licensed or otherwise affected by this document.
- b. Affirmer offers the Work as-is and makes no representations or
- warranties of any kind concerning the Work, express, implied,
- statutory or otherwise, including without limitation warranties of
- title, merchantability, fitness for a particular purpose, non
- infringement, or the absence of latent or other defects, accuracy, or
- the present or absence of errors, whether or not discoverable, all to
- the greatest extent permissible under applicable law.
- c. Affirmer disclaims responsibility for clearing rights of other persons
- that may apply to the Work or any use thereof, including without
- limitation any person's Copyright and Related Rights in the Work.
- Further, Affirmer disclaims responsibility for obtaining any necessary
- consents, permissions or other rights required for any use of the
- Work.
- d. Affirmer understands and acknowledges that Creative Commons is not a
- party to this document and has no duty or obligation with respect to
- this CC0 or use of the Work.
diff --git a/EMigunova/COPYING.LESSER b/EMigunova/COPYING.LESSER
deleted file mode 100644
index 0a041280b..000000000
--- a/EMigunova/COPYING.LESSER
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser 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
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/EMigunova/EMigunova.opam b/EMigunova/EMigunova.opam
deleted file mode 100644
index f3591117e..000000000
--- a/EMigunova/EMigunova.opam
+++ /dev/null
@@ -1,36 +0,0 @@
-# This file is generated by dune, edit dune-project instead
-opam-version: "2.0"
-version: "0.1"
-synopsis: "An interpreter for miniML"
-description:
- "FIXME. A longer description, for example, which are the most interesting features being supported, etc."
-maintainer: ["Migunova Anastasia "]
-authors: ["Migunova Anastasia "]
-license: "LGPL-3.0-or-later"
-homepage: "https://github.com/MigunovaAnastasia1/fp2024"
-doc: "https://kakadu.github.io/fp2024/docs/EMigunova"
-bug-reports: "https://github.com/MigunovaAnastasia1/fp2024"
-depends: [
- "dune" {>= "3.7"}
- "angstrom"
- "ppx_inline_test" {with-test}
- "ppx_expect"
- "ppx_deriving"
- "bisect_ppx"
- "odoc" {with-doc}
- "ocamlformat" {build}
-]
-build: [
- ["dune" "subst"] {dev}
- [
- "dune"
- "build"
- "-p"
- name
- "-j"
- jobs
- "@install"
- "@runtest" {with-test}
- "@doc" {with-doc}
- ]
-]
diff --git a/EMigunova/Makefile b/EMigunova/Makefile
deleted file mode 100644
index e234db4bf..000000000
--- a/EMigunova/Makefile
+++ /dev/null
@@ -1,49 +0,0 @@
-.PHONY: repl tests test fmt lint celan
-
-all:
- dune build
-
-repl:
- dune build ./REPL.exe && rlwrap _build/default/REPL.exe
-
-tests: test
-test:
- dune runtest
-
-celan: clean
-clean:
- @$(RM) -r _build _coverage
-
-fmt:
- dune build @fmt --auto-promote
-
-lint:
- dune build @lint --force
-
-release:
- dune build --profile=release
- dune runtest --profile=release
-
-install:
- dune b @install --profile=release
- dune install
-
-ODIG_SWITCHES = --odoc-theme=odig.gruvbox.light
-ODIG_SWITCHES += --no-tag-index
-ODIG_SWITCHES += --no-pkg-deps
-odig:
- odig odoc $(ODIG_SWITCHES) Lambda
-
-TEST_COV_D = /tmp/cov
-COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect tests/
-
-.PHONY: test_coverage coverage
-test_coverage: coverage
-coverage:
- $(RM) -r $(TEST_COV_D)
- mkdir -p $(TEST_COV_D)
- BISECT_FILE=$(TEST_COV_D)/language dune runtest --no-print-directory \
- --instrument-with bisect_ppx --force
- bisect-ppx-report html $(COVERAGE_OPTS)
- bisect-ppx-report summary $(COVERAGE_OPTS)
- @echo "Use 'xdg-open _coverage/index.html' to see coverage report"
diff --git a/EMigunova/bin/REPL.ml b/EMigunova/bin/REPL.ml
deleted file mode 100644
index b2efc3fa8..000000000
--- a/EMigunova/bin/REPL.ml
+++ /dev/null
@@ -1,68 +0,0 @@
-(** Copyright 2025, Migunova Anastasia *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open EMigunova_lib
-
-type options =
- { mutable dump_parsetree : bool
- ; mutable dump_inference : bool
- }
-
-let run_single dump_parsetree dump_inference =
- let text = In_channel.(input_all stdin) |> String.trim in
- let ast = Parse.parse text in
- match ast with
- | Error _ -> Format.printf "Syntax error"
- | Result.Ok ast ->
- if dump_parsetree then Format.printf "%a\n" Ast.pp_structure ast;
- if dump_inference
- then (
- let infer = Inference.run_inferencer ast in
- match infer with
- | Error e ->
- Printf.printf "Type inference error: ";
- Inference.print_error e
- | Result.Ok infer_result_list ->
- let inter = Interpreter.run_interpreter ast in
- (match inter with
- | Error e -> Interpreter.print_error e
- | Result.Ok inter_result_list ->
- Base.List.fold2_exn
- infer_result_list
- inter_result_list
- ~init:()
- ~f:(fun () (name, ty) (_, value) ->
- Printf.printf "val %s : " name;
- Inference.print_type ty;
- Printf.printf " = ";
- Interpreter.print_value value;
- Printf.printf "\n")));
- if not (dump_inference || dump_parsetree)
- then (
- match Inference.run_inferencer ast with
- | Error _ -> ()
- | _ ->
- let _ = Interpreter.run_interpreter ast in
- ())
-;;
-
-let () =
- let options = { dump_parsetree = false; dump_inference = false } in
- let () =
- let open Stdlib.Arg in
- parse
- [ ( "--dparsetree"
- , Unit (fun () -> options.dump_parsetree <- true)
- , "Dump parse tree, don't eval enything" )
- ; ( "--dinference"
- , Unit (fun () -> options.dump_inference <- true)
- , "Eval and display type inference info" )
- ]
- (fun _ ->
- Stdlib.Format.eprintf "Anonymous arguments are not supported\n";
- Stdlib.exit 1)
- "Read-Eval-Print-Loop for MiniML Calculus"
- in
- run_single options.dump_parsetree options.dump_inference
-;;
diff --git a/EMigunova/bin/dune b/EMigunova/bin/dune
deleted file mode 100644
index b4ff2cd1d..000000000
--- a/EMigunova/bin/dune
+++ /dev/null
@@ -1,7 +0,0 @@
-(executable
- (name REPL)
- (public_name REPL)
- (libraries EMigunova_lib))
-
-(cram
- (deps ./REPL.exe %{bin:REPL}))
diff --git a/EMigunova/bin/repl.t b/EMigunova/bin/repl.t
deleted file mode 100644
index e38e3ca4f..000000000
--- a/EMigunova/bin/repl.t
+++ /dev/null
@@ -1,9 +0,0 @@
-(** Copyright 2025, Migunova Anastasia *)
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
- $ ./REPL.exe -help
- Read-Eval-Print-Loop for MiniML Calculus
- --dparsetree Dump parse tree, don't eval enything
- --dinference Eval and display type inference info
- -help Display this list of options
- --help Display this list of options
diff --git a/EMigunova/dune b/EMigunova/dune
deleted file mode 100644
index 98e54536a..000000000
--- a/EMigunova/dune
+++ /dev/null
@@ -1,7 +0,0 @@
-(env
- (dev
- (flags
- (:standard -alert @deprecated -warn-error -A -w -3-9-32-34-58)))
- (release
- (flags
- (:standard -alert @deprecated -warn-error +A -w +A-4-40-42-44-70))))
diff --git a/EMigunova/dune-project b/EMigunova/dune-project
deleted file mode 100644
index 3f6b334cb..000000000
--- a/EMigunova/dune-project
+++ /dev/null
@@ -1,35 +0,0 @@
-(lang dune 3.7)
-
-(generate_opam_files true)
-
-(cram enable)
-
-(license LGPL-3.0-or-later)
-
-(authors "Migunova Anastasia ")
-
-(maintainers "Migunova Anastasia ")
-
-(bug_reports "https://github.com/MigunovaAnastasia1/fp2024")
-
-(homepage "https://github.com/MigunovaAnastasia1/fp2024")
-
-(package
- (name EMigunova) ; FIXME and regenerate .opam file using 'dune build @install'
- (synopsis "An interpreter for miniML")
- (description
- "FIXME. A longer description, for example, which are the most interesting features being supported, etc.")
- (documentation "https://kakadu.github.io/fp2024/docs/EMigunova")
- (version 0.1)
- (depends
- dune
- angstrom
- (ppx_inline_test :with-test)
- ppx_expect
- ppx_deriving
- bisect_ppx
- (odoc :with-doc)
- (ocamlformat :build)
- ; base
- ; After adding dependencies to 'dune' files add the same dependecies here too
- ))
diff --git a/EMigunova/lib/ast.ml b/EMigunova/lib/ast.ml
deleted file mode 100644
index f075157d4..000000000
--- a/EMigunova/lib/ast.ml
+++ /dev/null
@@ -1,98 +0,0 @@
-(** Copyright 2024, Migunova Anastasia *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-(** identidicator *)
-type ident = string [@@deriving show { with_path = false }]
-
-(** constants *)
-type constant =
- | Const_int of int
- | Const_bool of bool
- | Const_char of char
- | Const_string of string
- | Const_unit (** Represents a single value [ () ]*)
-[@@deriving show { with_path = false }]
-
-(** types *)
-type ttype =
- | Type_int
- | Type_bool
- | Type_char
- | Type_string
- | Type_unit
- | Type_var of ident (** Represents type variable, e.g. [ 'a ]*)
- | Type_option of ttype option (**e.g. [ int option ]*)
- | Type_list of ttype (**e.g. [ bool list ]*)
- | Type_tuple of ttype list (**e.g. [ int*int*bool ]*)
- | Type_arrow of ttype * ttype (**e.g. [ int -> bool ]*)
-[@@deriving show { with_path = false }]
-
-(** patterns *)
-type pattern =
- | Pattern_any (** The pattern [ _ ]. *)
- | Pattern_const of constant (** e.g. [ () ], [ true ], [ 2 ] *)
- | Pattern_var of string (** A variable pattern such as [ x ] *)
- | Pattern_option of pattern option (** e.g. [ Some x ], [ None ] *)
- | Pattern_tuple of pattern list (** Represnts n-tuples (x1, x2, ... ,xn) *)
- | Pattern_list_sugar_case of pattern list (** e.g. [ [x1; x2; x3] ] *)
- | Pattern_list_constructor_case of pattern list (** e.g. [ x1::x2::[x3;x4] ] *)
-[@@deriving show { with_path = false }]
-
-(** binary operators*)
-type binary_op =
- | Plus (** [+] *)
- | Sub (** [-] *)
- | Mul (** [*] *)
- | Div (** [/] *)
- | And (** [&&]*)
- | Or (** [||]*)
- | Equal (** [=]*)
- | NotEqual (** [<>] or [!=]*)
- | Less (** [<]*)
- | LessEqual (** [<=]*)
- | Greater (** [>]*)
- | GreaterEqual (** [>=]*)
-[@@deriving show { with_path = false }]
-
-(** expressions*)
-type expression =
- | Expr_var of ident (** e.g. [x] *)
- | Expr_const of constant (** e.g. [3], [true], ["string"] *)
- | Expr_option of expression option (** e.g. [Some (x-3)], [None] *)
- | Expr_list_sugar of expression list (** e.g. [ [4;5;6] ] *)
- | Expr_list_construct of expression list (** e.g. [ 4::5::6::[] ] *)
- | Expr_tuple of expression list (** e.g. [ (x,5+y)) ] *)
- | Expr_binary_op of binary_op * expression * expression
- (** e.g. [ 2+3 ], [ 23 true | _ -> false] *)
- | Expr_construct_in of let_binding * expression (** e.g. [ let x = 4 in x] *)
- | Expr_anonym_fun of pattern list * expression (** e.g. [ fun a b -> a + b ] *)
- | Expr_function_fun of (pattern * expression) list
- (** e.g. [ function | (a,b) -> a+b | _ -> 0] *)
- | Expr_application of expression * expression list
- (** e.g. [ f a b ] [ (fun a -> a*3) 5 ] [ (function | true -> 1 | false -> 0) x ] *)
- | Typed_expression of ttype * expression (** e.g. [ (x : int) ] *)
-
-(** recursive flag *)
-and rec_flag =
- | Recursive
- | Non_recursive
-
-(** LHS of let binding comes in two forms: (1) let [ pattern ] = ... ;
- (2) let [ fun_id arg1 arg2 ] = ... *)
-and let_declaration =
- | Let_pattern of pattern
- | Let_fun of ident * pattern list
-
-(** let bindind *)
-and let_binding =
- | Let_binding of rec_flag * let_declaration * expression
- | Let_rec_and_binding of let_binding list
-[@@deriving show { with_path = false }]
-
-(** entire program*)
-type structure = let_binding list [@@deriving show { with_path = false }]
diff --git a/EMigunova/lib/dune b/EMigunova/lib/dune
deleted file mode 100644
index ce2300b5c..000000000
--- a/EMigunova/lib/dune
+++ /dev/null
@@ -1,9 +0,0 @@
-(library
- (name EMigunova_lib)
- (public_name EMigunova.Lib)
- (modules Ast Parse Inference Interpreter)
- (libraries base angstrom)
- (preprocess
- (pps ppx_deriving.show))
- (instrumentation
- (backend bisect_ppx)))
diff --git a/EMigunova/lib/inference.ml b/EMigunova/lib/inference.ml
deleted file mode 100644
index f9ec6b527..000000000
--- a/EMigunova/lib/inference.ml
+++ /dev/null
@@ -1,951 +0,0 @@
-(** Copyright 2025, Migunova Anastasia *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-
-let rec print_type (ty : ttype) =
- match ty with
- | Type_int -> Printf.printf "int"
- | Type_bool -> Printf.printf "bool"
- | Type_char -> Printf.printf "char"
- | Type_string -> Printf.printf "string"
- | Type_unit -> Printf.printf "unit"
- | Type_var ident -> Printf.printf "%s" ident
- | Type_option (Some ty) ->
- (match ty with
- | Type_tuple _ ->
- Printf.printf "(";
- print_type ty;
- Printf.printf ")"
- | _ -> print_type ty);
- Printf.printf " option"
- | Type_option None -> ()
- | Type_list ty ->
- (match ty with
- | Type_tuple _ ->
- Printf.printf "(";
- print_type ty;
- Printf.printf ")"
- | _ -> print_type ty);
- Printf.printf " list"
- | Type_tuple ty_list ->
- (match ty_list with
- | first :: second :: rest ->
- (match first with
- | Type_arrow _ | Type_tuple _ ->
- Printf.printf "(";
- print_type first;
- Printf.printf ")"
- | _ -> print_type first);
- Printf.printf "*";
- print_type (Type_tuple (second :: rest))
- | single :: [] ->
- (match single with
- | Type_arrow _ | Type_tuple _ ->
- Printf.printf "(";
- print_type single;
- Printf.printf ")"
- | _ -> print_type single)
- | _ -> ())
- | Type_arrow (ty1, ty2) ->
- (match ty1 with
- | Type_arrow _ ->
- Printf.printf "(";
- print_type ty1;
- Printf.printf ")"
- | _ -> print_type ty1);
- Printf.printf "->";
- print_type ty2
-;;
-
-type error =
- [ `No_variable_rec
- | `No_arg_rec
- | `Bound_several_times of string
- | `Occurs_check of string * ttype (* * core_type *)
- | `No_variable of string
- | `Unification_failed of string * ttype * ttype (* of core_type * core_type *)
- ]
-
-let print_error (e : error) =
- match e with
- | `No_variable_rec ->
- Printf.printf
- "Recursive binding failed: a function was expected as the RHS. Recursive binding \
- is impossible for that variable. It would lead to infinite recursion."
- | `No_arg_rec ->
- Printf.printf
- "Recursive binding failed: the LHS of the recursive binding must not be a composed \
- pattern (e.g. tuple, list, etc.). A variable is required."
- | `Bound_several_times id ->
- Printf.printf
- "Binding faild: simultaneous binding of one identifier to several values. The \
- identifier that was bound several times: '%s'."
- id
- | `Occurs_check (id, ty) ->
- Printf.printf "Occurs check failed: the type variable %s occurs inside" id;
- print_type ty
- | `No_variable id -> Printf.printf "Undefined variable '%s'" id
- | `Unification_failed (id, ty1, ty2) ->
- Printf.printf "Unification( %s ) failed for following unifiable types: " id;
- print_type ty1;
- Printf.printf " and ";
- print_type ty2
-;;
-
-module State = struct
- open Base
-
- type 'a t = int -> int * ('a, error) Result.t
-
- let return x state = state, Result.return x
- let fail e state = state, Result.fail e
-
- let ( >>= ) (monad : 'a t) (f : 'a -> 'b t) : 'b t =
- fun state ->
- match monad state with
- | state, Result.Ok result -> f result state
- | state, Result.Error e -> fail e state
- ;;
-
- module Syntax = struct
- let ( let* ) = ( >>= )
- end
-
- let ( >>| ) (monad : 'a t) (f : 'a -> 'b) : 'b t =
- fun state ->
- match monad state with
- | state, Result.Ok result -> return (f result) state
- | state, Result.Error e -> fail e state
- ;;
-
- module RList = struct
- let fold_left xs ~init ~f =
- List.fold_left xs ~init ~f:(fun acc x ->
- let open Syntax in
- let* acc = acc in
- f acc x)
- ;;
-
- let fold_right xs ~init ~f =
- List.fold_right xs ~init ~f:(fun x acc ->
- let open Syntax in
- let* acc = acc in
- f x acc)
- ;;
- end
-
- module RMap = struct
- let fold map ~init ~f =
- Map.fold map ~init ~f:(fun ~key ~data acc ->
- let open Syntax in
- let* acc = acc in
- f key data acc)
- ;;
- end
-
- let fresh state = state + 1, Result.Ok state
- let run monad = snd (monad 0)
-end
-
-module VarSet = struct
- include Set.Make (String)
-end
-
-type scheme = Scheme of VarSet.t * ttype
-
-module Type = struct
- (*gets type_core and returns set of idents of all type_core's type variables *)
- let free_vars =
- let rec helper acc = function
- | Type_option (Some ty) | Type_list ty -> helper acc ty
- | Type_var name -> VarSet.add name acc
- | Type_tuple ty_list -> List.fold_left helper acc ty_list
- | Type_arrow (ty1, ty2) -> VarSet.union (helper acc ty1) (helper acc ty2)
- | _ -> acc
- in
- helper VarSet.empty
- ;;
-
- (*gets the identifier and core_type and checks whether a type variable with this identifier occurs in the type*)
- let occurs_in var ty = VarSet.mem var (free_vars ty)
-end
-
-module Subst = struct
- open State
- open State.Syntax
- open Base
-
- let empty = Map.empty (module String)
- let singleton1 = Map.singleton (module String)
-
- (*gets some name of type variable and core_type and checks if an name doesn't occur in a type (bad case of infinite loop)
- and returns wrapped sub*)
- let singleton key value =
- match value with
- | Type_var id when String.equal key id -> return empty
- | _ ->
- if Type.occurs_in key value
- then fail (`Occurs_check (key, value))
- else return (Map.singleton (module String) key value)
- ;;
-
- let remove = Map.remove
-
- (*gets substitution and core_type then performs a substitution and returns new concretized core_type*)
- let apply sub =
- let rec helper = function
- | Type_var name as ty ->
- (match Map.find sub name with
- | Some ty -> ty
- | None -> ty)
- | Type_option (Some ty) -> Type_option (Some (helper ty))
- | Type_list ty -> Type_list (helper ty)
- | Type_tuple ty_list -> Type_tuple (List.map ty_list ~f:helper)
- | Type_arrow (ty1, ty2) -> Type_arrow (helper ty1, helper ty2)
- | ty -> ty
- in
- helper
- ;;
-
- let rec unify (debug_info : string) (l : ttype) (r : ttype) =
- match l, r with
- | Type_unit, Type_unit
- | Type_int, Type_int
- | Type_char, Type_char
- | Type_string, Type_string
- | Type_bool, Type_bool
- | Type_option None, Type_option None
- | Type_option (Some _), Type_option None
- | Type_option None, Type_option (Some _) -> return empty
- | Type_var l, Type_var r when String.equal l r -> return empty
- | Type_var name, ty | ty, Type_var name -> singleton name ty
- | Type_list ty1, Type_list ty2 | Type_option (Some ty1), Type_option (Some ty2) ->
- unify "list_unify" ty1 ty2
- | Type_tuple list1, Type_tuple list2 ->
- let rec helper acc = function
- | first_ty1 :: rest1, first_ty2 :: rest2 ->
- let* acc_sub = acc in
- let* unified_sub =
- unify "tuple_unify" (apply acc_sub first_ty1) (apply acc_sub first_ty2)
- in
- helper (compose acc_sub unified_sub) (rest1, rest2)
- | [], [] -> acc
- | _ -> fail (`Unification_failed (debug_info, l, r))
- (*considering case when list1 and list2 have different lengths*)
- in
- helper (return empty) (list1, list2)
- | Type_arrow (arg1, res1), Type_arrow (arg2, res2) ->
- let* unified_sub1 = unify "([type1] -> [...]) and ([type2] -> [...])" arg1 arg2 in
- let* unified_sub2 =
- unify "arrow_unify_result" (apply unified_sub1 res1) (apply unified_sub1 res2)
- in
- compose unified_sub1 unified_sub2
- | _ -> fail (`Unification_failed (debug_info, l, r))
-
- and extend key value sub =
- match Map.find sub key with
- | None ->
- let value = apply sub value in
- let* new_sub = singleton key value in
- Map.fold sub ~init:(return new_sub) ~f:(fun ~key ~data acc ->
- let* acc = acc in
- let new_data = apply new_sub data in
- return (Map.update acc key ~f:(fun _ -> new_data)))
- | Some existing_value ->
- let* new_sub = unify "extend sub" value existing_value in
- compose sub new_sub
-
- and compose sub1 sub2 = RMap.fold sub2 ~init:(return sub1) ~f:extend
-
- let compose_all sub_list = RList.fold_left sub_list ~init:(return empty) ~f:compose
-end
-
-module Scheme = struct
- let free_vars (Scheme (bind_set, ty)) = VarSet.diff (Type.free_vars ty) bind_set
-
- let apply sub (Scheme (bind_set, ty)) =
- let new_sub = VarSet.fold (fun key sub -> Subst.remove sub key) bind_set sub in
- let new_ty = Subst.apply new_sub ty in
- let is_generalized_type_var id = not (Base.String.is_prefix ~prefix:"'ty" id) in
- let rec extract_id_from_ty acc_set = function
- | Type_var id -> VarSet.add id acc_set
- | Type_option (Some ty) -> extract_id_from_ty acc_set ty
- | Type_tuple ty_list ->
- Base.List.fold_left ty_list ~init:acc_set ~f:(fun acc_set ty ->
- extract_id_from_ty acc_set ty)
- | Type_list ty -> extract_id_from_ty acc_set ty
- | Type_arrow (ty1, ty2) -> extract_id_from_ty (extract_id_from_ty acc_set ty1) ty2
- | _ -> acc_set
- in
- let new_bind_set =
- VarSet.fold
- (fun id new_bind_set ->
- if is_generalized_type_var id then VarSet.add id new_bind_set else new_bind_set)
- (extract_id_from_ty VarSet.empty new_ty)
- VarSet.empty
- in
- Scheme (new_bind_set, new_ty)
- ;;
-end
-
-module TypeEnv = struct
- open Base
-
- type t = (ident, scheme, String.comparator_witness) Map.t
-
- let empty = Map.empty (module String)
- let extend env key value = Map.update env key ~f:(fun _ -> value)
-
- let rec extend_with_pattern env_acc pat (Scheme (bind_set, ty) as scheme) =
- match pat, ty with
- | Pattern_var id, _ -> extend env_acc id scheme
- | Pattern_tuple pat_list, Type_tuple ty_list ->
- (match pat_list, ty_list with
- | first_pat :: pat_rest, first_ty :: ty_rest ->
- let new_acc_env =
- extend_with_pattern env_acc first_pat (Scheme (bind_set, first_ty))
- in
- extend_with_pattern
- new_acc_env
- (Pattern_tuple pat_rest)
- (Scheme (bind_set, Type_tuple ty_rest))
- | _ -> env_acc)
- | Pattern_list_sugar_case pat_list, Type_list ty ->
- Base.List.fold_left pat_list ~init:env_acc ~f:(fun env_acc pat ->
- extend_with_pattern env_acc pat (Scheme (bind_set, ty)))
- | Pattern_list_constructor_case pat_list, Type_list ty ->
- (match pat_list with
- | single_pat :: [] ->
- extend_with_pattern env_acc single_pat (Scheme (bind_set, Type_list ty))
- | first :: rest ->
- extend_with_pattern
- (extend_with_pattern env_acc first (Scheme (bind_set, ty)))
- (Pattern_list_constructor_case rest)
- (Scheme (bind_set, Type_list ty))
- | [] -> env_acc)
- | Pattern_option (Some pat), Type_option (Some ty) ->
- extend_with_pattern env_acc pat (Scheme (bind_set, ty))
- | _ -> env_acc
- ;;
-
- let free_vars env =
- Map.fold env ~init:VarSet.empty ~f:(fun ~key:_ ~data acc ->
- VarSet.union acc (Scheme.free_vars data))
- ;;
-
- let apply sub env = Map.map env ~f:(Scheme.apply sub)
- let find = Map.find
-
- let find_type_exn env key =
- let (Scheme (_, ty)) = Map.find_exn env key in
- ty
- ;;
-end
-
-module Infer = struct
- open Ast
- open State
- open State.Syntax
-
- let unify = Subst.unify
- let fresh_var = fresh >>| fun n -> Type_var ("'ty" ^ Int.to_string n)
-
- let fresh_var_instantiate id =
- (*e.g. 'ty3instantiate_'a *)
- fresh >>| fun n -> Type_var (Printf.sprintf "%s%dinstantiate_%s" "'ty" n id)
- ;;
-
- let instantiate (Scheme (bind_set, ty)) =
- VarSet.fold
- (fun name ty ->
- let* ty = ty in
- let* fresh = fresh_var_instantiate name in
- let* sub = Subst.singleton name fresh in
- return (Subst.apply sub ty))
- bind_set
- (return ty)
- ;;
-
- let generalize ~only_instantiated env ty =
- let free = VarSet.diff (Type.free_vars ty) (TypeEnv.free_vars env) in
- let new_free, new_ty, _ =
- VarSet.fold
- (fun str (temp_free, temp_ty, n) ->
- let degree = n / 26 in
- let new_str =
- if Base.String.is_substring ~substring:"instantiate" str
- then (
- let index = String.index str '_' in
- String.sub str (index + 1) (String.length str - (index + 1)))
- else if only_instantiated
- then str
- else
- (* 97 - is number 'a' in ASCII-table *)
- Printf.sprintf
- "'%c%s"
- (Char.chr (97 + (n mod 26)))
- (if degree = 0 then "" else Int.to_string degree)
- (*new_str : 'a, ... ,'z, 'a1, ... ,'z1, ...*)
- in
- let sub = Subst.singleton1 str (Type_var new_str) in
- let new_free = VarSet.add new_str temp_free in
- let new_ty = Subst.apply sub temp_ty in
- new_free, new_ty, n + 1)
- free
- (VarSet.empty, ty, 0)
- in
- Scheme (new_free, new_ty)
- ;;
-
- let rec extract_names_from_pat f acc = function
- | Pattern_var id -> f acc id
- | Pattern_option (Some pat) -> extract_names_from_pat f acc pat
- | Pattern_tuple pat_list
- | Pattern_list_sugar_case pat_list
- | Pattern_list_constructor_case pat_list ->
- (match pat_list with
- | [] -> return acc
- | first_pat :: rest_pats ->
- let* acc = extract_names_from_pat f acc first_pat in
- extract_names_from_pat f acc (Pattern_tuple rest_pats))
- | _ -> return acc
- ;;
-
- module StringSet = struct
- include Set.Make (String)
-
- let add_id set value =
- if mem value set then fail (`Bound_several_times value) else return (add value set)
- ;;
- end
-
- let rec remove_patterns_from_env env = function
- | [] -> return env
- | pat :: rest_pats ->
- let* env =
- extract_names_from_pat (fun env id -> return (Base.Map.remove env id)) env pat
- in
- remove_patterns_from_env env rest_pats
- ;;
-
- let check_names_from_pat pat =
- extract_names_from_pat StringSet.add_id StringSet.empty pat
- ;;
-
- let rec infer_pattern env pat =
- let* _ = check_names_from_pat pat in
- match pat with
- | Pattern_any ->
- let* fresh_type_var = fresh_var in
- return (env, fresh_type_var)
- | Pattern_var id ->
- let* fresh_type_var = fresh_var in
- let env = TypeEnv.extend env id (Scheme (VarSet.empty, fresh_type_var)) in
- return (env, fresh_type_var)
- | Pattern_const const ->
- (match const with
- | Const_int _ -> return (env, Type_int)
- | Const_string _ -> return (env, Type_string)
- | Const_char _ -> return (env, Type_char)
- | Const_bool _ -> return (env, Type_bool)
- | Const_unit -> return (env, Type_unit))
- | Pattern_tuple pat_list ->
- let* env, list_of_types =
- RList.fold_right
- pat_list
- ~init:(return (env, []))
- ~f:(fun element (env, list_of_types) ->
- let* new_env, element_type = infer_pattern env element in
- return (new_env, element_type :: list_of_types))
- in
- return (env, Type_tuple list_of_types)
- | Pattern_option None -> return (env, Type_option None)
- | Pattern_option (Some pat) ->
- let* env, type_of_pat = infer_pattern env pat in
- return (env, Type_option (Some type_of_pat))
- | Pattern_list_sugar_case pat_list ->
- let* list_element_type_var = fresh_var in
- let* env, sub =
- RList.fold_left
- pat_list
- ~init:(return (env, Subst.empty))
- ~f:(fun (acc_env, acc_sub) pat ->
- let* env, pat_type = infer_pattern acc_env pat in
- let* unified_sub =
- unify "infer pattern list sugar" list_element_type_var pat_type
- in
- let* composed_sub = Subst.compose unified_sub acc_sub in
- return (env, composed_sub))
- in
- let list_element_type = Subst.apply sub list_element_type_var in
- let env = TypeEnv.apply sub env in
- return (env, Type_list list_element_type)
- | Pattern_list_constructor_case pat_list ->
- let* fresh = fresh_var in
- let rec helper env sub_acc rest =
- match rest with
- | [] -> return (env, sub_acc)
- | single :: [] ->
- let* env, ty = infer_pattern env single in
- let* unified_sub = unify "" (Type_list fresh) ty in
- let* composed_sub = Subst.compose sub_acc unified_sub in
- helper env composed_sub []
- | first :: rest ->
- let* env, ty = infer_pattern env first in
- let* unified_sub = unify "" fresh ty in
- let* composed_sub = Subst.compose sub_acc unified_sub in
- helper env composed_sub rest
- in
- let* env, sub = helper env Subst.empty pat_list in
- let result_ty = Subst.apply sub fresh in
- return (env, Type_list result_ty)
- ;;
-
- let rec get_pat_type_from_env env = function
- | Pattern_var id -> return (TypeEnv.find_type_exn env id)
- | Pattern_any -> fresh_var
- | Pattern_const const ->
- (match const with
- | Const_int _ -> return Type_int
- | Const_string _ -> return Type_string
- | Const_char _ -> return Type_char
- | Const_bool _ -> return Type_bool
- | Const_unit -> return Type_unit)
- | Pattern_option (Some pat) ->
- let* ty = get_pat_type_from_env env pat in
- return (Type_option (Some ty))
- | Pattern_tuple pat_list ->
- let* ty_list =
- RList.fold_left pat_list ~init:(return []) ~f:(fun acc_list pat ->
- let* ty = get_pat_type_from_env env pat in
- return (acc_list @ [ ty ]))
- in
- return (Type_tuple ty_list)
- | Pattern_list_sugar_case (first_pat :: _)
- | Pattern_list_constructor_case (first_pat :: _) ->
- let* ty = get_pat_type_from_env env first_pat in
- return (Type_list ty)
- | _ -> return (Type_option None)
- ;;
-
- let extend_env_with_args env args_list =
- RList.fold_right
- args_list
- ~init:(return (env, []))
- ~f:(fun pat (env, pat_ty_list) ->
- let* env, pat_ty = infer_pattern env pat in
- return (env, pat_ty :: pat_ty_list))
- ;;
-
- (*this function is called when we deal with recursive bindings.
- And our language forbids recursive values*)
- let extend_env_with_bind_names env let_binding_list =
- RList.fold_left let_binding_list ~init:(return env) ~f:(fun env ->
- function
- | Let_binding (_, Let_fun (id, _), _) ->
- let* fresh = fresh_var in
- let env = TypeEnv.extend env id (Scheme (VarSet.empty, fresh)) in
- return env
- | Let_binding (_, Let_pattern (Pattern_var id), Expr_anonym_fun (_, _))
- | Let_binding (_, Let_pattern (Pattern_var id), Expr_function_fun _) ->
- let* fresh = fresh_var in
- let env = TypeEnv.extend env id (Scheme (VarSet.empty, fresh)) in
- return env
- | Let_binding (_, Let_pattern (Pattern_var _), _) -> fail `No_variable_rec
- | _ -> fail `No_arg_rec)
- ;;
-
- let rec check_names_from_let_binds =
- RList.fold_left ~init:(return StringSet.empty) ~f:(fun set_acc ->
- function
- | Let_binding (_, Let_fun (fun_identifier, _), _) ->
- StringSet.add_id set_acc fun_identifier
- | Let_binding (_, Let_pattern pat, _) ->
- extract_names_from_pat StringSet.add_id set_acc pat
- | Let_rec_and_binding let_binding_list ->
- let* let_rec_and_acc = check_names_from_let_binds let_binding_list in
- return (StringSet.union set_acc let_rec_and_acc))
- ;;
-
- let rec get_names_from_let_bind env = function
- | Let_binding (_, Let_pattern pat, _) ->
- extract_names_from_pat
- (fun acc id -> return (acc @ [ id, TypeEnv.find_type_exn env id ]))
- []
- pat
- | Let_binding (_, Let_fun (id, _), _) ->
- extract_names_from_pat
- (fun acc id -> return (acc @ [ id, TypeEnv.find_type_exn env id ]))
- []
- (Pattern_var id)
- | Let_rec_and_binding let_binding_list ->
- RList.fold_left
- let_binding_list
- ~init:(return [])
- ~f:(fun result_list let_binding ->
- let* last_element = get_names_from_let_bind env let_binding in
- return (result_list @ last_element))
- ;;
-
- let lookup_env id env =
- match TypeEnv.find env id with
- | Some scheme ->
- let* ans = instantiate scheme in
- return (Subst.empty, ans)
- | None -> fail (`No_variable id)
- ;;
-
- let rec infer_expression env = function
- | Expr_var id -> lookup_env id env
- | Expr_const const ->
- (match const with
- | Const_int _ -> return (Subst.empty, Type_int)
- | Const_string _ -> return (Subst.empty, Type_string)
- | Const_char _ -> return (Subst.empty, Type_char)
- | Const_bool _ -> return (Subst.empty, Type_bool)
- | Const_unit -> return (Subst.empty, Type_unit))
- | Expr_construct_in (let_binding, expression) ->
- (match let_binding with
- | Let_binding (Non_recursive, _, _) ->
- let* env, sub = infer_value_non_rec_binding env let_binding in
- let* expr_sub, expr_ty = infer_expression env expression in
- let* composed_sub = Subst.compose sub expr_sub in
- return (composed_sub, expr_ty)
- | Let_binding (Recursive, _, _) | Let_rec_and_binding _ ->
- let let_binding_list =
- match let_binding with
- | Let_rec_and_binding let_binding_list -> let_binding_list
- | _ -> let_binding :: []
- in
- let* env = extend_env_with_bind_names env let_binding_list in
- let* env, sub1 = infer_rec_value_binding_list env Subst.empty let_binding_list in
- let* sub2, ty2 = infer_expression env expression in
- let* composed_sub = Subst.compose sub2 sub1 in
- return (composed_sub, ty2))
- | Expr_anonym_fun (first_pat :: rest_pats, expr) ->
- let* env, ty1 = infer_pattern env first_pat in
- let* sub, ty2 =
- match rest_pats with
- | [] -> infer_expression env expr
- | hd :: tl -> infer_expression env (Expr_anonym_fun (hd :: tl, expr))
- in
- return (sub, Type_arrow (Subst.apply sub ty1, ty2))
- | Expr_binary_op (bin_op, exp1, exp2) ->
- let* sub1, ty1 = infer_expression env exp1 in
- let* sub2, ty2 = infer_expression (TypeEnv.apply sub1 env) exp2 in
- let* required_arg_ty, required_result_ty =
- match bin_op with
- | Plus | Sub | Mul | Div -> return (Type_int, Type_int)
- | Equal | NotEqual | Less | LessEqual | Greater | GreaterEqual ->
- let* fresh = fresh_var in
- return (fresh, Type_bool)
- | _ -> return (Type_bool, Type_bool)
- in
- let* unified_sub1 =
- Subst.unify "expr binary op1" required_arg_ty (Subst.apply sub2 ty1)
- in
- let* unified_sub2 =
- Subst.unify "expr binary op2" required_arg_ty (Subst.apply unified_sub1 ty2)
- in
- let* composed_sub = Subst.compose_all [ sub1; sub2; unified_sub1; unified_sub2 ] in
- let* sub_expr1_type = unify "" ty1 (Subst.apply composed_sub required_arg_ty) in
- let* sub_expr2_type = unify "" ty2 (Subst.apply composed_sub required_arg_ty) in
- let* composed_sub =
- Subst.compose_all [ sub_expr1_type; sub_expr2_type; composed_sub ]
- in
- return (composed_sub, required_result_ty)
- | Expr_application (expr, expr_list) ->
- let* fresh = fresh_var in
- let rec build_arrow_chain expression_list =
- match expression_list with
- | first_expr :: [] ->
- let* sub, ty = infer_expression env first_expr in
- return (sub, Type_arrow (ty, fresh))
- | first_expr :: expression_list ->
- let* sub1, ty1 = build_arrow_chain expression_list in
- let* sub2, ty2 = infer_expression (TypeEnv.apply sub1 env) first_expr in
- let* composed_sub = Subst.compose sub1 sub2 in
- return (composed_sub, Subst.apply composed_sub (Type_arrow (ty2, ty1)))
- | [] -> return (Subst.empty, Type_option None)
- in
- let* args_sub, required_ty = build_arrow_chain expr_list in
- let* expr_sub, expr_ty = infer_expression (TypeEnv.apply args_sub env) expr in
- let* unified_sub =
- unify "fun application " expr_ty (Subst.apply expr_sub required_ty)
- in
- let* composed_sub = Subst.compose_all [ unified_sub; expr_sub; args_sub ] in
- let final_ty = Subst.apply composed_sub fresh in
- return (composed_sub, final_ty)
- | Expr_function_fun case_list ->
- let* fresh_for_matching = fresh_var in
- let* fresh_for_result = fresh_var in
- infer_match_exp
- env
- ~with_exp:false
- Subst.empty
- fresh_for_matching
- fresh_for_result
- case_list
- | Expr_match_with (expr, case_list) ->
- let* expr_sub, expr_ty = infer_expression env expr in
- let env = TypeEnv.apply expr_sub env in
- let* fresh_for_result = fresh_var in
- infer_match_exp env ~with_exp:true expr_sub expr_ty fresh_for_result case_list
- | Expr_tuple expr_list ->
- let* sub, ty_list =
- RList.fold_right
- ~f:(fun expr (sub_acc, ty_list) ->
- let* sub, ty = infer_expression (TypeEnv.apply sub_acc env) expr in
- let* sub_acc = Subst.compose sub_acc sub in
- return (sub_acc, ty :: ty_list))
- ~init:(return (Subst.empty, []))
- expr_list
- in
- let result_ty = Subst.apply sub (Type_tuple ty_list) in
- return (sub, result_ty)
- | Expr_list_construct expr_list ->
- let* fresh = fresh_var in
- let rec infer_list_constract env acc_sub = function
- | [] -> return (Subst.empty, Type_option None)
- | end_element :: [] ->
- let* expr_sub, expr_ty = infer_expression env end_element in
- let* unified_sub = unify "expr list construct end" expr_ty (Type_list fresh) in
- let* composed_sub = Subst.compose_all [ expr_sub; unified_sub; acc_sub ] in
- return (composed_sub, Type_list (Subst.apply composed_sub fresh))
- | expr_element :: expr_rest ->
- let* expr_sub, expr_ty = infer_expression env expr_element in
- let* unified_sub = unify "expr list construct element" expr_ty fresh in
- let* composed_sub = Subst.compose_all [ expr_sub; unified_sub; acc_sub ] in
- let env = TypeEnv.apply composed_sub env in
- let* sub, ty = infer_list_constract env composed_sub expr_rest in
- return (sub, ty)
- in
- infer_list_constract env Subst.empty expr_list
- | Expr_list_sugar expr_list ->
- let* fresh = fresh_var in
- let* sub =
- RList.fold_left expr_list ~init:(return Subst.empty) ~f:(fun acc_sub expr ->
- let* expr_sub, expr_type = infer_expression (TypeEnv.apply acc_sub env) expr in
- let* unified_sub =
- unify
- "expr list sugar"
- expr_type
- (Subst.apply acc_sub (Subst.apply expr_sub fresh))
- in
- let* composed_sub = Subst.compose_all [ acc_sub; unified_sub; expr_sub ] in
- return composed_sub)
- in
- let fresh = Subst.apply sub fresh in
- return (sub, Type_list fresh)
- | Expr_option None -> return (Subst.empty, Type_option None)
- | Expr_option (Some expr) ->
- let* sub, ty = infer_expression env expr in
- return (sub, Type_option (Some ty))
- | Expr_if_then_else (if_expr, then_expr, else_expr) ->
- let* sub1, ty1 = infer_expression env if_expr in
- let* sub2, ty2 = infer_expression (TypeEnv.apply sub1 env) then_expr in
- let* sub3, ty3 =
- infer_expression (TypeEnv.apply sub2 (TypeEnv.apply sub1 env)) else_expr
- in
- let* sub4 = unify "if (here) then else" ty1 Type_bool in
- let* sub5 = unify "if _ then [first type] else [second type]" ty2 ty3 in
- let* final_sub = Subst.compose_all [ sub5; sub4; sub3; sub2; sub1 ] in
- return (final_sub, Subst.apply final_sub ty2)
- | Typed_expression (ty, expr) ->
- let* expr_sub, expr_ty = infer_expression env expr in
- let* unified_sub = unify "typed expression" expr_ty ty in
- let* final_sub = Subst.compose unified_sub expr_sub in
- return (final_sub, Subst.apply unified_sub expr_ty)
- | _ -> return (Subst.empty, Type_option None)
-
- and infer_match_exp env ~with_exp match_exp_sub match_exp_ty result_ty case_list =
- let* cases_sub, case_ty =
- RList.fold_left
- case_list
- ~init:(return (match_exp_sub, result_ty))
- ~f:(fun (sub_acc, ty_acc) (pat, case_exp) ->
- let* env, pat_sub =
- if with_exp
- then (
- let env = TypeEnv.apply sub_acc env in
- let* _, pat_ty = infer_pattern env pat in
- let* unified_sub1 =
- unify
- "infer_match_exp, match expression"
- pat_ty
- (Subst.apply sub_acc match_exp_ty)
- in
- let gen_pat_ty_sch =
- generalize ~only_instantiated:true env (Subst.apply unified_sub1 pat_ty)
- in
- let env = TypeEnv.extend_with_pattern env pat gen_pat_ty_sch in
- return (env, unified_sub1))
- else
- let* env, pat_ty = infer_pattern env pat in
- let* unified_sub1 = unify "" pat_ty match_exp_ty in
- let env = TypeEnv.apply unified_sub1 env in
- return (env, unified_sub1)
- in
- let* composed_sub1 = Subst.compose sub_acc pat_sub in
- let* case_exp_sub, case_exp_ty =
- infer_expression (TypeEnv.apply composed_sub1 env) case_exp
- in
- let* unified_sub2 =
- unify "infer_match_exp, result expression" ty_acc case_exp_ty
- in
- let* composed_sub2 =
- Subst.compose_all [ composed_sub1; case_exp_sub; unified_sub2 ]
- in
- return (composed_sub2, Subst.apply composed_sub2 ty_acc))
- in
- let final_ty =
- if with_exp
- then case_ty
- else Type_arrow (Subst.apply cases_sub match_exp_ty, case_ty)
- in
- return (cases_sub, final_ty)
-
- and infer_value_non_rec_binding env = function
- | Let_binding (Non_recursive, Let_fun (id, pattern_list), expr) ->
- let* env, _ = extend_env_with_args env pattern_list in
- let* expr_sub, expr_ty = infer_expression env expr in
- let env = TypeEnv.apply expr_sub env in
- let* let_bind_ty =
- let rec build_arrow_chain = function
- | single_ty :: [] -> Type_arrow (single_ty, expr_ty)
- | first_ty :: rest -> Type_arrow (first_ty, build_arrow_chain rest)
- | _ -> expr_ty
- in
- let* pat_types =
- RList.fold_left pattern_list ~init:(return []) ~f:(fun acc_list pat ->
- let* pat_ty = get_pat_type_from_env env pat in
- return (acc_list @ [ pat_ty ]))
- in
- return (build_arrow_chain pat_types)
- in
- let* env = remove_patterns_from_env env pattern_list in
- let generalized_let_bind_ty = generalize ~only_instantiated:false env let_bind_ty in
- let env = TypeEnv.extend env id generalized_let_bind_ty in
- return (env, expr_sub)
- | Let_binding (Non_recursive, Let_pattern pat, expr) ->
- let* expr_sub, expr_ty = infer_expression env expr in
- let env = TypeEnv.apply expr_sub env in
- let* _, pat_ty = infer_pattern env pat in
- let* unified_sub1 = unify "let binding with pattern" expr_ty pat_ty in
- let env = TypeEnv.apply unified_sub1 env in
- let let_pat_ty_sch =
- generalize ~only_instantiated:false env (Subst.apply unified_sub1 expr_ty)
- in
- let (Scheme (_, let_pat_ty)) = let_pat_ty_sch in
- let* env, init_pat_ty = infer_pattern env pat in
- let* unified_sub2 = unify "" init_pat_ty let_pat_ty in
- let env = TypeEnv.apply unified_sub1 env in
- let env = TypeEnv.extend_with_pattern env pat let_pat_ty_sch in
- let* composed_sub = Subst.compose_all [ unified_sub1; unified_sub2; expr_sub ] in
- return (env, composed_sub)
- | Let_binding (Recursive, _, _) | Let_rec_and_binding _ -> return (env, Subst.empty)
-
- and infer_rec_value_binding_list env sub let_binds =
- let infer_rec_vb env new_sub ty id pattern_list rest =
- let env = TypeEnv.apply new_sub env in
- let infered_let_bind_type = TypeEnv.find_type_exn env id in
- (*this type was infered during infering RSH of rec let_biding*)
- let* manual_let_bind_ty =
- (*this type is built by us manually*)
- let rec build_arrow_chain = function
- | single_ty :: [] -> Type_arrow (single_ty, ty)
- | first_ty :: rest -> Type_arrow (first_ty, build_arrow_chain rest)
- | [] -> infered_let_bind_type
- in
- let* pat_types =
- RList.fold_right pattern_list ~init:(return []) ~f:(fun pat pat_ty_list ->
- let* pat_ty = get_pat_type_from_env env pat in
- return (pat_ty :: pat_ty_list))
- in
- return (build_arrow_chain pat_types)
- in
- let* unified_sub =
- unify "rec let binding" manual_let_bind_ty infered_let_bind_type
- in
- let* composed_sub = Subst.compose_all [ new_sub; unified_sub; sub ] in
- let* env = remove_patterns_from_env env (Pattern_var id :: pattern_list) in
- let generalized_let_bind_sch =
- generalize
- ~only_instantiated:false
- env
- (Subst.apply composed_sub manual_let_bind_ty)
- in
- let env = TypeEnv.extend env id generalized_let_bind_sch in
- infer_rec_value_binding_list (TypeEnv.apply composed_sub env) composed_sub rest
- in
- match let_binds with
- | [] -> return (env, sub)
- | Let_binding
- ( Recursive
- , Let_fun (id, [])
- , ((Expr_anonym_fun (_, _) | Expr_function_fun _) as expr) )
- :: rest ->
- let* new_sub, ty = infer_expression env expr in
- infer_rec_vb env new_sub ty id [] rest
- | Let_binding (Recursive, Let_fun (_, []), _) :: _ -> fail `No_variable_rec
- | Let_binding (Recursive, Let_fun (id, pattern_list), expr) :: rest ->
- let* env, _ = extend_env_with_args env pattern_list in
- let* expr_sub, ty = infer_expression env expr in
- infer_rec_vb env expr_sub ty id pattern_list rest
- | _ -> fail `No_variable_rec
-
- and infer_let_biding (env, out_list) let_binding =
- match let_binding with
- | Let_binding (Non_recursive, _, _) ->
- let* env, _ = infer_value_non_rec_binding env let_binding in
- let* id_list = get_names_from_let_bind env let_binding in
- return (env, out_list @ id_list)
- | Let_binding (Recursive, _, _) ->
- let* env = extend_env_with_bind_names env (let_binding :: []) in
- let* env, _ = infer_rec_value_binding_list env Subst.empty (let_binding :: []) in
- let* id_list = get_names_from_let_bind env let_binding in
- return (env, out_list @ id_list)
- | Let_rec_and_binding biding_list ->
- let* _ = check_names_from_let_binds biding_list in
- let* env = extend_env_with_bind_names env biding_list in
- let* env, _ = infer_rec_value_binding_list env Subst.empty biding_list in
- let* id_list =
- RList.fold_left biding_list ~init:(return []) ~f:(fun result_list let_binding ->
- let* last_element = get_names_from_let_bind env let_binding in
- return (result_list @ last_element))
- in
- return (env, out_list @ id_list)
- ;;
-
- let infer_srtucture env ast =
- let* _, out_list = RList.fold_left ast ~init:(return (env, [])) ~f:infer_let_biding in
- let rec remove_duplicates =
- let fun_equal el1 el2 =
- match el1, el2 with
- | (id1, _), (id2, _) -> String.equal id1 id2
- in
- function
- | x :: xs when not (Base.List.mem xs x ~equal:fun_equal) ->
- x :: remove_duplicates xs
- | _ :: xs -> remove_duplicates xs
- | [] -> []
- in
- return (remove_duplicates out_list)
- ;;
-end
-
-let env_with_print_funs =
- let print_fun_list =
- [ "print_int", Scheme (VarSet.empty, Type_arrow (Type_int, Type_unit))
- ; "print_endline", Scheme (VarSet.empty, Type_arrow (Type_string, Type_unit))
- ]
- in
- List.fold_left
- (fun env (id, sch) -> TypeEnv.extend env id sch)
- TypeEnv.empty
- print_fun_list
-;;
-
-let run_inferencer ast = State.run (Infer.infer_srtucture env_with_print_funs ast)
diff --git a/EMigunova/lib/inference.mli b/EMigunova/lib/inference.mli
deleted file mode 100644
index cfd044220..000000000
--- a/EMigunova/lib/inference.mli
+++ /dev/null
@@ -1,43 +0,0 @@
-(** Copyright 2025, Migunova Anastasia *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-
-type error =
- [ `No_variable_rec
- (** Represents an error where a recursive variable is not allowed because that would lead to infinite recursion.
- E.g. [let rec x = x + 1] *)
- | `No_arg_rec
- (** Represents an error where the left-hand side of the recursive binding is not a var.
- E.g. [let rec [ a; b ] = ..] *)
- | `Bound_several_times of string
- (** Represents an error where a pattern bound the variable multiple times.
- E.g. [let x, x = ..] *)
- | `Occurs_check of string * ttype
- (** Represents an occurs check failure.
- This occurs when attempting to unify types, and one type is found to occur within another in a way that violates the rules of type systems.
- E.g. [let rec f x = f] *)
- | `No_variable of string
- (** Represents an error indicating that a variable could not be found in the current scope. *)
- | `Unification_failed of string * ttype * ttype
- (** Represents that type unification has failed.
- This occurs when two types cannot made equivalent during type inference. *)
- ]
-
-(*val pp_error : Format.formatter -> error -> unit*)
-
-module VarSet : sig
- type t = Set.Make(String).t
-end
-
-type scheme = Scheme of VarSet.t * ttype
-
-module TypeEnv : sig
- type t = (ident, scheme, Base.String.comparator_witness) Base.Map.t
-end
-
-val env_with_print_funs : TypeEnv.t
-val print_error : error -> unit
-val print_type : ttype -> unit
-val run_inferencer : let_binding list -> ((ident * ttype) list, error) result
diff --git a/EMigunova/lib/interpreter.ml b/EMigunova/lib/interpreter.ml
deleted file mode 100644
index 16638dbdc..000000000
--- a/EMigunova/lib/interpreter.ml
+++ /dev/null
@@ -1,471 +0,0 @@
-(** Copyright 2025, Migunova Anastasia *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-
-type error =
- [ `Type_error
- | `Division_by_zero
- | `Match_failure
- | `Too_many_args_for_anonym_fun
- | `Too_many_args_for_fun of string
- | `No_variable of string
- ]
-
-let print_error (e : error) =
- match e with
- | `Type_error -> Printf.printf "Type error"
- | `Division_by_zero -> Printf.printf "Division by zero"
- | `Match_failure -> Printf.printf "Matching failure"
- | `Too_many_args_for_fun id -> Printf.printf "Too many arguments for function '%s'" id
- | `Too_many_args_for_anonym_fun ->
- Printf.printf "Too many arguments for anonym function"
- | `No_variable id -> Printf.printf "Undefined variable '%s'" id
-;;
-
-type value =
- | Val_integer of int
- | Val_char of char
- | Val_string of string
- | Val_unit
- | Val_bool of bool
- | Val_fun of rec_flag * ident list option * pattern list * expression * env
- | Val_function of (pattern * expression) list * env
- | Val_tuple of value list
- | Val_list of value list
- | Val_option of value option
- | Val_builtin of string
-
-and env = (string, value, Base.String.comparator_witness) Base.Map.t
-
-let rec print_value = function
- | Val_integer int -> Printf.printf "%i" int
- | Val_char char -> Printf.printf "'%c'" char
- | Val_string str -> Printf.printf "%S" str
- | Val_unit -> Printf.printf "()"
- | Val_bool bool -> Printf.printf "%b" bool
- | Val_tuple val_list ->
- Printf.printf "(";
- let rec help = function
- | first :: [] -> print_value first
- | first :: rest ->
- print_value first;
- Printf.printf ", ";
- help rest
- | _ -> ()
- in
- help val_list;
- Printf.printf ")"
- | Val_fun _ -> Printf.printf ""
- | Val_function _ -> Printf.printf ""
- | Val_list val_list ->
- let rec help = function
- | [] -> ()
- | single :: [] -> print_value single
- | first :: rest ->
- print_value first;
- Printf.printf "; ";
- help rest
- in
- Printf.printf "[";
- help val_list;
- Printf.printf "]"
- | Val_option value ->
- (match value with
- | Some value ->
- Printf.printf "Some ";
- print_value value
- | None -> Printf.printf "None")
- | Val_builtin _ -> Printf.printf ""
-
-and print_env env =
- Printf.printf "Type enviroment: \n";
- Base.Map.iteri env ~f:(fun ~key ~data ->
- Printf.printf "val %s : " key;
- print_value data;
- Printf.printf "\n");
- Printf.printf "\n"
-;;
-
-module Res = struct
- open Base
-
- type 'a t = ('a, error) Result.t
-
- let fail = Result.fail
- let return = Result.return
-
- let ( >>= ) (monad : 'a t) (f : 'a -> 'b t) : 'b t =
- match monad with
- | Ok result -> f result
- | Error x -> fail x
- ;;
-
- let ( let* ) = ( >>= )
-end
-
-module EvalEnv = struct
- open Base
-
- let empty = Map.empty (module String)
- let extend env key value = Map.update env key ~f:(fun _ -> value)
-
- let find_exn env key =
- match Map.find env key with
- | Some value -> Res.return value
- | None -> Res.fail (`No_variable key)
- ;;
-
- let find_exn1 env key =
- let val' = Map.find_exn env key in
- val'
- ;;
-end
-
-module Inter = struct
- open Ast
- open Res
- open EvalEnv
-
- let eval_arith opr val1 val2 = return (Val_integer (opr val1 val2))
- let eval_eq opr val1 val2 = return (Val_bool (opr val1 val2))
- let eval_bool opr val1 val2 = return (Val_bool (opr val1 val2))
-
- let eval_bin_op = function
- | Mul, Val_integer val1, Val_integer val2 -> eval_arith ( * ) val1 val2
- | Div, Val_integer val1, Val_integer val2 when val2 <> 0 -> eval_arith ( / ) val1 val2
- | Div, _, Val_integer 0 -> fail `Division_by_zero
- | Plus, Val_integer val1, Val_integer val2 -> eval_arith ( + ) val1 val2
- | Sub, Val_integer val1, Val_integer val2 -> eval_arith ( - ) val1 val2
- | GreaterEqual, val1, val2 -> eval_eq ( >= ) val1 val2
- | LessEqual, val1, val2 -> eval_eq ( <= ) val1 val2
- | NotEqual, val1, val2 -> eval_eq ( <> ) val1 val2
- | Equal, val1, val2 -> eval_eq ( = ) val1 val2
- | Greater, val1, val2 -> eval_eq ( > ) val1 val2
- | Less, val1, val2 -> eval_eq ( < ) val1 val2
- | And, Val_bool val1, Val_bool val2 -> eval_bool ( && ) val1 val2
- | Or, Val_bool val1, Val_bool val2 -> eval_bool ( || ) val1 val2
- | _ -> fail `Type_error
- ;;
-
- let rec match_pattern env = function
- | Pattern_any, _ -> Some env
- | Pattern_const Const_unit, _ -> Some env
- | Pattern_option None, Val_option None -> Some env
- | Pattern_var name, value -> Some (extend env name value)
- | Pattern_const (Const_int pat), Val_integer value when pat = value -> Some env
- | Pattern_const (Const_char pat), Val_char value when pat = value -> Some env
- | Pattern_const (Const_string pat), Val_string value when pat = value -> Some env
- | Pattern_const (Const_bool pat), Val_bool value when pat = value -> Some env
- | Pattern_tuple pat_list, Val_tuple val_list ->
- let env =
- Base.List.fold2
- ~f:(fun env pat value ->
- match env with
- | Some env -> match_pattern env (pat, value)
- | None -> None)
- ~init:(Some env)
- pat_list
- val_list
- in
- (match env with
- | Ok env -> env
- | _ -> None)
- | Pattern_list_sugar_case pat_list, Val_list val_list ->
- (match pat_list, val_list with
- | [], [] -> Some env
- | first_pat :: rest_pat, first_val :: rest_val ->
- let env = match_pattern env (first_pat, first_val) in
- (match env with
- | Some env ->
- match_pattern env (Pattern_list_sugar_case rest_pat, Val_list rest_val)
- | None -> None)
- | _ -> None)
- | Pattern_list_constructor_case pat_list, Val_list val_list ->
- (match pat_list, val_list with
- | single_pat :: [], val_list -> match_pattern env (single_pat, Val_list val_list)
- | _ :: _ :: _, [] -> None
- | first_pat :: rest_pat, first_val :: rest_val ->
- let env = match_pattern env (first_pat, first_val) in
- (match env with
- | Some env ->
- match_pattern env (Pattern_list_constructor_case rest_pat, Val_list rest_val)
- | None -> None)
- | _ -> None)
- | Pattern_option (Some pat), Val_option (Some value) -> match_pattern env (pat, value)
- | _ -> None
- ;;
-
- let rec extend_names_from_pat env = function
- | Pattern_any, _ -> return env
- | Pattern_const Const_unit, Val_unit -> return env
- | Pattern_option None, Val_option None -> return env
- | Pattern_var id, value -> return (extend env id value)
- | Pattern_tuple pat_list, Val_tuple val_list ->
- (match
- Base.List.fold2 pat_list val_list ~init:(return env) ~f:(fun acc pat value ->
- let* env = acc in
- extend_names_from_pat env (pat, value))
- with
- | Ok acc -> acc
- | _ -> fail `Type_error)
- | Pattern_list_sugar_case pat_list, Val_list val_list ->
- (match pat_list, val_list with
- | first_pat :: rest_pat, first_val :: rest_val ->
- let* env = extend_names_from_pat env (first_pat, first_val) in
- let* env =
- extend_names_from_pat env (Pattern_list_sugar_case rest_pat, Val_list rest_val)
- in
- return env
- | _, _ -> return env)
- | Pattern_list_constructor_case pat_list, Val_list val_list ->
- (match pat_list, val_list with
- | first_pat :: rest_pat, first_val :: rest_val ->
- let* env = extend_names_from_pat env (first_pat, first_val) in
- let* env =
- extend_names_from_pat
- env
- (Pattern_list_constructor_case rest_pat, Val_list rest_val)
- in
- return env
- | _, _ -> return env)
- | Pattern_option (Some pat), Val_option (Some value) ->
- extend_names_from_pat env (pat, value)
- | _ -> fail `Type_error
- ;;
-
- let rec eval_expression env = function
- | Expr_var id -> find_exn env id
- | Expr_const const ->
- (match const with
- | Const_int int -> return (Val_integer int)
- | Const_char char -> return (Val_char char)
- | Const_string str -> return (Val_string str)
- | Const_bool bool -> return (Val_bool bool)
- | Const_unit -> return Val_unit)
- | Expr_construct_in (let_binding, expr) ->
- let* env = eval_value_binding env let_binding in
- eval_expression env expr
- | Expr_anonym_fun (pat_list, expr) ->
- return (Val_fun (Non_recursive, None, pat_list, expr, env))
- | Expr_binary_op (op, exp1, exp2) ->
- let* value1 = eval_expression env exp1 in
- let* value2 = eval_expression env exp2 in
- eval_bin_op (op, value1, value2)
- | Expr_application (exp, expr_list) ->
- let* fun_val = eval_expression env exp in
- let val_list = Base.List.map expr_list ~f:(fun expr -> eval_expression env expr) in
- let rec help_fun val_list = function
- | Val_fun (rec_flag, ident, pat_list, expr, fun_env) ->
- let fun_env =
- match ident, rec_flag with
- | Some ident_list, Recursive ->
- Base.List.fold_left ident_list ~init:fun_env ~f:(fun acc_env ident ->
- EvalEnv.extend acc_env ident (EvalEnv.find_exn1 env ident))
- | _ -> fun_env
- in
- let rec helper pat_list val_list fun_env =
- match pat_list, val_list with
- | _ :: _, [] ->
- return (Val_fun (Non_recursive, ident, pat_list, expr, fun_env))
- | first_pat :: rest_pat, first_val :: rest_val ->
- let* arg_val = first_val in
- let new_fun_env = match_pattern fun_env (first_pat, arg_val) in
- (match new_fun_env with
- | Some new_fun_env -> helper rest_pat rest_val new_fun_env
- | None -> fail `Match_failure)
- | [], _ :: _ ->
- let* partial_application_val = eval_expression fun_env expr in
- help_fun val_list partial_application_val
- | [], [] ->
- let _ =
- match ident with
- | Some (first :: []) -> first
- | Some _ -> "several_idents"
- | _ -> "no_ident"
- in
- eval_expression fun_env expr
- in
- helper pat_list val_list fun_env
- | Val_function (case_list, env) ->
- (match expr_list with
- | [] -> return fun_val
- | single :: [] ->
- let* arg_val = eval_expression env single in
- find_and_eval_case env arg_val case_list
- | _ -> fail `Too_many_args_for_anonym_fun)
- | Val_builtin builtin ->
- (match val_list with
- | [] -> return fun_val
- | single :: [] ->
- let* arg_val = single in
- (match builtin, arg_val with
- | "print_int", Val_integer integer ->
- print_int integer;
- Printf.printf "\n";
- (*to make the manytests results readable*)
- return Val_unit
- | "print_endline", Val_string str ->
- print_endline str;
- return Val_unit
- | _ -> fail `Type_error)
- | _ -> fail (`Too_many_args_for_fun builtin))
- | _ -> fail `Type_error
- in
- help_fun val_list fun_val
- | Expr_function_fun case_list -> return (Val_function (case_list, env))
- | Expr_match_with (expr, case_list) ->
- let* match_value = eval_expression env expr in
- find_and_eval_case env match_value case_list
- | Expr_tuple expr_list ->
- let* val_list =
- Base.List.fold_right
- ~f:(fun exp acc ->
- let* acc = acc in
- let* value = eval_expression env exp in
- return (value :: acc))
- ~init:(return [])
- expr_list
- in
- return (Val_tuple val_list)
- | Expr_list_sugar expr_list ->
- let* val_list =
- Base.List.fold_right
- ~f:(fun exp acc ->
- let* acc = acc in
- let* value = eval_expression env exp in
- return (value :: acc))
- ~init:(return [])
- expr_list
- in
- return (Val_list val_list)
- | Expr_list_construct expr_list ->
- let rec helper acc_list = function
- | [] -> eval_expression env (Expr_list_sugar [])
- | single_expr :: [] ->
- let* value = eval_expression env single_expr in
- (match value with
- | Val_list val_list -> return (Val_list (acc_list @ val_list))
- | _ -> return (Val_list []))
- | first_expr :: rest_exprs ->
- let* value = eval_expression env first_expr in
- helper (acc_list @ [ value ]) rest_exprs
- in
- helper [] expr_list
- | Expr_option (Some expr) ->
- let* value = eval_expression env expr in
- return (Val_option (Some value))
- | Expr_option None -> return (Val_option None)
- | Expr_if_then_else (if_expr, then_expr, else_expr) ->
- let* if_value = eval_expression env if_expr in
- (match if_value with
- | Val_bool true -> eval_expression env then_expr
- | Val_bool false -> eval_expression env else_expr
- | _ -> fail `Type_error)
- | Typed_expression (_, expr) -> eval_expression env expr
-
- and find_and_eval_case env value = function
- | [] -> fail `Match_failure
- | (pat, expr) :: rest_cases ->
- let env_temp = match_pattern env (pat, value) in
- (match env_temp with
- | Some env -> eval_expression env expr
- | None -> find_and_eval_case env value rest_cases)
-
- and eval_value_binding env = function
- | Let_binding (rec_flag, Let_fun (id, pat_list), expr) ->
- (match pat_list with
- | _ :: _ ->
- let env = extend env id (Val_fun (rec_flag, Some [ id ], pat_list, expr, env)) in
- return env
- | [] ->
- let* value = eval_expression env expr in
- let env = extend env id value in
- return env)
- | Let_binding (_, Let_pattern pat, expr) ->
- let* value = eval_expression env expr in
- let* env = extend_names_from_pat env (pat, value) in
- return env
- | Let_rec_and_binding binding_list ->
- let list_of_names =
- Base.List.fold_left binding_list ~init:[] ~f:(fun acc_list ->
- function
- | Let_binding (_, Let_fun (id, _), _) -> acc_list @ [ id ]
- | _ -> acc_list)
- in
- Base.List.fold_left binding_list ~init:(return env) ~f:(fun acc_env let_binding ->
- let* env = acc_env in
- let* env = eval_value_binding env let_binding in
- match let_binding with
- | Let_binding (_, Let_fun (id, _), _) ->
- let added_value = EvalEnv.find_exn1 env id in
- (match added_value with
- | Val_fun (Recursive, Some _, pat_list, expr, fun_env) ->
- let env =
- extend
- env
- id
- (Val_fun (Recursive, Some list_of_names, pat_list, expr, fun_env))
- in
- let _ = print_env in
- return env
- | _ -> return env)
- | _ -> return env)
- ;;
-
- let eval_let_bind env out_list value_binding =
- let rec extract_names_from_pat env acc = function
- | Pattern_var id -> acc @ [ id, EvalEnv.find_exn1 env id ]
- | Pattern_tuple pat_list
- | Pattern_list_sugar_case pat_list
- | Pattern_list_constructor_case pat_list ->
- Base.List.fold_left pat_list ~init:acc ~f:(extract_names_from_pat env)
- | Pattern_option (Some pat) -> extract_names_from_pat env acc pat
- | _ -> acc
- in
- let rec get_names_from_let_binds env = function
- | Let_binding (_, Let_fun (id, _), _) -> [ id, EvalEnv.find_exn1 env id ]
- | Let_binding (_, Let_pattern pat, _) -> extract_names_from_pat env [] pat
- | Let_rec_and_binding binding_list ->
- Base.List.fold_left binding_list ~init:[] ~f:(fun acc_list let_binding ->
- acc_list @ get_names_from_let_binds env let_binding)
- in
- let* env = eval_value_binding env value_binding in
- let eval_list = get_names_from_let_binds env value_binding in
- return (env, out_list @ eval_list)
- ;;
-
- let eval_structure env ast =
- let* _, out_list =
- Base.List.fold_left
- ~f:(fun acc let_bind ->
- let* env, out_list = acc in
- let* env, out_list = eval_let_bind env out_list let_bind in
- return (env, out_list))
- ~init:(return (env, []))
- ast
- in
- let rec remove_duplicates =
- let fun_equal el1 el2 =
- match el1, el2 with
- | (id1, _), (id2, _) -> String.equal id1 id2
- in
- function
- | x :: xs when not (Base.List.mem xs x ~equal:fun_equal) ->
- x :: remove_duplicates xs
- | _ :: xs -> remove_duplicates xs
- | [] -> []
- in
- return (remove_duplicates out_list)
- ;;
-end
-
-let empty_env = EvalEnv.empty
-
-let env_with_print_funs =
- let env = EvalEnv.extend empty_env "print_int" (Val_builtin "print_int") in
- EvalEnv.extend env "print_endline" (Val_builtin "print_endline")
-;;
-
-let run_interpreter ast = Inter.eval_structure env_with_print_funs ast
diff --git a/EMigunova/lib/interpreter.mli b/EMigunova/lib/interpreter.mli
deleted file mode 100644
index c7bd2ceec..000000000
--- a/EMigunova/lib/interpreter.mli
+++ /dev/null
@@ -1,33 +0,0 @@
-(** Copyright 2025, Migunova Anastasia *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-
-type error =
- [ `Type_error
- | `Division_by_zero
- | `Match_failure
- | `Too_many_args_for_anonym_fun
- | `Too_many_args_for_fun of string
- | `No_variable of string
- ]
-
-type value =
- | Val_integer of int
- | Val_char of char
- | Val_string of string
- | Val_unit
- | Val_bool of bool
- | Val_fun of rec_flag * ident list option * pattern list * expression * env
- | Val_function of (pattern * expression) list * env
- | Val_tuple of value list
- | Val_list of value list
- | Val_option of value option
- | Val_builtin of string
-
-and env = (string, value, Base.String.comparator_witness) Base.Map.t
-
-val print_value : value -> unit
-val print_error : error -> unit
-val run_interpreter : let_binding list -> ((ident * value) list, error) result
diff --git a/EMigunova/lib/parse.ml b/EMigunova/lib/parse.ml
deleted file mode 100644
index 5fd8c6a9e..000000000
--- a/EMigunova/lib/parse.ml
+++ /dev/null
@@ -1,604 +0,0 @@
-(** Copyright 2025, Migunova Anastasia *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Angstrom
-open Ast
-
-let is_char = function
- | 'A' .. 'Z' | 'a' .. 'z' -> true
- | _ -> false
-;;
-
-let is_digit = function
- | '0' .. '9' -> true
- | _ -> false
-;;
-
-let is_sep = function
- | ' ' | '\t' | '\n' | '\r' -> true
- | _ -> false
-;;
-
-let is_keyword = function
- | "let"
- | "rec"
- | "and"
- | "fun"
- | "if"
- | "then"
- | "else"
- | "match"
- | "with"
- | "in"
- | "true"
- | "false"
- | "Some"
- | "None"
- | "type"
- | "val"
- | "function"
- | "_" -> true
- | _ -> false
-;;
-
-let skip_sep = skip_while is_sep
-let trim t = skip_sep *> t <* skip_sep
-let token t = skip_sep *> string t <* skip_sep
-let round_par p = token "(" *> p <* token ")"
-let square_par p = token "[" *> p <* token "]"
-let round_par_many t = fix (fun p -> trim t <|> round_par p)
-let round_par_many1 t = round_par_many (round_par t)
-
-let parse_id =
- let* p_first = satisfy is_char <|> satisfy (Char.equal '_') >>| Char.escaped in
- let* p_rest =
- take_while1 (fun ch -> is_char ch || is_digit ch || Char.equal '_' ch) <|> return ""
- in
- let id = p_first ^ p_rest in
- if is_keyword id
- then fail "Error! parse_id: id must not match the keyword."
- else if id = "_"
- then fail "wildcard \"_\" not expected"
- else return id
-;;
-
-let parse_int = trim @@ take_while1 is_digit >>| fun x -> Const_int (int_of_string x)
-
-let parse_char =
- let* char = token "'" *> any_char <* token "'" in
- return @@ Const_char char
-;;
-
-let parse_str =
- let p_empty_string = trim @@ string "\"\"" <|> string "{||}" >>| fun _ -> "" in
- let p_content =
- choice
- [ trim @@ (string "{|" *> take_till (Char.equal '|')) <* string "|}"
- ; trim @@ (string "\"" *> take_till (Char.equal '\"')) <* token "\""
- ]
- in
- let* str = p_empty_string <|> p_content in
- return @@ Const_string str
-;;
-
-let parse_bool =
- let* bool = choice [ token "true" *> return true; token "false" *> return false ] in
- return @@ Const_bool bool
-;;
-
-let parse_unit =
- let* _ = token "()" in
- return @@ Const_unit
-;;
-
-let parse_const = choice [ parse_int; parse_char; parse_str; parse_bool; parse_unit ]
-
-(* -------parse patterns------ *)
-
-let parse_any_pattern =
- let* _ = trim @@ satisfy (fun ch -> Char.equal '_' ch) in
- return @@ Pattern_any
-;;
-
-let parse_var_pattern =
- let* var = trim parse_id in
- return @@ Pattern_var var
-;;
-
-let parse_const_pattern =
- let parse_neg_int =
- trim @@ (token "-" *> take_while1 is_digit >>| fun x -> Const_int (-int_of_string x))
- in
- let* const = trim @@ (parse_const <|> parse_neg_int) in
- return @@ Pattern_const const
-;;
-
-let parse_base_pattern =
- choice [ parse_var_pattern; parse_any_pattern; parse_const_pattern ]
-;;
-
-let parse_list_sugar_case_pattern parse_pattern =
- let empty_list_parser =
- let* _ = token "[" *> token "]" in
- return @@ Pattern_list_sugar_case []
- in
- let list_single_parser =
- let* pat = token "[" *> parse_pattern <* token "]" in
- return @@ Pattern_list_sugar_case [ pat ]
- in
- let list_parser =
- let* _ = token "[" in
- let* first = parse_pattern in
- let* rest = many1 (token ";" *> parse_pattern) in
- let* _ = token "]" in
- return @@ Pattern_list_sugar_case (first :: rest)
- in
- empty_list_parser <|> list_single_parser <|> list_parser
-;;
-
-let parse_list_construct_case_pattern parse_pattern =
- let* first = parse_pattern in
- let* rest = many1 @@ (token "::" *> parse_pattern) in
- return @@ Pattern_list_constructor_case (first :: rest)
-;;
-
-let parse_tuple_pattern parse_pattern =
- let* first = parse_pattern in
- let* rest = many1 @@ (token "," *> parse_pattern) in
- return @@ Pattern_tuple (first :: rest)
-;;
-
-let parse_option_pattern parser_for_argument_of_some =
- let parser_some =
- let* pattern_some = token "Some" *> parser_for_argument_of_some in
- return @@ Pattern_option (Some pattern_some)
- in
- let parser_none =
- let* _ = token "None" in
- return @@ Pattern_option None
- in
- parser_some <|> parser_none
-;;
-
-let parse_pattern =
- fix
- @@ fun parse_pattern ->
- round_par_many
- @@
- let parse_option_argument =
- fix
- @@ fun parse_option_argument ->
- round_par_many
- @@ choice
- [ parse_base_pattern
- ; parse_option_pattern parse_option_argument
- ; parse_list_sugar_case_pattern parse_pattern
- ]
- <|> round_par_many1 parse_pattern
- in
- let parse_list_construct_element =
- round_par_many
- @@ choice
- [ parse_base_pattern
- ; parse_option_pattern parse_option_argument
- ; parse_list_sugar_case_pattern parse_pattern
- ]
- <|> round_par_many1 parse_pattern
- in
- let parse_tuple_element =
- round_par_many
- @@ choice
- [ parse_list_construct_case_pattern parse_list_construct_element
- ; parse_base_pattern
- ; parse_option_pattern parse_option_argument
- ; parse_list_sugar_case_pattern parse_pattern
- ]
- <|> round_par_many1 parse_pattern
- in
- round_par_many
- @@ choice
- [ parse_tuple_pattern parse_tuple_element
- ; parse_list_construct_case_pattern parse_list_construct_element
- ; parse_base_pattern
- ; parse_option_pattern parse_option_argument
- ; parse_list_sugar_case_pattern parse_pattern
- ]
-;;
-
-let parse_expr_var =
- let* var = parse_id in
- return @@ Expr_var var
-;;
-
-let parse_expr_const =
- let* const = parse_const in
- return @@ Expr_const const
-;;
-
-let parse_expr_list_sugar parse_expr =
- let empty_list_parse = token "[" *> token "]" *> (return @@ Expr_list_sugar []) in
- let non_empty_list_parse =
- square_par
- @@
- let* first = parse_expr in
- let* other = many (token ";" *> parse_expr) in
- return @@ Expr_list_sugar (first :: other)
- in
- empty_list_parse <|> non_empty_list_parse
-;;
-
-let parse_expr_option parse_expression =
- fix
- @@ fun parse_expr_option ->
- let parse_some =
- let* _ = token "Some" in
- let* argument =
- round_par_many
- @@ choice
- [ parse_expr_const; parse_expr_var; parse_expr_list_sugar parse_expression ]
- <|> round_par_many1 @@ choice [ parse_expr_option; parse_expression ]
- in
- return @@ Expr_option (Some argument)
- in
- let parse_none =
- let* _ = token "None" in
- return @@ Expr_option None
- in
- parse_some <|> parse_none
-;;
-
-let parse_expr_base_elements parse_expression =
- round_par_many
- @@ choice
- [ parse_expr_const
- ; parse_expr_var
- ; parse_expr_option parse_expression
- ; parse_expr_list_sugar parse_expression
- ]
-;;
-
-(*let's add ability to specify type annotations*)
-
-let parse_type =
- fix
- @@ fun parse_type ->
- let base_type_parser =
- round_par_many
- @@ choice
- [ token "int" *> return Type_int
- ; token "char" *> return Type_char
- ; token "bool" *> return Type_bool
- ; token "string" *> return Type_string
- ; token "unit" *> return Type_unit
- ]
- in
- let tuple_type_parser parser_tuple_element_type =
- round_par_many
- @@
- let* first = parser_tuple_element_type in
- let* rest = many1 @@ (token "*" *> parser_tuple_element_type) in
- return (Type_tuple (first :: rest))
- in
- let parser_tuple_element_type =
- round_par_many (base_type_parser <|> round_par_many1 parse_type)
- in
- let list_type_parser =
- fix
- @@ fun list_type_parser ->
- let* element_type =
- choice
- @@ [ tuple_type_parser parser_tuple_element_type
- ; base_type_parser
- ; round_par_many1 list_type_parser
- ]
- in
- let rec list_type_parser element_type =
- (let* _ = token "list" in
- list_type_parser (Type_list element_type))
- <|> return element_type
- in
- list_type_parser element_type
- in
- choice
- [ list_type_parser; tuple_type_parser parser_tuple_element_type; base_type_parser ]
-;;
-
-let type_annotation expression_parser =
- (round_par_many1
- @@
- let* expression = expression_parser in
- let* ttype = token ":" *> parse_type in
- return @@ Typed_expression (ttype, expression))
- <|> round_par_many expression_parser
-;;
-
-let type_annotation1 expression_parser =
- round_par_many1
- @@
- let* expression = expression_parser in
- let* ttype = token ":" *> parse_type in
- return @@ Typed_expression (ttype, expression)
-;;
-
-(* ----if then else parser------ *)
-
-let parse_if_when_else parse_expression =
- let* if_condition = token "if" *> parse_expression in
- let* then_expression = token "then" *> parse_expression in
- let* else_expression =
- token "else" *> parse_expression <|> return @@ Expr_const Const_unit
- in
- return @@ Expr_if_then_else (if_condition, then_expression, else_expression)
-;;
-
-(* --- match with parser --- *)
-
-let parse_match_with parse_expression =
- let* compared_expression = token "match" *> parse_expression <* token "with" in
- let* pattern_first = (token "|" <|> return "") *> parse_pattern in
- let* return_expression_first = token "->" *> parse_expression in
- let parser_rest =
- token "|" *> parse_pattern
- >>= fun first_element ->
- token "->" *> parse_expression >>| fun second_element -> first_element, second_element
- in
- let* rest = many parser_rest in
- return
- @@ Expr_match_with
- (compared_expression, (pattern_first, return_expression_first) :: rest)
-;;
-
-(* ---let-binding parser--- *)
-
-let parse_rec_flag =
- let recursive = token "let " *> token "rec " >>= fun _ -> return Recursive in
- let non_recursive = token "let " >>= fun _ -> return Non_recursive in
- recursive <|> non_recursive
-;;
-
-let parse_let_declaration =
- let parser_fun_case =
- let* fun_ident = parse_id in
- let* arguments_list = many parse_pattern <* token "=" in
- return @@ Let_fun (fun_ident, arguments_list)
- in
- let parser_pattern_case =
- parse_pattern <* token "=" >>= fun pattern -> return @@ Let_pattern pattern
- in
- parser_fun_case <|> parser_pattern_case
-;;
-
-let parse_let_biding parse_expression =
- let* rec_flag = parse_rec_flag in
- let* let_declaration = parse_let_declaration in
- let* let_definition = parse_expression in
- return @@ Let_binding (rec_flag, let_declaration, let_definition)
-;;
-
-(* ---parser of mutually recursive let-bindings--- *)
-
-let parse_let_rec_and_binding parse_expression =
- let parse_first =
- let* _ = token "let" *> token "rec" in
- let* let_declaration = parse_let_declaration in
- let* let_definition = parse_expression in
- return @@ Let_binding (Recursive, let_declaration, let_definition)
- in
- let parse_one_of_rest =
- let* _ = token "and" in
- let* let_declaration = parse_let_declaration in
- let* let_definition = parse_expression in
- return @@ Let_binding (Recursive, let_declaration, let_definition)
- in
- let* first = parse_first in
- let* rest = many1 parse_one_of_rest in
- return @@ Let_rec_and_binding (first :: rest)
-;;
-
-(* ---in-construction parser--- *)
-
-let parse_in_construction parse_expression =
- let* parse_let_biding = parse_let_biding parse_expression in
- let* parse_expression = token "in" *> parse_expression in
- return @@ Expr_construct_in (parse_let_biding, parse_expression)
-;;
-
-(* ---anonymous function with keyword "fun" parser--- *)
-
-let parse_anonymouse_fun parse_expression =
- let parse_argument =
- round_par_many
- @@ choice
- @@ [ parse_base_pattern
- ; parse_list_sugar_case_pattern parse_pattern
- ; token "None" *> (return @@ Pattern_option None)
- ]
- <|> round_par_many1 parse_pattern
- in
- let* list_of_arguments = token "fun" *> many1 parse_argument in
- let* parse_expression = token "->" *> round_par_many parse_expression in
- return @@ Expr_anonym_fun (list_of_arguments, parse_expression)
-;;
-
-(* ---anonymous function with keyword "function" parser--- *)
-
-let parse_function_fun parse_expression =
- let* _ = token "function" in
- let* pattern_first = (token "|" <|> return "") *> parse_pattern in
- let* return_expression_first = token "->" *> parse_expression in
- let parser_one_matching =
- token "|" *> parse_pattern
- >>= fun first_element ->
- token "->" *> parse_expression >>| fun second_element -> first_element, second_element
- in
- let* rest = many parser_one_matching in
- return @@ Expr_function_fun ((pattern_first, return_expression_first) :: rest)
-;;
-
-(* ---application parser---*)
-
-let parse_application parse_expression =
- round_par_many
- @@
- let parse_application_element =
- round_par_many
- @@ choice
- @@ [ parse_expr_const; parse_expr_var; parse_expr_list_sugar parse_expression ]
- <|> round_par_many1 parse_expression
- <|> type_annotation1 parse_expression
- in
- let* first = parse_application_element in
- let* rest = many1 parse_application_element in
- return @@ Expr_application (first, rest)
-;;
-
-let parse_bin_op_T1 = token "||" *> return Or
-let parse_bin_op_T2 = token "&&" *> return And
-
-let parse_bin_op_T3 =
- choice
- [ token "=" *> return Equal
- ; token "<=" *> return LessEqual
- ; token ">=" *> return GreaterEqual
- ; token ">" *> return Greater
- ; token "<" *> return Less
- ; (token "!=" <|> token "<>") *> return NotEqual
- ]
-;;
-
-let parse_bin_op_T4 = choice [ token "+" *> return Plus; token "-" *> return Sub ]
-let parse_bin_op_T5 = choice [ token "*" *> return Mul; token "/" *> return Div ]
-
-(* ---------binary operators parser--------- *)
-
-let parse_bin_op_expression parse_expression =
- let parse_expr_base =
- parse_application parse_expression
- <|> parse_expr_base_elements parse_expression
- <|> round_par_many1 parse_expression
- <|> type_annotation1 parse_expression
- >>= fun result -> return result > "base"
- in
- let parse_expr_mul_div =
- let* first_operand = parse_expr_base in
- let rec parse_mul_div_chain left_expression =
- (let* operator = parse_bin_op_T5 in
- let* right_expression = parse_expr_base in
- parse_mul_div_chain @@ Expr_binary_op (operator, left_expression, right_expression))
- <|> return left_expression
- > "mul div"
- in
- parse_mul_div_chain first_operand
- in
- let parse_expr_add_sub =
- let rec parse_add_sub_chain left_expression =
- (let* operator = parse_bin_op_T4 in
- let* right_expression = parse_expr_mul_div in
- parse_add_sub_chain @@ Expr_binary_op (operator, left_expression, right_expression))
- <|> return left_expression
- in
- (let* first_operand = parse_expr_mul_div in
- parse_add_sub_chain first_operand)
- <|>
- (*implemention of negative int*)
- let* operator = parse_bin_op_T4 in
- let* right_expression = parse_expr_mul_div in
- parse_add_sub_chain
- @@ Expr_binary_op (operator, Expr_const (Const_int 0), right_expression)
- in
- let parse_expr_compare =
- let* first_operand = parse_expr_add_sub in
- let rec parse_compare_chain left_expression =
- (let* operator = parse_bin_op_T3 in
- let* right_expression = parse_expr_add_sub in
- parse_compare_chain @@ Expr_binary_op (operator, left_expression, right_expression))
- <|> return left_expression
- in
- parse_compare_chain first_operand
- in
- let parse_expr_and =
- let* first_operand = parse_expr_compare in
- let rec parse_and_chain left_expression =
- (let* operator = parse_bin_op_T2 in
- let* right_expression = parse_expr_compare in
- parse_and_chain @@ Expr_binary_op (operator, left_expression, right_expression))
- <|> return left_expression
- > "and"
- in
- parse_and_chain first_operand
- in
- let parse_expr_or =
- let* first_operand = parse_expr_and in
- let rec parse_or_chain left_expression =
- (let* operator = parse_bin_op_T1 in
- let* right_expression = parse_expr_and in
- parse_or_chain @@ Expr_binary_op (operator, left_expression, right_expression))
- <|> return left_expression
- > "or"
- in
- parse_or_chain first_operand
- in
- parse_expr_or
-;;
-
-(* ---expression parser--- *)
-
-let parse_expression_without_tuple_list parse_expression =
- (*also this implemention doesn't consider tuple and list_constructor_case constructions, then we will add it*)
- type_annotation
- @@ choice
- [ parse_bin_op_expression parse_expression
- ; parse_if_when_else parse_expression
- ; parse_match_with parse_expression
- ; parse_function_fun parse_expression
- ; parse_anonymouse_fun parse_expression
- ; parse_in_construction parse_expression
- ]
-;;
-
-(*let's add ability to parse tuple and list_constructor_case constructions*)
-
-let parse_expr_list_construct parse_expression =
- let parse_element =
- round_par_many @@ parse_expression_without_tuple_list parse_expression
- <|> round_par_many1 parse_expression
- in
- let* first = parse_element in
- let* rest = many1 @@ (token "::" *> parse_element) in
- return @@ Expr_list_construct (first :: rest)
-;;
-
-let parse_expr_tuple parse_expression =
- let parse_element =
- round_par_many
- @@ choice
- [ parse_expr_list_construct parse_expression
- ; parse_expression_without_tuple_list parse_expression
- ]
- <|> round_par_many1 parse_expression
- in
- let* first = parse_element in
- let* rest = many1 @@ (token "," *> parse_element) in
- return @@ Expr_tuple (first :: rest)
-;;
-
-let parse_expression =
- fix
- @@ fun parse_expression ->
- choice
- [ parse_expr_tuple parse_expression
- ; parse_expr_list_construct parse_expression
- ; parse_expression_without_tuple_list parse_expression
- ]
-;;
-
-let parse_structure =
- let* parse_let_bindings =
- many1
- (parse_let_rec_and_binding parse_expression <|> parse_let_biding parse_expression)
- in
- return parse_let_bindings
-;;
-
-let parse = parse_string ~consume:All parse_structure
diff --git a/EMigunova/lib/parse.mli b/EMigunova/lib/parse.mli
deleted file mode 100644
index fbc428259..000000000
--- a/EMigunova/lib/parse.mli
+++ /dev/null
@@ -1,32 +0,0 @@
-(** Copyright 2025, Migunova Anastasia *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Angstrom
-open Ast
-
-val parse_id : ident t
-val parse_int : constant t
-val parse_char : constant t
-val parse_str : constant t
-val parse_bool : constant t
-val parse_unit : constant t
-val parse_const : constant t
-val parse_any_pattern : pattern t
-val parse_var_pattern : pattern t
-val parse_const_pattern : pattern t
-val parse_tuple_pattern : pattern t -> pattern t
-val parse_pattern : pattern t
-val parse_expr_var : expression t
-val parse_expr_const : expression t
-val parse_expr_list_sugar : expression t -> expression t
-val parse_expr_base_elements : expression t -> expression t
-val parse_bin_op_expression : expression t -> expression t
-val parse_if_when_else : expression t -> expression t
-val parse_match_with : expression t -> expression t
-val parse_let_biding : expression t -> let_binding t
-val parse_in_construction : expression t -> expression t
-val parse_anonymouse_fun : expression t -> expression t
-val parse_function_fun : expression t -> expression t
-val parse_expression : expression t
-val parse : ident -> (let_binding list, ident) result
diff --git a/EMigunova/tests/.gitignore b/EMigunova/tests/.gitignore
deleted file mode 100644
index 26685e795..000000000
--- a/EMigunova/tests/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-lam*.txt
\ No newline at end of file
diff --git a/EMigunova/tests/dune b/EMigunova/tests/dune
deleted file mode 100644
index 07a30bab1..000000000
--- a/EMigunova/tests/dune
+++ /dev/null
@@ -1,30 +0,0 @@
-(cram
- (applies_to *)
- (deps
- ../bin/REPL.exe
- manytests/typed/001fac.ml
- manytests/typed/001fac.ml
- manytests/typed/002fac.ml
- manytests/typed/003fib.ml
- manytests/typed/004manyargs.ml
- manytests/typed/005fix.ml
- manytests/typed/006partial2.ml
- manytests/typed/006partial3.ml
- manytests/typed/006partial.ml
- manytests/typed/007order.ml
- manytests/typed/008ascription.ml
- manytests/typed/009let_poly.ml
- manytests/typed/010sukharev.ml
- manytests/typed/015tuples.ml
- manytests/typed/016lists.ml
- manytests/do_not_type/001.ml
- manytests/do_not_type/002if.ml
- manytests/do_not_type/003occurs.ml
- manytests/do_not_type/004let_poly.ml
- manytests/do_not_type/005.ml
- manytests/do_not_type/015tuples.ml
- manytests/do_not_type/016tuples_mismatch.ml
- manytests/do_not_type/097fun_vs_list.ml
- manytests/do_not_type/097fun_vs_unit.ml
- manytests/do_not_type/098rec_int.ml
- manytests/do_not_type/099.ml))
diff --git a/EMigunova/tests/manytests b/EMigunova/tests/manytests
deleted file mode 120000
index f6572219a..000000000
--- a/EMigunova/tests/manytests
+++ /dev/null
@@ -1 +0,0 @@
-./../../manytests
\ No newline at end of file
diff --git a/EMigunova/tests/manytests_inference.t b/EMigunova/tests/manytests_inference.t
deleted file mode 100644
index 48667c3cf..000000000
--- a/EMigunova/tests/manytests_inference.t
+++ /dev/null
@@ -1,170 +0,0 @@
- $ ../bin/REPL.exe --dinference <
- > let c = 'x'
- > let s = "asv"
- >
- > let cons2 a b xs = a::b::xs
- > let x = cons2 1 2 [3]
- > let xxx = (1,2,3,(4,5))
- val c : char = 'x'
- val s : string = "asv"
- val cons2 : 'a->'a->'a list->'a list =
- val x : int list = [1; 2; 3]
- val xxx : int*int*int*(int*int) = (1, 2, 3, (4, 5))
-
- $ ../bin/REPL.exe --dinference <
- > let f xs = match xs with
- > | [x] -> [x]
- >
- val f : 'a list->'a list =
-
- $ ../bin/REPL.exe --dinference < manytests/typed/001fac.ml
- 24
- val fac : int->int =
- val main : int = 0
- $ ../bin/REPL.exe --dinference < manytests/typed/001fac.ml
- 24
- val fac : int->int =
- val main : int = 0
-
- $ ../bin/REPL.exe --dinference < manytests/typed/002fac.ml
- 24
- val fac_cps : int->(int->'a)->'a =
- val main : int = 0
-
- $ ../bin/REPL.exe --dinference < manytests/typed/003fib.ml
- 3
- 3
- val fib_acc : int->int->int->int =
- val fib : int->int =
- val main : int = 0
-
- $ ../bin/REPL.exe --dinference < manytests/typed/004manyargs.ml
- 1111111111
- 1
- 10
- 100
- val wrap : 'a->'a =
- val test3 : int->int->int->int =
- val test10 : int->int->int->int->int->int->int->int->int->int->int =
- val main : int = 0
-
- $ ../bin/REPL.exe --dinference < manytests/typed/005fix.ml
- 720
- val fix : (('a->'b)->'a->'b)->'a->'b =
- val fac : (int->int)->int->int =
- val main : int = 0
-
- $ ../bin/REPL.exe --dinference < manytests/typed/006partial2.ml
- 1
- 2
- 3
- 7
- val foo : int->int->int->int =
- val main : int = 0
-
- $ ../bin/REPL.exe --dinference < manytests/typed/006partial3.ml
- 4
- 8
- 9
- val foo : int->int->int->unit =
- val main : int = 0
-
- $ ../bin/REPL.exe --dinference < manytests/typed/006partial.ml
- 1122
- val foo : int->int =
- val main : int = 0
-
- $ ../bin/REPL.exe --dinference < manytests/typed/007order.ml
- 1
- 2
- 4
- -1
- 103
- -555555
- 10000
- val _start : unit->unit->int->unit->int->int->unit->int->int->int =
- val main : unit = ()
-
- $ ../bin/REPL.exe --dinference < manytests/typed/008ascription.ml
- 8
- val addi : ('a->bool->int)->('a->bool)->'a->int =
- val main : int = 0
-
- $ ../bin/REPL.exe --dinference < manytests/typed/009let_poly.ml
- val temp : int*bool = (1, true)
-
- $ ../bin/REPL.exe --dinference < manytests/typed/010sukharev.ml
- val _1 : int->int->int*'a->bool =
- val _2 : int = 1
- val _3 : (int*string) option = Some (1, "hi")
- val _4 : int->'a =
- val _5 : int = 42
- val _6 : 'a option->'a =
- val int_of_option : int option->int =
- val _42 : int->bool =
- val id1 : 'a->'a =
- val id2 : 'a->'a =
-
- $ ../bin/REPL.exe --dinference < manytests/typed/015tuples.ml
- 1
- 1
- 1
- 1
- val fix : (('a->'b)->'a->'b)->'a->'b =
- val map : ('b->'a)->'b*'b->'a*'a =
- val fixpoly : (('a->'b)*('a->'b)->'a->'b)*(('a->'b)*('a->'b)->'a->'b)->('a->'b)*('a->'b) =
- val feven : 'a*(int->int)->int->int =
- val fodd : (int->int)*'a->int->int =
- val tie : (int->int)*(int->int) = (, )
- val meven : int->int =
- val modd : int->int =
- val main : int = 0
-
- $ ../bin/REPL.exe --dinference < manytests/typed/016lists.ml
- 1
- 2
- 3
- 8
- val length : 'a list->int =
- val length_tail : 'a list->int =
- val map : ('a->'b)->'a list->'b list =
- val append : 'a list->'a list->'a list =
- val concat : 'a list list->'a list =
- val iter : ('a->unit)->'a list->unit =
- val cartesian : 'b list->'a list->('b*'a) list =
- val main : int = 0
-
- $ ../bin/REPL.exe --dinference < manytests/do_not_type/001.ml
- Type inference error: Undefined variable 'fac'
-
- $ ../bin/REPL.exe --dinference < manytests/do_not_type/002if.ml
- Type inference error: Unification( if _ then [first type] else [second type] ) failed for following unifiable types: int and bool
-
- $ ../bin/REPL.exe --dinference < manytests/do_not_type/003occurs.ml
- Type inference error: Occurs check failed: the type variable 'ty2 occurs inside'ty2->'ty4->'ty5
-
- $ ../bin/REPL.exe --dinference < manytests/do_not_type/004let_poly.ml
- Type inference error: Unification( ([type1] -> [...]) and ([type2] -> [...]) ) failed for following unifiable types: bool and int
-
- $ ../bin/REPL.exe --dinference < manytests/do_not_type/005.ml
- Type inference error: Unification( ([type1] -> [...]) and ([type2] -> [...]) ) failed for following unifiable types: string and int
-
- $ ../bin/REPL.exe --dinference < manytests/do_not_type/015tuples.ml
- Type inference error: Recursive binding failed: the LHS of the recursive binding must not be a composed pattern (e.g. tuple, list, etc.). A variable is required.
-
- $ ../bin/REPL.exe --dinference < manytests/do_not_type/016tuples_mismatch.ml
- Type inference error: Unification( let binding with pattern ) failed for following unifiable types: int*int*int and 'ty1*'ty0
-
- $ ../bin/REPL.exe --dinference < manytests/do_not_type/097fun_vs_list.ml
- Type inference error: Unification( let binding with pattern ) failed for following unifiable types: 'ty0->'ty0 and 'ty2 list
-
- $ ../bin/REPL.exe --dinference < manytests/do_not_type/097fun_vs_unit.ml
- Type inference error: Unification( let binding with pattern ) failed for following unifiable types: 'ty0->'ty0 and unit
-
- $ ../bin/REPL.exe --dinference < manytests/do_not_type/098rec_int.ml
- Type inference error: Recursive binding failed: a function was expected as the RHS. Recursive binding is impossible for that variable. It would lead to infinite recursion.
-
- $ ../bin/REPL.exe --dinference < manytests/do_not_type/099.ml
- Type inference error: Recursive binding failed: the LHS of the recursive binding must not be a composed pattern (e.g. tuple, list, etc.). A variable is required.
diff --git a/EMigunova/tests/parsetree_factorial.t b/EMigunova/tests/parsetree_factorial.t
deleted file mode 100644
index 545e4edc1..000000000
--- a/EMigunova/tests/parsetree_factorial.t
+++ /dev/null
@@ -1,22 +0,0 @@
-(** Copyright 2025, Migunova Anastasia *)
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
- $ ../bin/REPL.exe --dparsetree < let rec factorial n = if n <= 1 then 1 else n * factorial (n-1)
- [(Let_binding (Recursive, (Let_fun ("factorial", [(Pattern_var "n")])),
- (Expr_if_then_else (
- (Expr_binary_op (LessEqual, (Expr_var "n"), (Expr_const (Const_int 1))
- )),
- (Expr_const (Const_int 1)),
- (Expr_binary_op (Mul, (Expr_var "n"),
- (Expr_application ((Expr_var "factorial"),
- [(Expr_binary_op (Sub, (Expr_var "n"),
- (Expr_const (Const_int 1))))
- ]
- ))
- ))
- ))
- ))
- ]
-
-
diff --git a/ETenyaeva/.envrc b/ETenyaeva/.envrc
deleted file mode 100644
index e6bd6786d..000000000
--- a/ETenyaeva/.envrc
+++ /dev/null
@@ -1,3 +0,0 @@
-export OPAMSWITCH=4.14.2+flambda
-eval $(opam env)
-
diff --git a/ETenyaeva/.gitignore b/ETenyaeva/.gitignore
deleted file mode 100644
index 7102a822c..000000000
--- a/ETenyaeva/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-_build
-_coverage
-/_esy
-/node_modules
-/esy.lock
-/.melange.eobjs
diff --git a/ETenyaeva/.ocamlformat b/ETenyaeva/.ocamlformat
deleted file mode 100644
index 97f970802..000000000
--- a/ETenyaeva/.ocamlformat
+++ /dev/null
@@ -1,2 +0,0 @@
-profile=janestreet
-version=0.26.2
diff --git a/ETenyaeva/.vscode/settings.json b/ETenyaeva/.vscode/settings.json
deleted file mode 100644
index 9c9d88247..000000000
--- a/ETenyaeva/.vscode/settings.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "ocaml.sandbox": {
- "kind": "opam",
- "switch": "4.14.2+flambda"
- }
-}
\ No newline at end of file
diff --git a/ETenyaeva/.zanuda b/ETenyaeva/.zanuda
deleted file mode 100644
index 0f09b19b2..000000000
--- a/ETenyaeva/.zanuda
+++ /dev/null
@@ -1 +0,0 @@
-forward mutability_check ignore REPL.ml
diff --git a/ETenyaeva/COPYING b/ETenyaeva/COPYING
deleted file mode 100644
index f288702d2..000000000
--- a/ETenyaeva/COPYING
+++ /dev/null
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is 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. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- 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.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- 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 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. Use with the GNU Affero General Public License.
-
- 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 Affero 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 special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU 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 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 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 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.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- Copyright (C)
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- 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 GPL, see
-.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-.
diff --git a/ETenyaeva/COPYING.CC0 b/ETenyaeva/COPYING.CC0
deleted file mode 100644
index 0e259d42c..000000000
--- a/ETenyaeva/COPYING.CC0
+++ /dev/null
@@ -1,121 +0,0 @@
-Creative Commons Legal Code
-
-CC0 1.0 Universal
-
- CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
- LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
- ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
- INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
- REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
- PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
- THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
- HEREUNDER.
-
-Statement of Purpose
-
-The laws of most jurisdictions throughout the world automatically confer
-exclusive Copyright and Related Rights (defined below) upon the creator
-and subsequent owner(s) (each and all, an "owner") of an original work of
-authorship and/or a database (each, a "Work").
-
-Certain owners wish to permanently relinquish those rights to a Work for
-the purpose of contributing to a commons of creative, cultural and
-scientific works ("Commons") that the public can reliably and without fear
-of later claims of infringement build upon, modify, incorporate in other
-works, reuse and redistribute as freely as possible in any form whatsoever
-and for any purposes, including without limitation commercial purposes.
-These owners may contribute to the Commons to promote the ideal of a free
-culture and the further production of creative, cultural and scientific
-works, or to gain reputation or greater distribution for their Work in
-part through the use and efforts of others.
-
-For these and/or other purposes and motivations, and without any
-expectation of additional consideration or compensation, the person
-associating CC0 with a Work (the "Affirmer"), to the extent that he or she
-is an owner of Copyright and Related Rights in the Work, voluntarily
-elects to apply CC0 to the Work and publicly distribute the Work under its
-terms, with knowledge of his or her Copyright and Related Rights in the
-Work and the meaning and intended legal effect of CC0 on those rights.
-
-1. Copyright and Related Rights. A Work made available under CC0 may be
-protected by copyright and related or neighboring rights ("Copyright and
-Related Rights"). Copyright and Related Rights include, but are not
-limited to, the following:
-
- i. the right to reproduce, adapt, distribute, perform, display,
- communicate, and translate a Work;
- ii. moral rights retained by the original author(s) and/or performer(s);
-iii. publicity and privacy rights pertaining to a person's image or
- likeness depicted in a Work;
- iv. rights protecting against unfair competition in regards to a Work,
- subject to the limitations in paragraph 4(a), below;
- v. rights protecting the extraction, dissemination, use and reuse of data
- in a Work;
- vi. database rights (such as those arising under Directive 96/9/EC of the
- European Parliament and of the Council of 11 March 1996 on the legal
- protection of databases, and under any national implementation
- thereof, including any amended or successor version of such
- directive); and
-vii. other similar, equivalent or corresponding rights throughout the
- world based on applicable law or treaty, and any national
- implementations thereof.
-
-2. Waiver. To the greatest extent permitted by, but not in contravention
-of, applicable law, Affirmer hereby overtly, fully, permanently,
-irrevocably and unconditionally waives, abandons, and surrenders all of
-Affirmer's Copyright and Related Rights and associated claims and causes
-of action, whether now known or unknown (including existing as well as
-future claims and causes of action), in the Work (i) in all territories
-worldwide, (ii) for the maximum duration provided by applicable law or
-treaty (including future time extensions), (iii) in any current or future
-medium and for any number of copies, and (iv) for any purpose whatsoever,
-including without limitation commercial, advertising or promotional
-purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
-member of the public at large and to the detriment of Affirmer's heirs and
-successors, fully intending that such Waiver shall not be subject to
-revocation, rescission, cancellation, termination, or any other legal or
-equitable action to disrupt the quiet enjoyment of the Work by the public
-as contemplated by Affirmer's express Statement of Purpose.
-
-3. Public License Fallback. Should any part of the Waiver for any reason
-be judged legally invalid or ineffective under applicable law, then the
-Waiver shall be preserved to the maximum extent permitted taking into
-account Affirmer's express Statement of Purpose. In addition, to the
-extent the Waiver is so judged Affirmer hereby grants to each affected
-person a royalty-free, non transferable, non sublicensable, non exclusive,
-irrevocable and unconditional license to exercise Affirmer's Copyright and
-Related Rights in the Work (i) in all territories worldwide, (ii) for the
-maximum duration provided by applicable law or treaty (including future
-time extensions), (iii) in any current or future medium and for any number
-of copies, and (iv) for any purpose whatsoever, including without
-limitation commercial, advertising or promotional purposes (the
-"License"). The License shall be deemed effective as of the date CC0 was
-applied by Affirmer to the Work. Should any part of the License for any
-reason be judged legally invalid or ineffective under applicable law, such
-partial invalidity or ineffectiveness shall not invalidate the remainder
-of the License, and in such case Affirmer hereby affirms that he or she
-will not (i) exercise any of his or her remaining Copyright and Related
-Rights in the Work or (ii) assert any associated claims and causes of
-action with respect to the Work, in either case contrary to Affirmer's
-express Statement of Purpose.
-
-4. Limitations and Disclaimers.
-
- a. No trademark or patent rights held by Affirmer are waived, abandoned,
- surrendered, licensed or otherwise affected by this document.
- b. Affirmer offers the Work as-is and makes no representations or
- warranties of any kind concerning the Work, express, implied,
- statutory or otherwise, including without limitation warranties of
- title, merchantability, fitness for a particular purpose, non
- infringement, or the absence of latent or other defects, accuracy, or
- the present or absence of errors, whether or not discoverable, all to
- the greatest extent permissible under applicable law.
- c. Affirmer disclaims responsibility for clearing rights of other persons
- that may apply to the Work or any use thereof, including without
- limitation any person's Copyright and Related Rights in the Work.
- Further, Affirmer disclaims responsibility for obtaining any necessary
- consents, permissions or other rights required for any use of the
- Work.
- d. Affirmer understands and acknowledges that Creative Commons is not a
- party to this document and has no duty or obligation with respect to
- this CC0 or use of the Work.
diff --git a/ETenyaeva/COPYING.LESSER b/ETenyaeva/COPYING.LESSER
deleted file mode 100644
index 0a041280b..000000000
--- a/ETenyaeva/COPYING.LESSER
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser 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
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/ETenyaeva/ETenyaeva.opam b/ETenyaeva/ETenyaeva.opam
deleted file mode 100644
index 019cae0c1..000000000
--- a/ETenyaeva/ETenyaeva.opam
+++ /dev/null
@@ -1,36 +0,0 @@
-# This file is generated by dune, edit dune-project instead
-opam-version: "2.0"
-version: "0.1"
-synopsis: "An interpreter for MiniML"
-description:
- "FIXME. A longer description, for example, which are the most interesing features being supported, etc."
-maintainer: ["Ekaterina Tenyaeva "]
-authors: ["Ekaterina Tenyaeva "]
-license: "LGPL-3.0-or-later"
-homepage: "https://github.com/Kakadu/fp2024"
-doc: "https://kakadu.github.io/fp2024/docs/Lambda"
-bug-reports: "https://github.com/Kakadu/fp2024"
-depends: [
- "dune" {>= "3.7"}
- "angstrom"
- "ppx_inline_test" {with-test}
- "ppx_expect"
- "ppx_deriving"
- "bisect_ppx"
- "odoc" {with-doc}
- "ocamlformat" {build}
-]
-build: [
- ["dune" "subst"] {dev}
- [
- "dune"
- "build"
- "-p"
- name
- "-j"
- jobs
- "@install"
- "@runtest" {with-test}
- "@doc" {with-doc}
- ]
-]
diff --git a/ETenyaeva/Makefile b/ETenyaeva/Makefile
deleted file mode 100644
index a0a833fae..000000000
--- a/ETenyaeva/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-.PHONY: repl tests test fmt lint celan
-
-all:
- dune build
-
-repl:
- dune build ./REPL.exe && rlwrap _build/default/REPL.exe
-
-run:
- dune exec ./bin/REPL.exe
-
-tests: test
-test:
- dune runtest
-
-celan: clean
-clean:
- @$(RM) -r _build _coverage
-
-fmt:
- dune build @fmt --auto-promote
-
-lint:
- dune build @lint --force
-
-release:
- dune build --profile=release
- dune runtest --profile=release
-
-install:
- dune b @install --profile=release
- dune install
-
-ODIG_SWITCHES = --odoc-theme=odig.gruvbox.light
-ODIG_SWITCHES += --no-tag-index
-ODIG_SWITCHES += --no-pkg-deps
-odig:
- odig odoc $(ODIG_SWITCHES) Lambda
-
-TEST_COV_D = /tmp/cov
-COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect tests/
-
-.PHONY: test_coverage coverage
-test_coverage: coverage
-coverage:
- $(RM) -r $(TEST_COV_D)
- mkdir -p $(TEST_COV_D)
- BISECT_FILE=$(TEST_COV_D)/language dune runtest --no-print-directory \
- --instrument-with bisect_ppx --force
- bisect-ppx-report html $(COVERAGE_OPTS)
- bisect-ppx-report summary $(COVERAGE_OPTS)
- @echo "Use 'xdg-open _coverage/index.html' to see coverage report"
diff --git a/ETenyaeva/bin/REPL.ml b/ETenyaeva/bin/REPL.ml
deleted file mode 100644
index 26f98789e..000000000
--- a/ETenyaeva/bin/REPL.ml
+++ /dev/null
@@ -1,81 +0,0 @@
-(** Copyright 2024-2025, Ekaterina Tenyaeva *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-type options =
- { mutable dump_parsetree : bool
- ; mutable dump_inference : bool
- }
-
-let run_single dump_parsetree dump_inference =
- let text = In_channel.(input_all stdin) |> String.trim in
- let ast = ETenyaeva_lib.Parser.parse text in
- match ast with
- | Error _ -> Format.printf "Syntax error"
- | Result.Ok ast ->
- if dump_parsetree then Format.printf "%a\n" ETenyaeva_lib.Ast.pp_structure ast;
- if dump_inference
- then (
- let infer =
- ETenyaeva_lib.Inferencer.run_inferencer
- ETenyaeva_lib.Inferencer.env_with_print_funs
- ast
- in
- match infer with
- | Error e ->
- Format.printf "Inferencer error: %a\n" ETenyaeva_lib.Inferencer.pp_error e
- | Result.Ok (_, infer_out_list) ->
- List.iter
- (function
- | Some id, ty ->
- Format.printf "val %s : %a\n" id ETenyaeva_lib.Inferencer.pp_type ty
- | None, ty -> Format.printf "- : %a\n" ETenyaeva_lib.Inferencer.pp_type ty)
- infer_out_list);
- if not (dump_inference || dump_parsetree)
- then (
- let infer =
- ETenyaeva_lib.Inferencer.run_inferencer
- ETenyaeva_lib.Inferencer.env_with_print_funs
- ast
- in
- match infer with
- | Error e ->
- Format.printf "Inferencer error: %a\n" ETenyaeva_lib.Inferencer.pp_error e
- | Result.Ok (_, _) ->
- let inter =
- ETenyaeva_lib.Interpreter.run_interpreter
- ETenyaeva_lib.Interpreter.env_with_print_funs
- ast
- in
- (match inter with
- | Error e ->
- Format.printf "Interpreter error: %a\n" ETenyaeva_lib.Interpreter.pp_error e
- | Result.Ok (_, inter_out_list) ->
- List.iter
- (function
- | Some id, val' ->
- Format.printf "val %s = %a\n" id ETenyaeva_lib.Interpreter.pp_value val'
- | None, val' ->
- Format.printf "- = %a\n" ETenyaeva_lib.Interpreter.pp_value val')
- inter_out_list))
-;;
-
-let () =
- let options = { dump_parsetree = false; dump_inference = false } in
- let () =
- let open Stdlib.Arg in
- parse
- [ ( "--dparsetree"
- , Unit (fun () -> options.dump_parsetree <- true)
- , "Dump parse tree, don't eval enything" )
- ; ( "--dinference"
- , Unit (fun () -> options.dump_inference <- true)
- , "Eval and display type inference info" )
- ]
- (fun _ ->
- Stdlib.Format.eprintf "Anonymous arguments are not supported\n";
- Stdlib.exit 1)
- "Read-Eval-Print-Loop for MiniML Calculus"
- in
- run_single options.dump_parsetree options.dump_inference
-;;
diff --git a/ETenyaeva/bin/dune b/ETenyaeva/bin/dune
deleted file mode 100644
index dbb6f9b1b..000000000
--- a/ETenyaeva/bin/dune
+++ /dev/null
@@ -1,7 +0,0 @@
-(executable
- (name REPL)
- (public_name REPL)
- (libraries ETenyaeva_lib))
-
-(cram
- (deps ./REPL.exe %{bin:REPL}))
diff --git a/ETenyaeva/bin/repl.t b/ETenyaeva/bin/repl.t
deleted file mode 100644
index 7a6bb19eb..000000000
--- a/ETenyaeva/bin/repl.t
+++ /dev/null
@@ -1,10 +0,0 @@
-(** Copyright 2024-2025, Ekaterina Tenyaeva *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
- $ ./REPL.exe -help
- Read-Eval-Print-Loop for MiniML Calculus
- --dparsetree Dump parse tree, don't eval enything
- --dinference Eval and display type inference info
- -help Display this list of options
- --help Display this list of options
diff --git a/ETenyaeva/dune b/ETenyaeva/dune
deleted file mode 100644
index 98e54536a..000000000
--- a/ETenyaeva/dune
+++ /dev/null
@@ -1,7 +0,0 @@
-(env
- (dev
- (flags
- (:standard -alert @deprecated -warn-error -A -w -3-9-32-34-58)))
- (release
- (flags
- (:standard -alert @deprecated -warn-error +A -w +A-4-40-42-44-70))))
diff --git a/ETenyaeva/dune-project b/ETenyaeva/dune-project
deleted file mode 100644
index 128ce91f0..000000000
--- a/ETenyaeva/dune-project
+++ /dev/null
@@ -1,35 +0,0 @@
-(lang dune 3.7)
-
-(generate_opam_files true)
-
-(cram enable)
-
-(license LGPL-3.0-or-later)
-
-(authors "Ekaterina Tenyaeva ")
-
-(maintainers "Ekaterina Tenyaeva ")
-
-(bug_reports "https://github.com/Kakadu/fp2024")
-
-(homepage "https://github.com/Kakadu/fp2024")
-
-(package
- (name ETenyaeva) ; FIXME and regenerate .opam file using 'dune build @install'
- (synopsis "An interpreter for MiniML")
- (description
- "FIXME. A longer description, for example, which are the most interesing features being supported, etc.")
- (documentation "https://kakadu.github.io/fp2024/docs/Lambda")
- (version 0.1)
- (depends
- dune
- angstrom
- (ppx_inline_test :with-test)
- ppx_expect
- ppx_deriving
- bisect_ppx
- (odoc :with-doc)
- (ocamlformat :build)
- ; base
- ; After adding dependencies to 'dune' files add the same dependecies here too
- ))
diff --git a/ETenyaeva/lib/ast.ml b/ETenyaeva/lib/ast.ml
deleted file mode 100644
index 39ea70a08..000000000
--- a/ETenyaeva/lib/ast.ml
+++ /dev/null
@@ -1,104 +0,0 @@
-(** Copyright 2024-2025, Ekaterina Tenyaeva *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-type id = string (* identifier *) [@@deriving show { with_path = false }]
-
-type rec_flag =
- | Rec (** recursive *)
- | NonRec (** non-recursive *)
-[@@deriving show { with_path = false }]
-
-type const =
- | Int of int (** integer, e.g. 26 *)
- | Bool of bool (** boolean, e.g. true *)
- | String of string (** string, e.g. "string" *)
- | Char of char (** char, e.g. 'a' *)
- | Unit (** [()] *)
-[@@deriving show { with_path = false }]
-
-type typ =
- | TypInt (** integer type - [int] *)
- | TypChar (** char type - [char] *)
- | TypStr (** string type - [string] *)
- | TypBool (** boolean type - [bool] *)
- | TypUnit (** unit type - [unit] *)
- | TypVar of id (** variable type *)
- | TypArrow of typ * typ (** arrow type *)
- | TypList of typ (** list type, e.g. [int list], [string list] *)
- | TypTuple of typ * typ * typ list (** tuple type, e.g. [int * int * string] *)
- | TypOption of typ (** type option *)
-[@@deriving show { with_path = false }]
-
-type binary_oper =
- | Add (** [+] *)
- | Sub (** [-] *)
- | Mult (* [*] *)
- | Div (** [/] *)
- | And (** [&&] *)
- | Or (** [||] *)
- | Equals (** [=] *)
- | NotEquals (** [<>] *)
- | LessThan (** [<] *)
- | LessEquals (** [<=] *)
- | GreaterThan (** [>] *)
- | GreaterEquals (** [>=] *)
-[@@deriving show { with_path = false }]
-
-type unary_oper =
- | Neg (** negation of a value, e.g. -5 *)
- | Not (** [not] *)
-[@@deriving show { with_path = false }]
-
-type pattern =
- | PatConst of const (** matches a constant value, e.g. 42, true *)
- | PatVar of id (** matches any value and binds it to a variable, e.g. x *)
- | PatAny (** matches any value without binding it - [_] *)
- | PatTup of pattern * pattern * pattern list
- (** matches tuples, e.g. (x, y), (a, b, c) *)
- | PatList of pattern list (** matches lists of patterns, e.g. [y; x] *)
- | PatListConstructor of pattern list (** matches lists of patterns, e.g. a::b::[] *)
- | PatOption of pattern option (** matches an optional pattern, e.g. Some x or None *)
- | PatWithTyp of typ * pattern (** typed pattern, e.g. a: int *)
-[@@deriving show { with_path = false }]
-
-type expr =
- | ExpVar of id (** variable, e.g. x *)
- | ExpConst of const (** constant, e.g. 10*)
- | ExpIfThenElse of expr * expr * expr option
- (** conditional expression, e.g. if a then b else c*)
- | ExpFun of pattern * expr (** function, e.g. fun (x, y) -> x + y *)
- | ExpFunction of case_expr * case_expr list
- (** function, e.g. function x | 0 -> "zero" | _ -> "nonzero" *)
- | ExpBinOper of binary_oper * expr * expr (** binary operation, e.g. 1 + 5*)
- | ExpUnOper of unary_oper * expr (** unary operation, e.g. -7 *)
- | ExpList of expr list (** list expression, e.g. [1, "string", 2, (1 + 7)] *)
- | ExpListConstructor of expr list (** list expression, e.g. 1::2::[] *)
- | ExpLet of rec_flag * let_binding * let_binding list * expr (** let, e.g. let x = 5 *)
- | ExpApp of expr * expr (** application, e.g. (fun (x, y) -> x + y) (1, 2) *)
- | ExpTup of expr * expr * expr list (** tuple expression, e.g. (e1, e2), (x, y, z) *)
- | ExpMatch of expr * case_expr * case_expr list
- (** pattern matching, e.g. match x with | 0 -> "zero" | _ -> "nonzero" *)
- | ExpOption of expr option (** optonal expression, e.g. Some x*)
- | ExpWithTyp of typ * expr (** typed expression, e.g. a: int *)
-[@@deriving show { with_path = false }]
-
-and let_binding =
- { pat : pattern (** the pattern being bound, e.g. x, (a, b) *)
- ; expr : expr (** the expression being assigned, e.g. 42, fun x -> x + 1 *)
- }
-[@@deriving show { with_path = false }]
-
-and case_expr =
- { case_pat : pattern (** the pattern to match, e.g. x, _ *)
- ; case_expr : expr (** the expression to evaluate if the pattern matches *)
- }
-[@@deriving show { with_path = false }]
-
-type structure_item =
- | EvalExp of expr (** an expression to be evaluated but not bound, e.g. 1 + 2*)
- | Binding of rec_flag * let_binding * let_binding list
- (** a value or function binding, e.g. let x = 1*)
-[@@deriving show { with_path = false }]
-
-type structure = structure_item list [@@deriving show { with_path = false }]
diff --git a/ETenyaeva/lib/dune b/ETenyaeva/lib/dune
deleted file mode 100644
index 6e1463c94..000000000
--- a/ETenyaeva/lib/dune
+++ /dev/null
@@ -1,18 +0,0 @@
-(library
- (name ETenyaeva_lib)
- (public_name ETenyaeva.lib)
- (libraries base angstrom)
- (preprocess
- (pps ppx_deriving.show))
- (instrumentation
- (backend bisect_ppx)))
-
-; (library
-; (name tests)
-; (modules tests)
-; (libraries ETenyaeva_lib)
-; (preprocess
-; (pps ppx_expect ppx_deriving.show))
-; (instrumentation
-; (backend bisect_ppx))
-; (inline_tests))
diff --git a/ETenyaeva/lib/inferencer.ml b/ETenyaeva/lib/inferencer.ml
deleted file mode 100644
index 047ac0725..000000000
--- a/ETenyaeva/lib/inferencer.ml
+++ /dev/null
@@ -1,838 +0,0 @@
-(** Copyright 2024-2025, Ekaterina Tenyaeva *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-open Stdlib.Format
-
-let rec pp_type fmt = function
- | TypInt -> fprintf fmt "int"
- | TypBool -> fprintf fmt "bool"
- | TypUnit -> fprintf fmt "unit"
- | TypStr -> fprintf fmt "string"
- | TypChar -> fprintf fmt "char"
- | TypVar id -> fprintf fmt "%s" id
- | TypArrow ((TypArrow (_, _) as ty1), ty2) ->
- fprintf fmt "(%a) -> %a" pp_type ty1 pp_type ty2
- | TypArrow (ty1, ty2) -> fprintf fmt "%a -> %a" pp_type ty1 pp_type ty2
- | TypList ty ->
- (match ty with
- | TypInt | TypBool | TypUnit | TypStr | TypVar _ | TypChar ->
- fprintf fmt "%a list" pp_type ty
- | _ -> fprintf fmt "(%a) list" pp_type ty)
- | TypTuple (f, s, xs) ->
- fprintf
- fmt
- "%a"
- (pp_print_list
- ~pp_sep:(fun _ _ -> printf " * ")
- (fun fmt ty ->
- match ty with
- | TypInt | TypBool | TypUnit | TypStr | TypVar _ | TypChar -> pp_type fmt ty
- | _ -> fprintf fmt "(%a)" pp_type ty))
- (f :: s :: xs)
- | TypOption TypUnit -> ()
- | TypOption ty ->
- (match ty with
- | TypInt | TypBool | TypUnit | TypStr | TypVar _ | TypChar ->
- fprintf fmt "%a option" pp_type ty
- | _ -> fprintf fmt "(%a) option" pp_type ty)
-;;
-
-type error =
- | NoVariableRec
- | NoArgRec
- | SeveralBounds of string
- | OccursCheck of string * typ
- | NoVariable of string
- | UnificationFailed of typ * typ
-
-let pp_error fmt = function
- | OccursCheck (id, typ) ->
- fprintf fmt "Occurs check failed. Type variable %s occurs inside %a\n" id pp_type typ
- | NoVariable name -> fprintf fmt "Unbound variable %s'." name
- | NoVariableRec ->
- fprintf fmt "Only variables are allowed as left-hand side of `let rec'"
- | UnificationFailed (ty1, ty2) ->
- fprintf fmt "Failed to unify types: %a and %a\n" pp_type ty1 pp_type ty2
- | NoArgRec ->
- fprintf fmt "This kind of expression is not allowed as right-hand side of `let rec'"
- | SeveralBounds name -> fprintf fmt "Multiple bounds for variable %s'." name
-;;
-
-module State = struct
- open Base
-
- type 'a t = int -> int * ('a, error) Result.t
-
- let return x state = state, Result.return x
- let fail e state = state, Result.fail e
-
- let ( >>= ) (monad : 'a t) (f : 'a -> 'b t) : 'b t =
- fun state ->
- match monad state with
- | state, Result.Ok result -> f result state
- | state, Result.Error e -> fail e state
- ;;
-
- module Syntax = struct
- let ( let* ) = ( >>= )
- end
-
- let ( >>| ) (monad : 'a t) (f : 'a -> 'b) : 'b t =
- fun state ->
- match monad state with
- | state, Result.Ok result -> return (f result) state
- | state, Result.Error e -> fail e state
- ;;
-
- module RList = struct
- let fold_left xs ~init ~f =
- List.fold_left xs ~init ~f:(fun acc x ->
- let open Syntax in
- let* acc = acc in
- f acc x)
- ;;
-
- let fold_right xs ~init ~f =
- List.fold_right xs ~init ~f:(fun x acc ->
- let open Syntax in
- let* acc = acc in
- f x acc)
- ;;
- end
-
- module RMap = struct
- let fold map ~init ~f =
- Map.fold map ~init ~f:(fun ~key ~data acc ->
- let open Syntax in
- let* acc = acc in
- f key data acc)
- ;;
- end
-
- let fresh state = state + 1, Result.Ok state
- let run monad = snd (monad 0)
-end
-
-module VarSet = struct
- include Stdlib.Set.Make (String)
-end
-
-type scheme = Scheme of VarSet.t * typ
-
-module Type = struct
- open Base
-
- (* gets a variable var and type ty, and checks whether the
- variable is contained in the set of free variables of this type*)
- let occurs_in var ty =
- let rec helper ty =
- match ty with
- | TypOption ty | TypList ty -> helper ty
- | TypVar name -> String.equal name var
- | TypTuple (fst_ty, snd_ty, ty_list) ->
- List.exists ~f:helper (fst_ty :: snd_ty :: ty_list)
- | TypArrow (l, r) -> helper l || helper r
- | _ -> false
- in
- match ty with
- | TypVar _ -> false
- | _ -> helper ty
- ;;
-
- let free_vars =
- let rec helper acc = function
- | TypOption ty | TypList ty -> helper acc ty
- | TypVar name -> VarSet.add name acc
- | TypTuple (fst_ty, snd_ty, ty_list) ->
- List.fold_left ~f:helper ~init:acc (fst_ty :: snd_ty :: ty_list)
- | TypArrow (l, r) -> helper (helper acc l) r
- | _ -> acc
- in
- helper VarSet.empty
- ;;
-end
-
-module Subst = struct
- open State
- open Base
- open State.Syntax
-
- let empty = Map.empty (module String)
- let singleton1 = Map.singleton (module String)
-
- let singleton key value =
- if Type.occurs_in key value
- then fail (OccursCheck (key, value))
- else return (Map.singleton (module String) key value)
- ;;
-
- let remove = Map.remove
-
- let apply sub =
- let rec helper = function
- | TypVar name as ty ->
- (match Map.find sub name with
- | Some name -> name
- | None -> ty)
- | TypOption ty -> TypOption (helper ty)
- | TypList ty -> TypList (helper ty)
- | TypTuple (fst_ty, snd_ty, ty_list) ->
- TypTuple (helper fst_ty, helper snd_ty, List.map ty_list ~f:helper)
- | TypArrow (l, r) -> TypArrow (helper l, helper r)
- | ty -> ty
- in
- helper
- ;;
-
- let rec unify l r =
- match l, r with
- | TypUnit, TypUnit
- | TypInt, TypInt
- | TypChar, TypChar
- | TypStr, TypStr
- | TypBool, TypBool -> return empty
- | TypVar l, TypVar r when String.equal l r -> return empty
- | TypVar name, ty | ty, TypVar name -> singleton name ty
- | TypList ty1, TypList ty2 | TypOption ty1, TypOption ty2 -> unify ty1 ty2
- | TypTuple (fst1, snd1, list1), TypTuple (fst2, snd2, list2) ->
- (match
- List.fold2
- (fst1 :: snd1 :: list1)
- (fst2 :: snd2 :: list2)
- ~init:(return empty)
- ~f:(fun acc ty1 ty2 ->
- let* sub_acc = acc in
- let* unified_sub = unify (apply sub_acc ty1) (apply sub_acc ty2) in
- compose sub_acc unified_sub)
- with
- | Ok res -> res
- | _ -> fail (UnificationFailed (l, r)))
- | TypArrow (l1, r1), TypArrow (l2, r2) ->
- let* sub1 = unify l1 l2 in
- let* sub2 = unify (apply sub1 r1) (apply sub1 r2) in
- compose sub1 sub2
- | _ -> fail (UnificationFailed (l, r))
-
- and extend key value sub =
- match Map.find sub key with
- | None ->
- let value = apply sub value in
- let* new_sub = singleton key value in
- Map.fold sub ~init:(return new_sub) ~f:(fun ~key ~data acc ->
- let* acc = acc in
- let new_data = apply new_sub data in
- return (Map.update acc key ~f:(fun _ -> new_data)))
- | Some existing_value ->
- let* new_sub = unify value existing_value in
- compose sub new_sub
-
- and compose sub1 sub2 = RMap.fold sub2 ~init:(return sub1) ~f:extend
-
- let compose_all sub_list = RList.fold_left sub_list ~init:(return empty) ~f:compose
-end
-
-module Scheme = struct
- let free_vars (Scheme (bind_set, ty)) = VarSet.diff (Type.free_vars ty) bind_set
-
- let apply sub (Scheme (bind_set, ty)) =
- let new_sub = VarSet.fold (fun key sub -> Subst.remove sub key) bind_set sub in
- Scheme (bind_set, Subst.apply new_sub ty)
- ;;
-end
-
-module TypeEnv = struct
- open Base
-
- type t = (id, scheme, String.comparator_witness) Map.t
-
- let empty = Map.empty (module String)
- let extend env key value = Map.update env key ~f:(fun _ -> value)
-
- let free_vars env =
- Map.fold env ~init:VarSet.empty ~f:(fun ~key:_ ~data acc ->
- VarSet.union acc (Scheme.free_vars data))
- ;;
-
- let apply sub env = Map.map env ~f:(Scheme.apply sub)
- let find = Map.find
-
- let rec extend_with_pattern env_acc pat (Scheme (bind_set, ty) as scheme) =
- match pat, ty with
- | PatVar id, _ -> extend env_acc id scheme
- | PatTup (fst_pat, snd_pat, pat_list), TypTuple (fst_ty, snd_ty, ty_list) ->
- let env =
- List.fold2
- ~init:env_acc
- ~f:(fun env pat ty -> extend_with_pattern env pat (Scheme (bind_set, ty)))
- (fst_pat :: snd_pat :: pat_list)
- (fst_ty :: snd_ty :: ty_list)
- in
- (match env with
- | Ok env -> env
- | _ -> env_acc)
- | PatListConstructor pat_list, TypList ty ->
- (match pat_list with
- | single_pat :: [] ->
- extend_with_pattern env_acc single_pat (Scheme (bind_set, TypList ty))
- | first :: rest ->
- extend_with_pattern
- (extend_with_pattern env_acc first (Scheme (bind_set, ty)))
- (PatListConstructor rest)
- (Scheme (bind_set, TypList ty))
- | [] -> env_acc)
- | PatList pat_list, TypList ty ->
- List.fold_left pat_list ~init:env_acc ~f:(fun env_acc pat ->
- extend_with_pattern env_acc pat (Scheme (bind_set, ty)))
- | PatOption (Some pat), TypOption ty ->
- extend_with_pattern env_acc pat (Scheme (bind_set, ty))
- | _ -> env_acc
- ;;
-
- (** looks for a type by key in the environment and throws an exception if the key is not found*)
- let find_type_exn env key =
- let (Scheme (_, ty)) = Map.find_exn env key in
- ty
- ;;
-end
-
-module Infer = struct
- open State
- open State.Syntax
-
- let unify = Subst.unify
- let fresh_var = fresh >>| fun n -> TypVar ("'ty" ^ Int.to_string n)
-
- let instantiate (Scheme (bind_set, ty)) =
- VarSet.fold
- (fun name ty ->
- let* ty = ty in
- let* fresh = fresh_var in
- let* sub = Subst.singleton name fresh in
- return (Subst.apply sub ty))
- bind_set
- (return ty)
- ;;
-
- (** generalizes type ty by removing certain variables from the environment,
- evaluating free variables, creating new names for them, and returning a new generic schema*)
- let generalize env ty ~remove_from_env id =
- let env =
- match remove_from_env, id, ty with
- | true, Some id, TypArrow _ -> Base.Map.remove env id
- | _ -> env
- in
- let free = VarSet.diff (Type.free_vars ty) (TypeEnv.free_vars env) in
- let new_free, new_ty, _ =
- VarSet.fold
- (fun str (temp_free, temp_ty, n) ->
- let degree = n / 26 in
- let new_str =
- Printf.sprintf
- "'%c%s"
- (Stdlib.Char.chr (97 + (n mod 26)))
- (if degree = 0 then "" else Int.to_string degree)
- in
- let sub = Subst.singleton1 str (TypVar new_str) in
- let new_free = VarSet.add new_str temp_free in
- let new_ty = Subst.apply sub temp_ty in
- new_free, new_ty, n + 1)
- free
- (VarSet.empty, ty, 0)
- in
- Scheme (new_free, new_ty)
- ;;
-
- let lookup_env id env =
- match TypeEnv.find env id with
- | Some scheme ->
- let* ans = instantiate scheme in
- return (Subst.empty, ans)
- | None -> fail (NoVariable id)
- ;;
-
- let rec infer_pattern env = function
- | PatAny ->
- let* fresh = fresh_var in
- return (env, fresh)
- | PatVar id ->
- let* fresh = fresh_var in
- let env = TypeEnv.extend env id (Scheme (VarSet.empty, fresh)) in
- return (env, fresh)
- | PatConst const ->
- (match const with
- | Int _ -> return (env, TypInt)
- | String _ -> return (env, TypStr)
- | Char _ -> return (env, TypChar)
- | Bool _ -> return (env, TypBool)
- | Unit -> return (env, TypUnit))
- | PatTup (fst_pat, snd_pat, pat_list) ->
- let* env1, ty1 = infer_pattern env fst_pat in
- let* env2, ty2 = infer_pattern env1 snd_pat in
- let* env_rest, ty_list =
- RList.fold_right
- ~f:(fun pat acc ->
- let* env_acc, ty_list = return acc in
- let* env, ty = infer_pattern env_acc pat in
- return (env, ty :: ty_list))
- ~init:(return (env2, []))
- pat_list
- in
- return (env_rest, TypTuple (ty1, ty2, ty_list))
- | PatOption None ->
- let* fresh = fresh_var in
- return (env, TypOption fresh)
- | PatOption (Some pat) ->
- let* env, ty = infer_pattern env pat in
- return (env, TypOption ty)
- | PatListConstructor pat_list ->
- let* fresh = fresh_var in
- let rec helper env sub_acc rest =
- match rest with
- | [] -> return (env, sub_acc)
- | single :: [] ->
- let* env, ty = infer_pattern env single in
- let* unified_sub = unify (TypList fresh) ty in
- let* composed_sub = Subst.compose sub_acc unified_sub in
- helper env composed_sub []
- | first :: rest ->
- let* env, ty = infer_pattern env first in
- let* unified_sub = unify fresh ty in
- let* composed_sub = Subst.compose sub_acc unified_sub in
- helper env composed_sub rest
- in
- let* env, sub = helper env Subst.empty pat_list in
- let result_ty = Subst.apply sub fresh in
- return (env, TypList result_ty)
- | PatList pat_list ->
- let* list_element_type_var = fresh_var in
- let* env, sub =
- RList.fold_left
- pat_list
- ~init:(return (env, Subst.empty))
- ~f:(fun (acc_env, acc_sub) pat ->
- let* env, pat_type = infer_pattern acc_env pat in
- let* unified_sub = unify list_element_type_var pat_type in
- let* composed_sub = Subst.compose unified_sub acc_sub in
- return (env, composed_sub))
- in
- let list_element_type = Subst.apply sub list_element_type_var in
- let env = TypeEnv.apply sub env in
- return (env, TypList list_element_type)
- | PatWithTyp (c_ty, pat) ->
- let* env, ty = infer_pattern env pat in
- let* unified_sub = unify ty c_ty in
- return (TypeEnv.apply unified_sub env, Subst.apply unified_sub ty)
- ;;
-
- let extend_env_with_bind_names env value_binding_list =
- RList.fold_right
- value_binding_list
- ~init:(return (env, []))
- ~f:(fun let_bind acc ->
- match let_bind with
- | { pat = PatVar id | PatWithTyp (_, PatVar id); _ } ->
- let* env, fresh_acc = return acc in
- let* fresh = fresh_var in
- let env = TypeEnv.extend env id (Scheme (VarSet.empty, fresh)) in
- return (env, fresh :: fresh_acc)
- | _ -> fail NoVariableRec)
- ;;
-
- (** Recursively traverses patterns by extracting variable names.
- Applies the given func to each identifier found.
- Uses the accumulator acc to store intermediate results.*)
- let rec extract_names_from_pat func acc = function
- | PatVar id -> func acc id
- | PatTup (fst_pat, snd_pat, pat_list) ->
- RList.fold_left
- (fst_pat :: snd_pat :: pat_list)
- ~init:(return acc)
- ~f:(extract_names_from_pat func)
- | PatOption (Some pat) -> extract_names_from_pat func acc pat
- | PatListConstructor pat_list | PatList pat_list ->
- (match pat_list with
- | [] -> return acc
- | first_pat :: rest_pats ->
- let* acc = extract_names_from_pat func acc first_pat in
- extract_names_from_pat func acc (PatList rest_pats))
- | PatWithTyp (_, pat) -> extract_names_from_pat func acc pat
- | _ -> return acc
- ;;
-
- module StringSet = struct
- include Stdlib.Set.Make (String)
-
- let add_id set value =
- if mem value set then fail (SeveralBounds value) else return (add value set)
- ;;
- end
-
- let check_names_from_let_binds =
- RList.fold_left ~init:(return StringSet.empty) ~f:(fun set_acc { pat; _ } ->
- extract_names_from_pat StringSet.add_id set_acc pat)
- ;;
-
- let infer_binop_type = function
- | Equals | NotEquals | GreaterThan | GreaterEquals | LessThan | LessEquals ->
- fresh_var >>| fun fresh_ty -> fresh_ty, fresh_ty, TypBool
- | Add | Sub | Mult | Div -> return (TypInt, TypInt, TypInt)
- | And | Or -> return (TypBool, TypBool, TypBool)
- ;;
-
- let infer_unop_type = function
- | Neg -> return (TypInt, TypInt)
- | Not -> return (TypBool, TypBool)
- ;;
-
- (** takes a type environment and an expression, and then returns the type of that expression*)
- let rec infer_expression env = function
- | ExpVar id -> lookup_env id env
- | ExpConst const ->
- (match const with
- | Int _ -> return (Subst.empty, TypInt)
- | String _ -> return (Subst.empty, TypStr)
- | Bool _ -> return (Subst.empty, TypBool)
- | Char _ -> return (Subst.empty, TypChar)
- | Unit -> return (Subst.empty, TypUnit))
- | ExpTup (fst_exp, snd_exp, exp_list) ->
- let* sub1, ty1 = infer_expression env fst_exp in
- let* sub2, ty2 = infer_expression (TypeEnv.apply sub1 env) snd_exp in
- let env = TypeEnv.apply sub2 env in
- let* sub_rest, ty_list =
- RList.fold_right
- ~f:(fun exp acc ->
- let* sub_acc, ty_list = return acc in
- let* sub, ty = infer_expression (TypeEnv.apply sub_acc env) exp in
- let* sub_acc = Subst.compose sub_acc sub in
- return (sub_acc, ty :: ty_list))
- ~init:(return (Subst.empty, []))
- exp_list
- in
- let* sub_result = Subst.compose_all [ sub1; sub2; sub_rest ] in
- let ty1 = Subst.apply sub_result ty1 in
- let ty2 = Subst.apply sub_result ty2 in
- let ty_list = Base.List.map ~f:(fun ty -> Subst.apply sub_result ty) ty_list in
- return (sub_result, TypTuple (ty1, ty2, ty_list))
- | ExpIfThenElse (if_exp, then_exp, None) ->
- let* sub1, ty1 = infer_expression env if_exp in
- let* sub2, ty2 = infer_expression (TypeEnv.apply sub1 env) then_exp in
- let* sub3 = unify ty1 TypBool in
- let* sub4 = unify ty2 TypUnit in
- let* final_sub = Subst.compose_all [ sub4; sub3; sub2; sub1 ] in
- return (final_sub, Subst.apply final_sub ty2)
- | ExpIfThenElse (if_exp, then_exp, Some else_exp) ->
- let* sub1, ty1 = infer_expression env if_exp in
- let* sub2, ty2 = infer_expression (TypeEnv.apply sub1 env) then_exp in
- let* sub3, ty3 = infer_expression (TypeEnv.apply sub2 env) else_exp in
- let* sub4 = unify ty1 TypBool in
- let* sub5 = unify ty2 ty3 in
- let* final_sub = Subst.compose_all [ sub5; sub4; sub3; sub2; sub1 ] in
- return (final_sub, Subst.apply final_sub ty2)
- | ExpWithTyp (c_ty, exp) ->
- let* sub, ty = infer_expression env exp in
- let* unified_sub = unify ty c_ty in
- let* final_sub = Subst.compose unified_sub sub in
- return (final_sub, Subst.apply unified_sub ty)
- | ExpFunction (case, case_list) ->
- let* fresh_for_matching = fresh_var in
- let* fresh_for_result = fresh_var in
- infer_match_exp
- env
- ~with_exp:false
- Subst.empty
- fresh_for_matching
- fresh_for_result
- (case :: case_list)
- | ExpMatch (exp, case, case_list) ->
- let* exp_sub, exp_ty = infer_expression env exp in
- let env = TypeEnv.apply exp_sub env in
- let* fresh_for_result = fresh_var in
- infer_match_exp
- env
- ~with_exp:true
- exp_sub
- exp_ty
- fresh_for_result
- (case :: case_list)
- | ExpUnOper (operation, expr) ->
- let* subst1, ty = infer_expression env expr in
- let* ty1_op, ty_res = infer_unop_type operation in
- let* subst2 = Subst.unify (Subst.apply subst1 ty) ty1_op in
- let* subst = Subst.compose_all [ subst1; subst2 ] in
- return (subst, Subst.apply subst ty_res)
- | ExpBinOper (op, expr1, expr2) ->
- let* subst1, ty = infer_expression env expr1 in
- let* subst2, ty' = infer_expression (TypeEnv.apply subst1 env) expr2 in
- let* ty1_op, ty2_op, ty_res = infer_binop_type op in
- let* subst3 = Subst.unify (Subst.apply subst2 ty) ty1_op in
- let* subst4 = Subst.unify (Subst.apply subst3 ty') ty2_op in
- let* subst = Subst.compose_all [ subst1; subst2; subst3; subst4 ] in
- return (subst, Subst.apply subst ty_res)
- | ExpApp (exp1, exp2) ->
- let* sub1, ty1 = infer_expression env exp1 in
- let* sub2, ty2 = infer_expression (TypeEnv.apply sub1 env) exp2 in
- let* fresh = fresh_var in
- let* sub3 = unify (Subst.apply sub2 ty1) (TypArrow (ty2, fresh)) in
- let* composed_sub = Subst.compose_all [ sub3; sub2; sub1 ] in
- let final_ty = Subst.apply composed_sub fresh in
- return (composed_sub, final_ty)
- | ExpList exprs ->
- (match exprs with
- | [] ->
- let* fresh = fresh_var in
- return (Subst.empty, TypList fresh)
- | _ :: _ ->
- let infer_list_elements env es =
- let rec aux env = function
- | [] -> return ([], [])
- | e :: es' ->
- let* s, t = infer_expression env e in
- let* s', ts = aux (TypeEnv.apply s env) es' in
- return (s' @ [ s ], t :: ts)
- in
- aux env es
- in
- let* subst, tys = infer_list_elements env exprs in
- let* total_subst = Subst.compose_all subst in
- (match tys with
- | [] -> fail (SeveralBounds "inferred empty list type")
- | ty :: _ -> return (total_subst, TypList ty)))
- | ExpListConstructor expr_list ->
- let* fresh = fresh_var in
- let rec infer_list_constract env acc_sub = function
- | [] ->
- let* fresh1 = fresh_var in
- return (Subst.empty, TypOption fresh1)
- | end_element :: [] ->
- let* expr_sub, expr_ty = infer_expression env end_element in
- let* unified_sub = unify expr_ty (TypList fresh) in
- let* composed_sub = Subst.compose_all [ expr_sub; unified_sub; acc_sub ] in
- return (composed_sub, TypList (Subst.apply composed_sub fresh))
- | expr_element :: expr_rest ->
- let* expr_sub, expr_ty = infer_expression env expr_element in
- let* unified_sub = unify expr_ty fresh in
- let* composed_sub = Subst.compose_all [ expr_sub; unified_sub; acc_sub ] in
- let env = TypeEnv.apply composed_sub env in
- let* sub, ty = infer_list_constract env composed_sub expr_rest in
- return (sub, ty)
- in
- infer_list_constract env Subst.empty expr_list
- | ExpOption None ->
- let* fresh = fresh_var in
- return (Subst.empty, TypOption fresh)
- | ExpOption (Some expr) ->
- let* sub, ty = infer_expression env expr in
- return (sub, TypOption ty)
- | ExpFun (pat, expr) ->
- let* env, ty1 = infer_pattern env pat in
- let* sub, ty2 = infer_expression env expr in
- return (sub, TypArrow (Subst.apply sub ty1, ty2))
- | ExpLet (NonRec, value_binding, value_binding_list, exp) ->
- let* _ = check_names_from_let_binds (value_binding :: value_binding_list) in
- let* env, sub1 =
- infer_value_binding_list env Subst.empty (value_binding :: value_binding_list)
- in
- let* sub2, ty2 = infer_expression env exp in
- let* composed_sub = Subst.compose sub2 sub1 in
- return (composed_sub, ty2)
- | ExpLet (Rec, value_binding, value_binding_list, exp) ->
- let* env, fresh_acc =
- extend_env_with_bind_names env (value_binding :: value_binding_list)
- in
- let* env, sub1 =
- infer_rec_value_binding_list
- env
- fresh_acc
- Subst.empty
- (value_binding :: value_binding_list)
- in
- let* sub2, ty2 = infer_expression env exp in
- let* composed_sub = Subst.compose sub2 sub1 in
- return (composed_sub, ty2)
-
- and infer_match_exp env ~with_exp match_exp_sub match_exp_ty result_ty case_list =
- let* cases_sub, case_ty =
- RList.fold_left
- case_list
- ~init:(return (match_exp_sub, result_ty))
- ~f:(fun acc { case_pat = pat; case_expr = case_exp } ->
- let* sub_acc, ty_acc = return acc in
- let* env, pat_sub =
- let* env, pat_ty = infer_pattern env pat in
- let* unified_sub1 = unify match_exp_ty pat_ty in
- let* pat_names =
- extract_names_from_pat StringSet.add_id StringSet.empty pat
- >>| StringSet.elements
- in
- if with_exp
- then (
- let env = TypeEnv.apply unified_sub1 env in
- let generalized_schemes =
- Base.List.map pat_names ~f:(fun name ->
- let ty = TypeEnv.find_type_exn env name in
- let generalized_ty =
- generalize env ty ~remove_from_env:true (Some name)
- in
- name, generalized_ty)
- in
- let env =
- Base.List.fold generalized_schemes ~init:env ~f:(fun env (key, value) ->
- TypeEnv.extend env key value)
- in
- return (env, unified_sub1))
- else return (env, unified_sub1)
- in
- let* composed_sub1 = Subst.compose sub_acc pat_sub in
- let* case_exp_sub, case_exp_ty =
- infer_expression (TypeEnv.apply composed_sub1 env) case_exp
- in
- let* unified_sub2 = unify ty_acc case_exp_ty in
- let* composed_sub2 =
- Subst.compose_all [ composed_sub1; case_exp_sub; unified_sub2 ]
- in
- return (composed_sub2, Subst.apply composed_sub2 ty_acc))
- in
- let final_ty =
- if with_exp then case_ty else TypArrow (Subst.apply cases_sub match_exp_ty, case_ty)
- in
- return (cases_sub, final_ty)
-
- and infer_value_binding_list env sub let_binds =
- let infer_vb new_sub env ty pat rest =
- let* composed_sub = Subst.compose sub new_sub in
- let env = TypeEnv.apply composed_sub env in
- let generalized_ty =
- generalize env (Subst.apply composed_sub ty) ~remove_from_env:false None
- in
- let* env, pat_ty = infer_pattern env pat in
- let env = TypeEnv.extend_with_pattern env pat generalized_ty in
- let* unified_sub = unify ty pat_ty in
- let* final_sub = Subst.compose composed_sub unified_sub in
- let env = TypeEnv.apply final_sub env in
- infer_value_binding_list env final_sub rest
- in
- match let_binds with
- | [] -> return (env, sub)
- | { pat = PatWithTyp (pat_ty, pat); expr = ExpFun (e_pat, expr) } :: rest ->
- let* new_sub, ty =
- infer_expression env (ExpFun (e_pat, ExpWithTyp (pat_ty, expr)))
- in
- infer_vb new_sub env ty pat rest
- | { pat = PatWithTyp (pat_ty, pat); expr = ExpFunction _ as expr } :: rest ->
- let* new_sub, ty = infer_expression env (ExpWithTyp (pat_ty, expr)) in
- infer_vb new_sub env ty pat rest
- | { pat; expr } :: rest ->
- let* new_sub, ty = infer_expression env expr in
- infer_vb new_sub env ty pat rest
-
- and infer_rec_value_binding_list env fresh_acc sub let_binds =
- let infer_rec_vb new_sub fresh ty id fresh_acc rest ~required_ty =
- let* new_sub =
- match required_ty with
- | Some c_ty ->
- let* unified_sub = unify ty c_ty in
- Subst.compose unified_sub new_sub
- | None -> return new_sub
- in
- let* unified_sub = unify (Subst.apply new_sub fresh) ty in
- let* composed_sub = Subst.compose_all [ new_sub; unified_sub; sub ] in
- let env = TypeEnv.apply composed_sub env in
- let generalized_ty =
- generalize env (Subst.apply composed_sub fresh) ~remove_from_env:true (Some id)
- in
- let env = TypeEnv.extend env id generalized_ty in
- infer_rec_value_binding_list env fresh_acc composed_sub rest
- in
- match let_binds, fresh_acc with
- | [], _ -> return (env, sub)
- | ( { pat = PatVar id; expr = (ExpFun _ | ExpFunction _) as exp } :: rest
- , fresh :: fresh_acc ) ->
- let* new_sub, ty = infer_expression env exp in
- infer_rec_vb new_sub fresh ty id fresh_acc rest ~required_ty:None
- | ( { pat = PatWithTyp (pat_ty, PatVar id); expr = ExpFun (pat, expr) } :: rest
- , fresh :: fresh_acc ) ->
- let* new_sub, ty = infer_expression env (ExpFun (pat, ExpWithTyp (pat_ty, expr))) in
- infer_rec_vb new_sub fresh ty id fresh_acc rest ~required_ty:None
- | ( { pat = PatWithTyp (pat_ty, PatVar id); expr = ExpFunction _ as expr } :: rest
- , fresh :: fresh_acc ) ->
- let* new_sub, ty = infer_expression env (ExpWithTyp (pat_ty, expr)) in
- infer_rec_vb new_sub fresh ty id fresh_acc rest ~required_ty:None
- | { pat = PatVar id; expr } :: rest, fresh :: fresh_acc ->
- let* new_sub, ty = infer_expression env expr in
- let update_fresh = Subst.apply new_sub fresh in
- if ty = update_fresh
- then fail NoArgRec
- else infer_rec_vb new_sub fresh ty id fresh_acc rest ~required_ty:None
- | { pat = PatWithTyp (pat_ty, PatVar id); expr } :: rest, fresh :: fresh_acc ->
- let* new_sub, ty = infer_expression env expr in
- let update_fresh = Subst.apply new_sub fresh in
- if ty = update_fresh
- then fail NoArgRec
- else infer_rec_vb new_sub fresh ty id fresh_acc rest ~required_ty:(Some pat_ty)
- | _ -> fail NoVariableRec
- ;;
-
- let infer_structure_item (env, out_list) =
- let get_names_from_let_binds env =
- RList.fold_left ~init:(return []) ~f:(fun acc { pat; _ } ->
- extract_names_from_pat
- (fun acc id -> return (acc @ [ Some id, TypeEnv.find_type_exn env id ]))
- acc
- pat)
- in
- function
- | EvalExp exp ->
- let* _, ty = infer_expression env exp in
- return (env, out_list @ [ None, ty ])
- | Binding (NonRec, value_binding, value_binding_list) ->
- let value_binding_list = value_binding :: value_binding_list in
- let* _ = check_names_from_let_binds value_binding_list in
- let* env, _ = infer_value_binding_list env Subst.empty value_binding_list in
- let* id_list = get_names_from_let_binds env value_binding_list in
- return (env, out_list @ id_list)
- | Binding (Rec, value_binding, value_binding_list) ->
- let value_binding_list = value_binding :: value_binding_list in
- let* env, fresh_acc = extend_env_with_bind_names env value_binding_list in
- let* env, _ =
- infer_rec_value_binding_list env fresh_acc Subst.empty value_binding_list
- in
- let* id_list = get_names_from_let_binds env value_binding_list in
- return (env, out_list @ id_list)
- ;;
-
- let infer_srtucture env ast =
- let* env, out_list =
- RList.fold_left ast ~init:(return (env, [])) ~f:infer_structure_item
- in
- let remove_duplicates =
- let fun_equal el1 el2 =
- match el1, el2 with
- | (Some id1, _), (Some id2, _) -> String.equal id1 id2
- | _ -> false
- in
- function
- | x :: xs when not (Base.List.mem xs x ~equal:fun_equal) -> x :: xs
- | _ :: xs -> xs
- | [] -> []
- in
- return (env, remove_duplicates out_list)
- ;;
-end
-
-let empty_env = TypeEnv.empty
-
-let env_with_print_funs =
- let print_fun_list =
- [ "print_int", Scheme (VarSet.empty, TypArrow (TypInt, TypUnit))
- ; "print_endline", Scheme (VarSet.empty, TypArrow (TypStr, TypUnit))
- ]
- in
- Base.List.fold_left
- ~f:(fun env (id, sch) -> TypeEnv.extend env id sch)
- ~init:TypeEnv.empty
- print_fun_list
-;;
-
-let run_inferencer env ast = State.run (Infer.infer_srtucture env ast)
diff --git a/ETenyaeva/lib/inferencer.mli b/ETenyaeva/lib/inferencer.mli
deleted file mode 100644
index 104013c34..000000000
--- a/ETenyaeva/lib/inferencer.mli
+++ /dev/null
@@ -1,41 +0,0 @@
-(** Copyright 2024-2025, Ekaterina Tenyaeva *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-type error =
- | NoVariableRec
- | NoArgRec
- | SeveralBounds of string
- | OccursCheck of string * Ast.typ
- | NoVariable of string
- | UnificationFailed of Ast.typ * Ast.typ
-
-val pp_type : Format.formatter -> Ast.typ -> unit
-val pp_error : Format.formatter -> error -> unit
-
-module VarSet : sig
- type t
-
- val empty : t
- val add : string -> t -> t
- val remove : string -> t -> t
- val mem : string -> t -> bool
- val union : t -> t -> t
- val inter : t -> t -> t
- val diff : t -> t -> t
- val elements : t -> string list
-end
-
-type scheme = Scheme of VarSet.t * Ast.typ
-
-module TypeEnv : sig
- type t = (Ast.id, scheme, Base.String.comparator_witness) Base.Map.t
-end
-
-val empty_env : TypeEnv.t
-val env_with_print_funs : TypeEnv.t
-
-val run_inferencer
- : TypeEnv.t
- -> Ast.structure
- -> (TypeEnv.t * (Ast.id option * Ast.typ) list, error) result
diff --git a/ETenyaeva/lib/interpreter.ml b/ETenyaeva/lib/interpreter.ml
deleted file mode 100644
index a0d8646e2..000000000
--- a/ETenyaeva/lib/interpreter.ml
+++ /dev/null
@@ -1,435 +0,0 @@
-(** Copyright 2024-2025, Ekaterina Tenyaeva *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-
-type error =
- | TypeError
- | DivisionByZero
- | MatchFailure
- | NoVariable of id
-
-let pp_error ppf : error -> _ = function
- | TypeError -> Format.fprintf ppf "Type error"
- | DivisionByZero -> Format.fprintf ppf "Division by zero"
- | MatchFailure -> Format.fprintf ppf "Matching failure"
- | NoVariable id -> Format.fprintf ppf "Undefined variable '%s'" id
-;;
-
-type value =
- | ValInt of int
- | ValChar of char
- | ValString of string
- | ValUnit
- | ValBool of bool
- | ValFun of rec_flag * pattern * expr * env
- | ValFunction of case_expr list * env
- | ValTuple of value * value * value list
- | ValList of value list
- | ValOption of value option
- | ValBuiltin of id
-
-and env = (id, value, Base.String.comparator_witness) Base.Map.t
-
-let rec pp_value ppf =
- let open Stdlib.Format in
- function
- | ValInt int -> fprintf ppf "%i" int
- | ValChar char -> fprintf ppf "'%c'" char
- | ValString str -> fprintf ppf "%S" str
- | ValBool bool -> fprintf ppf "%b" bool
- | ValUnit -> fprintf ppf "()"
- | ValOption value ->
- (match value with
- | Some value -> fprintf ppf "Some %a" pp_value value
- | None -> fprintf ppf "None")
- | ValList vls ->
- fprintf
- ppf
- "[%a]"
- (pp_print_list ~pp_sep:(fun ppf () -> fprintf ppf "; ") pp_value)
- vls
- | ValTuple (fst_val, snd_val, val_list) ->
- fprintf
- ppf
- "(%a)"
- (pp_print_list ~pp_sep:(fun ppf () -> fprintf ppf ", ") pp_value)
- (fst_val :: snd_val :: val_list)
- | ValFun _ -> fprintf ppf ""
- | ValFunction _ -> fprintf ppf ""
- | ValBuiltin _ -> fprintf ppf ""
-;;
-
-module Res = struct
- open Base
-
- type 'a t = ('a, error) Result.t
-
- let fail = Result.fail
- let return = Result.return
-
- let ( >>= ) (monad : 'a t) (f : 'a -> 'b t) : 'b t =
- match monad with
- | Ok result -> f result
- | Error x -> fail x
- ;;
-
- let ( let* ) = ( >>= )
-end
-
-module EvalEnv = struct
- open Base
-
- let empty = Map.empty (module String)
- let extend env key value = Map.update env key ~f:(fun _ -> value)
-
- let compose env1 env2 =
- Map.fold env2 ~f:(fun ~key ~data env_acc -> extend env_acc key data) ~init:env1
- ;;
-
- let find_exn env key =
- match Map.find env key with
- | Some value -> Res.return value
- | None -> Res.fail (NoVariable key)
- ;;
-
- let find_exn1 env key =
- let val' = Map.find_exn env key in
- val'
- ;;
-end
-
-module Inter = struct
- open Res
- open EvalEnv
-
- let eval_arith opr val1 val2 = return (ValInt (opr val1 val2))
- let eval_eq opr val1 val2 = return (ValBool (opr val1 val2))
- let eval_bool opr val1 val2 = return (ValBool (opr val1 val2))
-
- let eval_un_op = function
- | Neg, ValInt val1 -> return (ValInt (-val1))
- | Not, ValBool val1 -> return (ValBool (not val1))
- | _ -> fail TypeError
- ;;
-
- let eval_bin_op = function
- | Mult, ValInt val1, ValInt val2 -> eval_arith ( * ) val1 val2
- | Div, ValInt val1, ValInt val2 when val2 <> 0 -> eval_arith ( / ) val1 val2
- | Div, _, ValInt 0 -> fail DivisionByZero
- | Add, ValInt val1, ValInt val2 -> eval_arith ( + ) val1 val2
- | Sub, ValInt val1, ValInt val2 -> eval_arith ( - ) val1 val2
- | GreaterEquals, val1, val2 -> eval_eq ( >= ) val1 val2
- | LessEquals, val1, val2 -> eval_eq ( <= ) val1 val2
- | NotEquals, val1, val2 -> eval_eq ( <> ) val1 val2
- | Equals, val1, val2 -> eval_eq ( = ) val1 val2
- | GreaterThan, val1, val2 -> eval_eq ( > ) val1 val2
- | LessThan, val1, val2 -> eval_eq ( < ) val1 val2
- | And, ValBool val1, ValBool val2 -> eval_bool ( && ) val1 val2
- | Or, ValBool val1, ValBool val2 -> eval_bool ( || ) val1 val2
- | _ -> fail TypeError
- ;;
-
- let rec match_pattern env = function
- | PatAny, _ -> Some env
- | PatVar name, value -> Some (extend env name value)
- | PatConst (Int pat), ValInt value when pat = value -> Some env
- | PatConst (Char pat), ValChar value when pat = value -> Some env
- | PatConst (Bool pat), ValBool value when pat = value -> Some env
- | PatConst Unit, _ -> Some env
- | PatConst (String pat), ValString value when pat = value -> Some env
- | PatTup (fst_pat, snd_pat, pat_list), ValTuple (fst_val, snd_val, val_list) ->
- let env =
- Base.List.fold2
- ~f:(fun env pat value ->
- match env with
- | Some env -> match_pattern env (pat, value)
- | None -> None)
- ~init:(Some env)
- (fst_pat :: snd_pat :: pat_list)
- (fst_val :: snd_val :: val_list)
- in
- (match env with
- | Ok env -> env
- | _ -> None)
- | PatListConstructor pat_list, ValList val_list ->
- (match pat_list, val_list with
- | single_pat :: [], val_list -> match_pattern env (single_pat, ValList val_list)
- | _ :: _ :: _, [] -> None
- | first_pat :: rest_pat, first_val :: rest_val ->
- let env = match_pattern env (first_pat, first_val) in
- (match env with
- | Some env -> match_pattern env (PatListConstructor rest_pat, ValList rest_val)
- | None -> None)
- | _ -> None)
- | PatList pat_list, ValList val_list ->
- (match pat_list, val_list with
- | [], [] -> Some env
- | first_pat :: rest_pat, first_val :: rest_val ->
- let env = match_pattern env (first_pat, first_val) in
- (match env with
- | Some env -> match_pattern env (PatList rest_pat, ValList rest_val)
- | None -> None)
- | _ -> None)
- | PatWithTyp (_, pat), value -> match_pattern env (pat, value)
- | PatOption None, ValOption None -> Some env
- | PatOption (Some pat), ValOption (Some value) -> match_pattern env (pat, value)
- | _ -> None
- ;;
-
- let rec extend_names_from_pat env = function
- | PatAny, _ -> return env
- | PatConst Unit, ValUnit -> return env
- | PatOption None, ValOption None -> return env
- | PatVar id, value -> return (extend env id value)
- | PatTup (fst_pat, snd_pat, pat_list), ValTuple (fst_val, snd_val, val_list) ->
- (match
- Base.List.fold2
- (fst_pat :: snd_pat :: pat_list)
- (fst_val :: snd_val :: val_list)
- ~init:(return env)
- ~f:(fun acc pat value ->
- let* env = acc in
- extend_names_from_pat env (pat, value))
- with
- | Ok acc -> acc
- | _ -> fail TypeError)
- | PatList pat_list, ValList val_list ->
- (match pat_list, val_list with
- | first_pat :: rest_pat, first_val :: rest_val ->
- let* env = extend_names_from_pat env (first_pat, first_val) in
- let* env = extend_names_from_pat env (PatList rest_pat, ValList rest_val) in
- return env
- | _, _ -> return env)
- | PatListConstructor pat_list, ValList val_list ->
- (match pat_list, val_list with
- | first_pat :: rest_pat, first_val :: rest_val ->
- let* env = extend_names_from_pat env (first_pat, first_val) in
- let* env =
- extend_names_from_pat env (PatListConstructor rest_pat, ValList rest_val)
- in
- return env
- | _, _ -> return env)
- | PatOption (Some pat), ValOption (Some value) ->
- extend_names_from_pat env (pat, value)
- | _ -> fail TypeError
- ;;
-
- let rec eval_expression env = function
- | ExpVar id -> find_exn env id
- | ExpConst const ->
- (match const with
- | Int int -> return (ValInt int)
- | Char char -> return (ValChar char)
- | String str -> return (ValString str)
- | Bool bool -> return (ValBool bool)
- | Unit -> return ValUnit)
- | ExpLet (NonRec, value_binding, value_binding_list, exp) ->
- let* env = eval_value_binding_list env (value_binding :: value_binding_list) in
- eval_expression env exp
- | ExpLet (Rec, value_binding, value_binding_list, exp) ->
- let* env = eval_rec_value_binding_list env (value_binding :: value_binding_list) in
- eval_expression env exp
- | ExpFun (pat, exp) -> return (ValFun (NonRec, pat, exp, env))
- | ExpFunction (case, case_list) -> return (ValFunction (case :: case_list, env))
- | ExpMatch (exp, case, case_list) ->
- let* match_value = eval_expression env exp in
- find_and_eval_case env match_value (case :: case_list)
- | ExpBinOper (op, exp1, exp2) ->
- let* value1 = eval_expression env exp1 in
- let* value2 = eval_expression env exp2 in
- eval_bin_op (op, value1, value2)
- | ExpUnOper (op, e) ->
- let* v = eval_expression env e in
- eval_un_op (op, v)
- | ExpListConstructor expr_list ->
- let* val_list =
- Base.List.fold_right
- ~f:(fun exp acc ->
- let* acc = acc in
- let* value = eval_expression env exp in
- match value with
- | ValList lst -> return (lst @ acc)
- | _ -> return (value :: acc))
- ~init:(return [])
- expr_list
- in
- return (ValList val_list)
- | ExpList expr_list ->
- let* val_list =
- Base.List.fold_right
- ~f:(fun exp acc ->
- let* acc = acc in
- let* value = eval_expression env exp in
- return (value :: acc))
- ~init:(return [])
- expr_list
- in
- return (ValList val_list)
- | ExpApp (exp1, exp2) ->
- let* fun_val = eval_expression env exp1 in
- let* arg_val = eval_expression env exp2 in
- (match fun_val with
- | ValFun (rec_flag, pat, exp, fun_env) ->
- let* new_env =
- match rec_flag, match_pattern fun_env (pat, arg_val) with
- | Rec, Some extended_env -> return (compose env extended_env)
- | NonRec, Some extended_env -> return extended_env
- | _, None -> fail MatchFailure
- in
- eval_expression new_env exp
- | ValFunction (case_list, env) -> find_and_eval_case env arg_val case_list
- | ValBuiltin builtin ->
- (match builtin, arg_val with
- | "print_int", ValInt integer ->
- Format.printf "%d\n" integer;
- return ValUnit
- | "print_endline", ValString str ->
- print_endline str;
- return ValUnit
- | _ -> fail TypeError)
- | _ -> fail TypeError)
- | ExpOption None -> return (ValOption None)
- | ExpOption (Some expr) ->
- let* value = eval_expression env expr in
- return (ValOption (Some value))
- | ExpTup (fst_exp, snd_exp, exp_list) ->
- let* fst_val = eval_expression env fst_exp in
- let* snd_val = eval_expression env snd_exp in
- let* val_list =
- Base.List.fold_right
- ~f:(fun exp acc ->
- let* acc = acc in
- let* value = eval_expression env exp in
- return (value :: acc))
- ~init:(return [])
- exp_list
- in
- return (ValTuple (fst_val, snd_val, val_list))
- | ExpIfThenElse (if_exp, then_exp, Some else_exp) ->
- let* value_if_exp = eval_expression env if_exp in
- (match value_if_exp with
- | ValBool true -> eval_expression env then_exp
- | ValBool false -> eval_expression env else_exp
- | _ -> fail TypeError)
- | ExpIfThenElse (fst_val, snd_val, None) ->
- let* value_fst_val = eval_expression env fst_val in
- (match value_fst_val with
- | ValBool true ->
- let* value_snd_val = eval_expression env snd_val in
- (match value_snd_val with
- | ValUnit as v -> return v
- | _ -> fail TypeError)
- | ValBool false -> return ValUnit
- | _ -> fail TypeError)
- | ExpWithTyp (_, exp) -> eval_expression env exp
-
- and find_and_eval_case env value = function
- | [] -> fail MatchFailure
- | { case_pat; case_expr } :: tail ->
- let env_temp = match_pattern env (case_pat, value) in
- (match env_temp with
- | Some env -> eval_expression env case_expr
- | None -> find_and_eval_case env value tail)
-
- and eval_value_binding_list env value_binding_list =
- Base.List.fold_left
- ~f:(fun acc { pat; expr } ->
- let* env = acc in
- let* value = eval_expression env expr in
- match pat with
- | PatVar name | PatWithTyp (_, PatVar name) ->
- let env = extend env name value in
- return env
- | _ ->
- let* env = extend_names_from_pat env (pat, value) in
- return env)
- ~init:(return env)
- value_binding_list
-
- and eval_rec_value_binding_list env value_binding_list =
- Base.List.fold_left
- ~f:(fun acc { pat; expr } ->
- let* env = acc in
- let* value = eval_expression env expr in
- match pat with
- | PatVar name | PatWithTyp (_, PatVar name) ->
- let value =
- match value with
- | ValFun (_, pat, expr, env) -> ValFun (Rec, pat, expr, env)
- | other -> other
- in
- let env = extend env name value in
- return env
- | _ -> fail TypeError)
- ~init:(return env)
- value_binding_list
- ;;
-
- let eval_structure_item env out_list =
- let rec extract_names_from_pat env acc = function
- | PatVar id -> acc @ [ Some id, EvalEnv.find_exn1 env id ]
- | PatTup (fst_pat, snd_pat, pat_list) ->
- Base.List.fold_left
- (fst_pat :: snd_pat :: pat_list)
- ~init:acc
- ~f:(extract_names_from_pat env)
- | PatList pat_list ->
- Base.List.fold_left pat_list ~init:acc ~f:(extract_names_from_pat env)
- | PatWithTyp (_, pat) -> extract_names_from_pat env acc pat
- | _ -> acc
- in
- let get_names_from_let_binds env =
- Base.List.fold_left ~init:[] ~f:(fun acc { pat; _ } ->
- extract_names_from_pat env acc pat)
- in
- function
- | EvalExp exp ->
- let* val' = eval_expression env exp in
- return (env, out_list @ [ None, val' ])
- | Binding (NonRec, value_binding, value_binding_list) ->
- let value_binding_list = value_binding :: value_binding_list in
- let* env = eval_value_binding_list env value_binding_list in
- let eval_list = get_names_from_let_binds env value_binding_list in
- return (env, out_list @ eval_list)
- | Binding (Rec, value_binding, value_binding_list) ->
- let value_binding_list = value_binding :: value_binding_list in
- let* env = eval_rec_value_binding_list env value_binding_list in
- let eval_list = get_names_from_let_binds env value_binding_list in
- return (env, out_list @ eval_list)
- ;;
-
- let eval_structure env ast =
- let* env, out_list =
- Base.List.fold_left
- ~f:(fun acc item ->
- let* env, out_list = acc in
- let* env, out_list = eval_structure_item env out_list item in
- return (env, out_list))
- ~init:(return (env, []))
- ast
- in
- let remove_duplicates =
- let fun_equal el1 el2 =
- match el1, el2 with
- | (Some id1, _), (Some id2, _) -> String.equal id1 id2
- | _ -> false
- in
- function
- | x :: xs when not (Base.List.mem xs x ~equal:fun_equal) -> x :: xs
- | _ :: xs -> xs
- | [] -> []
- in
- return (env, remove_duplicates out_list)
- ;;
-end
-
-let empty_env = EvalEnv.empty
-
-let env_with_print_funs =
- let env = EvalEnv.extend empty_env "print_int" (ValBuiltin "print_int") in
- EvalEnv.extend env "print_endline" (ValBuiltin "print_endline")
-;;
-
-let run_interpreter = Inter.eval_structure
diff --git a/ETenyaeva/lib/interpreter.mli b/ETenyaeva/lib/interpreter.mli
deleted file mode 100644
index 06c182310..000000000
--- a/ETenyaeva/lib/interpreter.mli
+++ /dev/null
@@ -1,39 +0,0 @@
-(** Copyright 2024-2025, Ekaterina Tenyaeva *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-type error =
- | TypeError
- (** Represents a type error that occurs when a type mismatch is detected in an expression. *)
- | DivisionByZero
- (** Represents the error that occurs when attempting to perform a division by zero operation. *)
- | MatchFailure
- (** Represents a match error occurs when a pattern matching attempt fails. *)
- | NoVariable of Ast.id
- (** Represents an error that occurs when attempting to use a variable that has not been declared or initialized. *)
-
-val pp_error : Format.formatter -> error -> unit
-
-type value =
- | ValInt of int
- | ValChar of char
- | ValString of string
- | ValUnit
- | ValBool of bool
- | ValFun of Ast.rec_flag * Ast.pattern * Ast.expr * env
- | ValFunction of Ast.case_expr list * env
- | ValTuple of value * value * value list
- | ValList of value list
- | ValOption of value option
- | ValBuiltin of Ast.id
-
-and env = (Ast.id, value, Base.String.comparator_witness) Base.Map.t
-
-val pp_value : Format.formatter -> value -> unit
-val empty_env : env
-val env_with_print_funs : env
-
-val run_interpreter
- : env
- -> Ast.structure
- -> (env * (Ast.id option * value) list, error) result
diff --git a/ETenyaeva/lib/parser.ml b/ETenyaeva/lib/parser.ml
deleted file mode 100644
index 9058dbc59..000000000
--- a/ETenyaeva/lib/parser.ml
+++ /dev/null
@@ -1,482 +0,0 @@
-(** Copyright 2024-2025, Ekaterina Tenyaeva *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Base
-open Ast
-open Angstrom
-
-let skip_whitespaces = skip_while Char.is_whitespace
-
-let parse_comments =
- skip_whitespaces *> string "(*" *> many_till any_char (string "*)") *> return ()
-;;
-
-let ws = many parse_comments *> skip_whitespaces
-let token str = ws *> string str
-
-let skip_round_par parse =
- token "(" *> parse <* (token ")" <|> fail "There is no closing bracket.")
-;;
-
-let is_keyword = function
- | "let"
- | "rec"
- | "and"
- | "if"
- | "then"
- | "else"
- | "match"
- | "with"
- | "in"
- | "true"
- | "false"
- | "Some"
- | "None"
- | "type"
- | "val"
- | "while"
- | "for"
- | "_" -> true
- | _ -> false
-;;
-
-let is_separator = function
- | ')'
- | '('
- | '<'
- | '>'
- | '@'
- | ','
- | ';'
- | ':'
- | '\\'
- | '"'
- | '/'
- | '['
- | ']'
- | '?'
- | '='
- | '{'
- | '}'
- | ' '
- | '\r'
- | '\t'
- | '\n'
- | '*'
- | '-' -> true
- | _ -> false
-;;
-
-let keyword str =
- token str
- *>
- let* is_space =
- peek_char
- >>| function
- | Some c -> is_separator c
- | None -> true
- in
- if is_space
- then return str <* ws
- else fail (Printf.sprintf "There is no separator after %S." str)
-;;
-
-let safe_tl = function
- | [] -> []
- | _ :: tail -> tail
-;;
-
-let parse_chain_left_associative parse parse_fun =
- let rec go acc =
- (let* f = parse_fun in
- let* elem = parse in
- go (f acc elem))
- <|> return acc
- in
- let* elem = parse in
- go elem
-;;
-
-let parse_chain_right_associative parse parse_fun =
- let rec go acc =
- (let* f = parse_fun in
- let* elem = parse in
- let* next_elem = go elem in
- return (f acc next_elem))
- <|> return acc
- in
- let* elem = parse in
- go elem
-;;
-
-(* ==================== constant ==================== *)
-
-let parse_const_int =
- take_while1 Char.is_digit >>| fun int_value -> Int (Int.of_string int_value)
-;;
-
-let parse_const_char =
- string "\'" *> any_char <* string "\'" >>| fun char_value -> Char char_value
-;;
-
-let parse_const_string =
- choice
- [ string "\"" *> take_till (Char.equal '\"') <* string "\""
- ; string "{|" *> take_till (Char.equal '|') <* string "|}"
- ]
- >>| fun str_value -> String str_value
-;;
-
-let parse_const_unit = string "()" >>| fun _ -> Unit
-
-let parse_const_bool =
- string "true" >>| (fun _ -> Bool true) <|> (string "false" >>| fun _ -> Bool false)
-;;
-
-let parse_constant =
- ws
- *> choice
- [ parse_const_int
- ; parse_const_char
- ; parse_const_string
- ; parse_const_bool
- ; parse_const_unit
- ]
-;;
-
-(* ==================== ident ==================== *)
-
-let parse_ident =
- ws
- *>
- let* fst_char =
- satisfy (function
- | 'a' .. 'z' | '_' -> true
- | _ -> false)
- >>| String.of_char
- in
- let* rest_str =
- take_while (function
- | 'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '_' | '\'' -> true
- | _ -> false)
- in
- let id = fst_char ^ rest_str in
- if is_keyword id then fail (Printf.sprintf "Impossible name: %S." id) else return id
-;;
-
-(* --------------------- type ---------------------- *)
-
-let parse_base_type =
- choice
- [ keyword "unit" *> return TypUnit
- ; keyword "int" *> return TypInt
- ; keyword "char" *> return TypChar
- ; keyword "string" *> return TypStr
- ; keyword "bool" *> return TypBool
- ]
-;;
-
-let parse_tuple_type parse_type =
- let* fst_type = parse_type in
- let* snd_type = token "*" *> parse_type in
- let* type_list = many (token "*" *> parse_type) in
- return (TypTuple (fst_type, snd_type, type_list))
-;;
-
-let parse_list_type parse_type =
- let f acc_ty = function
- | "list" -> TypList acc_ty
- | _ -> TypUnit
- in
- let rec go acc_ty =
- let* ty = keyword "list" in
- go (f acc_ty ty) <|> return acc_ty
- in
- let* fst_ty = parse_type in
- go fst_ty
-;;
-
-let parse_core_type =
- ws
- *> fix (fun parse_full_type ->
- let parse_type = parse_base_type <|> skip_round_par parse_full_type in
- let parse_type = parse_list_type parse_type <|> parse_type in
- parse_tuple_type parse_type <|> parse_type)
-;;
-
-(* -------------------- pattern -------------------- *)
-
-let parse_pat_with_type parse_pat =
- let* pat = ws *> token "(" *> parse_pat in
- let* constr = ws *> token ":" *> ws *> parse_core_type <* ws <* token ")" in
- return (PatWithTyp (constr, pat))
-;;
-
-let parse_pat_any = keyword "_" *> return PatAny
-let parse_pat_var = parse_ident >>| fun var -> PatVar var
-let parse_pat_constant = parse_constant >>| fun const -> PatConst const
-
-let parse_tuple parse tuple =
- let* fst = parse in
- let* snd = token "," *> parse in
- let* tail = many (token "," *> parse) in
- return (tuple (fst, snd, tail))
-;;
-
-let parse_pat_tuple parse_pat =
- parse_tuple parse_pat (fun (fst_pat, snd_pat, pat_list) ->
- PatTup (fst_pat, snd_pat, pat_list))
-;;
-
-let parse_pattern_option parse_pat =
- lift
- (fun e -> PatOption e)
- (keyword "Some" *> parse_pat
- >>| (fun e -> Some e)
- <|> (keyword "None" >>| fun _ -> None))
-;;
-
-let parse_list_construct_case_pattern parse_pat =
- let* first = parse_pat in
- let* rest = many1 @@ (token "::" *> parse_pat) in
- return (PatListConstructor (first :: rest))
-;;
-
-let parse_pattern_list parse_pat =
- let empty_list_parser =
- let* _ = token "[" *> token "]" in
- return (PatList [])
- in
- let list_parser =
- let* _ = token "[" in
- let* first = parse_pat in
- let* rest = many (token ";" *> parse_pat) in
- let* _ = token "]" in
- return (PatList (first :: rest))
- in
- empty_list_parser <|> list_parser
-;;
-
-let parse_pattern =
- ws
- *> fix (fun parse_full_pat ->
- let parse_pat =
- choice
- [ parse_pat_var
- ; parse_pat_with_type parse_full_pat
- ; parse_pat_any
- ; parse_pat_constant
- ; parse_pattern_list parse_full_pat
- ; skip_round_par parse_full_pat
- ; parse_pattern_option parse_full_pat
- ]
- in
- let parse_pat = parse_pat_tuple parse_pat <|> parse_pat in
- let parse_pat = parse_pattern_list parse_pat <|> parse_pat in
- let parse_pat = parse_list_construct_case_pattern parse_pat <|> parse_pat in
- parse_pat)
-;;
-
-(* -------------------- operator -------------------- *)
-
-let cmp =
- choice
- [ token "=" *> return Equals
- ; token "<>" *> return NotEquals
- ; token "<=" *> return LessEquals
- ; token ">=" *> return GreaterEquals
- ; token "<" *> return LessThan
- ; token ">" *> return GreaterThan
- ]
-;;
-
-let logical = choice [ token "&&" *> return And; token "||" *> return Or ]
-let add_sub = choice [ token "+" *> return Add; token "-" *> return Sub ]
-let mult_div = choice [ token "/" *> return Div; token "*" *> return Mult ]
-
-let bin_op chain1 parse_exp parse_fun_op =
- chain1 parse_exp (parse_fun_op >>| fun opr exp1 exp2 -> ExpBinOper (opr, exp1, exp2))
-;;
-
-let parse_left_bin_op = bin_op parse_chain_left_associative
-let parse_right_bin_op = bin_op parse_chain_right_associative
-let parse_un_oper = choice [ token "-" *> return Neg; keyword "not" *> return Not ]
-
-(* -------------------- expression -------------------- *)
-
-let parse_exp_with_type parse_exp =
- let* expr = ws *> token "(" *> parse_exp in
- let* constr = ws *> token ":" *> ws *> parse_core_type <* ws <* token ")" in
- return (ExpWithTyp (constr, expr))
-;;
-
-let parse_exp_ident = parse_ident >>| fun id -> ExpVar id
-let parse_exp_constant = parse_constant >>| fun const -> ExpConst const
-
-let parse_exp_tuple parse_exp =
- parse_tuple parse_exp (fun (fst_exp, snd_exp, exp_list) ->
- ExpTup (fst_exp, snd_exp, exp_list))
-;;
-
-let parse_list_construct_case_exp parse_exp =
- let* first = parse_exp in
- let* rest = many1 (token "::" *> parse_exp) in
- return (ExpListConstructor (first :: rest))
-;;
-
-let parse_exp_list parse_exp =
- let empty_list_parser =
- let* _ = token "[" *> token "]" in
- return (ExpList [])
- in
- let list_parser =
- let* _ = token "[" in
- let* first = parse_exp in
- let* rest = many (token ";" *> parse_exp) in
- let* _ = token "]" in
- return (ExpList (first :: rest))
- in
- empty_list_parser <|> list_parser
-;;
-
-let parse_exp_fun parse_exp =
- keyword "fun"
- *>
- let* pat = parse_pattern in
- let* params = many parse_pattern in
- token "->"
- *>
- let* body_exp = parse_exp in
- let exp =
- match params with
- | [] -> body_exp
- | _ -> List.fold_right ~f:(fun par acc -> ExpFun (par, acc)) params ~init:body_exp
- in
- return (ExpFun (pat, exp))
-;;
-
-let parse_exp_ifthenelse parse_expr =
- lift3
- (fun cond t f -> ExpIfThenElse (cond, t, f))
- (keyword "if" *> parse_expr)
- (keyword "then" *> parse_expr)
- (option None (keyword "else" *> parse_expr >>| Option.some))
-;;
-
-let parse_match_case parse_exp =
- ws
- *> option () (token "|" *> return ())
- *>
- let* pat = parse_pattern in
- let* exp = token "->" *> parse_exp in
- return { case_pat = pat; case_expr = exp }
-;;
-
-let parse_exp_match parse_exp =
- let* exp = keyword "match" *> parse_exp <* keyword "with" in
- let* case_list = sep_by1 (token "|") (parse_match_case parse_exp) in
- return (ExpMatch (exp, List.hd_exn case_list, safe_tl case_list))
-;;
-
-let parse_exp_function parse_exp =
- keyword "function"
- *>
- let* case_list = sep_by1 (token "|") (parse_match_case parse_exp) in
- return (ExpFunction (List.hd_exn case_list, safe_tl case_list))
-;;
-
-let parse_exp_bin_op parse_exp =
- let parse_exp = parse_left_bin_op parse_exp mult_div in
- let parse_exp = parse_left_bin_op parse_exp add_sub in
- let parse_exp = parse_left_bin_op parse_exp cmp in
- parse_right_bin_op parse_exp logical
-;;
-
-let parse_exp_un_oper parse_exp =
- parse_un_oper >>= fun op -> parse_exp >>= fun expr -> return (ExpUnOper (op, expr))
-;;
-
-let parse_exp_option parse_exp =
- choice
- [ keyword "None" *> return (ExpOption None)
- ; (keyword "Some" *> choice [ skip_round_par parse_exp; parse_exp ]
- >>| fun e -> ExpOption (Some e))
- ]
-;;
-
-let parse_binding parse_exp =
- let* pattern = parse_pattern in
- let* xs = many parse_pattern in
- let+ parse_exp = token "=" *> parse_exp in
- { pat = pattern
- ; expr =
- (match xs with
- | [] -> parse_exp
- | _ -> List.fold_right ~f:(fun f p -> ExpFun (f, p)) xs ~init:parse_exp)
- }
-;;
-
-let parse_exp_let parse_exp =
- keyword "let"
- *>
- let* rec_flag = keyword "rec" *> return Rec <|> return NonRec in
- let* vb = parse_binding parse_exp in
- let* value_bindings = many (keyword "and" *> parse_binding parse_exp) in
- let+ expr = keyword "in" *> parse_exp in
- ExpLet (rec_flag, vb, value_bindings, expr)
-;;
-
-let parse_exp_apply parse_exp =
- parse_chain_left_associative parse_exp (return (fun exp1 exp2 -> ExpApp (exp1, exp2)))
-;;
-
-let parse_expression =
- ws
- *> fix (fun expr ->
- let expr_const =
- choice
- [ skip_round_par expr
- ; parse_exp_option expr
- ; parse_exp_constant
- ; parse_exp_with_type expr
- ; parse_exp_ident
- ; parse_exp_ifthenelse expr
- ]
- in
- let expr_fun = parse_exp_fun expr <|> expr_const in
- let expr_list = parse_exp_list expr <|> expr_fun in
- let expr_apply = parse_exp_apply expr_list <|> expr_list in
- let expr_bin_op = parse_exp_bin_op expr_apply <|> expr_apply in
- let expr_un_op = parse_exp_un_oper expr_bin_op <|> expr_bin_op in
- let expr_cons = parse_list_construct_case_exp expr_un_op <|> expr_un_op in
- let expr_let_in = parse_exp_let expr <|> expr_cons in
- let expr_function = parse_exp_function expr <|> expr_let_in in
- let expr_match = parse_exp_match expr <|> expr_function in
- let expr_tuple = parse_exp_tuple expr_match <|> expr_match in
- expr_tuple)
-;;
-
-(* ==================== structure ==================== *)
-
-let parse_structure_value parse_exp =
- keyword "let"
- *>
- let* rec_flag = keyword "rec" *> return Rec <|> return NonRec in
- let* vb = parse_binding parse_exp in
- let+ value_bindings = many (keyword "and" *> parse_binding parse_exp) in
- Binding (rec_flag, vb, value_bindings)
-;;
-
-let parse_structure =
- ws
- *>
- let str_value = parse_structure_value parse_expression in
- let str_eval = str_value <|> (parse_expression >>| fun ex -> EvalExp ex) in
- let semicolons = many (token ";;") in
- sep_by semicolons str_eval <* semicolons <* ws
-;;
-
-(* ==================== execute ==================== *)
-
-let parse = parse_string ~consume:All parse_structure
diff --git a/ETenyaeva/lib/parser.mli b/ETenyaeva/lib/parser.mli
deleted file mode 100644
index e2cc1fcac..000000000
--- a/ETenyaeva/lib/parser.mli
+++ /dev/null
@@ -1,5 +0,0 @@
-(** Copyright 2024-2025, Ekaterina Tenyaeva *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-val parse : string -> (Ast.structure, string) result
diff --git a/ETenyaeva/tests/.gitignore b/ETenyaeva/tests/.gitignore
deleted file mode 100644
index 26685e795..000000000
--- a/ETenyaeva/tests/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-lam*.txt
\ No newline at end of file
diff --git a/ETenyaeva/tests/dune b/ETenyaeva/tests/dune
deleted file mode 100644
index 6dcce80de..000000000
--- a/ETenyaeva/tests/dune
+++ /dev/null
@@ -1,41 +0,0 @@
-(include_subdirs no)
-
-(library
- (name tests)
- (libraries ETenyaeva_lib)
- (preprocess
- (pps ppx_expect ppx_deriving.show))
- (inline_tests)
- (instrumentation
- (backend bisect_ppx)))
-
-(cram
- (applies_to *)
- (deps
- ../bin/REPL.exe
- manytests/typed/001fac.ml
- manytests/typed/001fac.ml
- manytests/typed/002fac.ml
- manytests/typed/003fib.ml
- manytests/typed/004manyargs.ml
- manytests/typed/005fix.ml
- manytests/typed/006partial2.ml
- manytests/typed/006partial3.ml
- manytests/typed/006partial.ml
- manytests/typed/007order.ml
- manytests/typed/008ascription.ml
- manytests/typed/009let_poly.ml
- manytests/typed/010sukharev.ml
- manytests/typed/015tuples.ml
- manytests/typed/016lists.ml
- manytests/do_not_type/001.ml
- manytests/do_not_type/002if.ml
- manytests/do_not_type/003occurs.ml
- manytests/do_not_type/004let_poly.ml
- manytests/do_not_type/005.ml
- manytests/do_not_type/015tuples.ml
- manytests/do_not_type/016tuples_mismatch.ml
- manytests/do_not_type/097fun_vs_list.ml
- manytests/do_not_type/097fun_vs_unit.ml
- manytests/do_not_type/098rec_int.ml
- manytests/do_not_type/099.ml))
diff --git a/ETenyaeva/tests/inferencer.ml b/ETenyaeva/tests/inferencer.ml
deleted file mode 100644
index d65793b49..000000000
--- a/ETenyaeva/tests/inferencer.ml
+++ /dev/null
@@ -1,142 +0,0 @@
-(** Copyright 2024-2025, Ekaterina Tenyaeva *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open ETenyaeva_lib.Parser
-
-(* open ETenyaeva_lib.Ast *)
-open ETenyaeva_lib.Inferencer
-
-let run input =
- match parse input with
- | Ok ast ->
- (match run_inferencer empty_env ast with
- | Ok (_, out_list) ->
- List.iter
- (function
- | Some id, type' -> Format.printf "val %s : %a\n" id pp_type type'
- | None, type' -> Format.printf "- : %a\n" pp_type type')
- out_list
- | Error e -> Format.printf "Inferencer error: %a\n" pp_error e)
- | Error _ -> Format.printf "Parsing error\n"
-;;
-
-let%expect_test "parsing error" =
- run {|
- let a = ;;
- |};
- [%expect {|
- Parsing error
- |}]
-;;
-
-let%expect_test "const" =
- run {|
- 1;;
- |};
- [%expect {|
- - : int
- |}]
-;;
-
-let%expect_test "const list" =
- run {|
- [1; 2; 3; 4];;
- |};
- [%expect {|
- - : int list
- |}]
-;;
-
-let%expect_test "binary oper with const" =
- run {|
- 1 + 3 - 400 / 3 * 2;;
- |};
- [%expect {|
- - : int
- |}]
-;;
-
-let%expect_test "unary oper with const" =
- run {|
- not false;; -2
- |};
- [%expect {|
- - : bool
- - : int
- |}]
-;;
-
-let%expect_test "match" =
- run {|
- match 1 + 2 with
- | 3 -> 4
- | _ -> 3
- ;;
- |};
- [%expect {|
- - : int
- |}]
-;;
-
-let%expect_test "type check negative expression" =
- run {|
- let f a q = -(if a then q else -q)
- |};
- [%expect {|
- val f : bool -> int -> int
- |}]
-;;
-
-let%expect_test "type check definition tuple" =
- run {|
- let (a, b) = (1, 2);;
- |};
- [%expect {|
- val a : int
- val b : int
- |}]
-;;
-
-let%expect_test "type check several definition variable" =
- run {|
- let f = 1 and r = "qwe";; let q = 2
- |};
- [%expect {|
- val f : int
- val r : string
- val q : int
- |}]
-;;
-
-let%expect_test "type check several recursive definition" =
- run {|
- let rec f1 a = a + 1 and f2 b = f1 b;;
- |};
- [%expect {|
- val f1 : int -> int
- val f2 : int -> int
- |}]
-;;
-
-let%expect_test "type check lenght" =
- run {|
- let rec length xs =
- match xs with
- | [] -> 0
- | h::tl -> 1 + length tl
- |};
- [%expect {|
- val length : 'a list -> int
- |}]
-;;
-
-let%expect_test "type check let and" =
- run {|
- let rec f1 a = a + 1 and f2 b = f1 b;;
- |};
- [%expect {|
- val f1 : int -> int
- val f2 : int -> int
- |}]
-;;
diff --git a/ETenyaeva/tests/inferencer.mli b/ETenyaeva/tests/inferencer.mli
deleted file mode 100644
index 72580acbb..000000000
--- a/ETenyaeva/tests/inferencer.mli
+++ /dev/null
@@ -1,3 +0,0 @@
-(** Copyright 2024-2025, Ekaterina Tenyaeva *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
diff --git a/ETenyaeva/tests/inferencer_mantests_typed.t b/ETenyaeva/tests/inferencer_mantests_typed.t
deleted file mode 100644
index 5566f0c3f..000000000
--- a/ETenyaeva/tests/inferencer_mantests_typed.t
+++ /dev/null
@@ -1,79 +0,0 @@
- $ cat manytests/typed/001fac.ml | ../bin/REPL.exe --dinference
- val fac : int -> int
- val main : int
-
- $ cat manytests/typed/002fac.ml | ../bin/REPL.exe --dinference
- val fac_cps : int -> (int -> 'a) -> 'a
- val main : int
-
- $ cat manytests/typed/003fib.ml | ../bin/REPL.exe --dinference
- val fib_acc : int -> int -> int -> int
- val fib : int -> int
- val main : int
-
- $ cat manytests/typed/004manyargs.ml | ../bin/REPL.exe --dinference
- val wrap : 'a -> 'a
- val test3 : int -> int -> int -> int
- val test10 : int -> int -> int -> int -> int -> int -> int -> int -> int -> int -> int
- val main : int
-
- $ cat manytests/typed/005fix.ml | ../bin/REPL.exe --dinference
- val fix : (('a -> 'b) -> 'a -> 'b) -> 'a -> 'b
- val fac : (int -> int) -> int -> int
- val main : int
-
- $ cat manytests/typed/006partial.ml | ../bin/REPL.exe --dinference
- val foo : int -> int
- val main : int
-
- $ cat manytests/typed/006partial2.ml | ../bin/REPL.exe --dinference
- val foo : int -> int -> int -> int
- val main : int
-
- $ cat manytests/typed/006partial3.ml | ../bin/REPL.exe --dinference
- val foo : int -> int -> int -> unit
- val main : int
-
- $ cat manytests/typed/007order.ml | ../bin/REPL.exe --dinference
- val _start : unit -> unit -> int -> unit -> int -> int -> unit -> int -> int -> int
- val main : unit
-
- $ cat manytests/typed/008ascription.ml | ../bin/REPL.exe --dinference
- val addi : ('a -> bool -> int) -> ('a -> bool) -> 'a -> int
- val main : int
-
- $ cat manytests/typed/009let_poly.ml | ../bin/REPL.exe --dinference
- val temp : int * bool
-
- $ cat manytests/typed/010sukharev.ml | ../bin/REPL.exe --dinference
- val _1 : int -> int -> int * 'a -> bool
- val _2 : int
- val _3 : (int * string) option
- val _4 : int -> 'a
- val _5 : int
- val _6 : 'a option -> 'a
- val int_of_option : int option -> int
- val _42 : int -> bool
- val id1 : 'a -> 'a
- val id2 : 'b -> 'b
-
- $ cat manytests/typed/015tuples.ml | ../bin/REPL.exe --dinference
- val fix : (('a -> 'b) -> 'a -> 'b) -> 'a -> 'b
- val map : ('b -> 'a) -> 'b * 'b -> 'a * 'a
- val fixpoly : (('a -> 'b) * ('a -> 'b) -> 'a -> 'b) * (('a -> 'b) * ('a -> 'b) -> 'a -> 'b) -> ('a -> 'b) * ('a -> 'b)
- val feven : 'a * (int -> int) -> int -> int
- val fodd : (int -> int) * 'a -> int -> int
- val tie : (int -> int) * (int -> int)
- val meven : int -> int
- val modd : int -> int
- val main : int
-
- $ cat manytests/typed/016lists.ml | ../bin/REPL.exe --dinference
- val length : 'a list -> int
- val length_tail : 'a list -> int
- val map : ('a -> 'b) -> 'a list -> 'b list
- val append : 'a list -> 'a list -> 'a list
- val concat : ('a list) list -> 'a list
- val iter : ('a -> unit) -> 'a list -> unit
- val cartesian : 'b list -> 'a list -> ('b * 'a) list
- val main : int
diff --git a/ETenyaeva/tests/inferencer_manytests_do_not_type.t b/ETenyaeva/tests/inferencer_manytests_do_not_type.t
deleted file mode 100644
index f55aa0425..000000000
--- a/ETenyaeva/tests/inferencer_manytests_do_not_type.t
+++ /dev/null
@@ -1,39 +0,0 @@
- $ cat ./manytests/do_not_type/001.ml | ../bin/REPL.exe --dinference
- Inferencer error: Unbound variable fac'.
-
- $ cat ./manytests/do_not_type/002if.ml | ../bin/REPL.exe --dinference
- Inferencer error: Failed to unify types: int and bool
-
-
- $ cat ./manytests/do_not_type/003occurs.ml | ../bin/REPL.exe --dinference
- Inferencer error: Occurs check failed. Type variable 'ty1 occurs inside 'ty1 -> 'ty3
-
-
- $ cat ./manytests/do_not_type/004let_poly.ml | ../bin/REPL.exe --dinference
- Inferencer error: Failed to unify types: int and bool
-
-
- $ cat ./manytests/do_not_type/005.ml | ../bin/REPL.exe --dinference
- Inferencer error: Failed to unify types: string and int
-
-
- $ cat ./manytests/do_not_type/015tuples.ml | ../bin/REPL.exe --dinference
- Inferencer error: Only variables are allowed as left-hand side of `let rec'
-
- $ cat ./manytests/do_not_type/016tuples_mismatch.ml | ../bin/REPL.exe --dinference
- Inferencer error: Failed to unify types: int * int * int and 'ty0 * 'ty1
-
-
- $ cat ./manytests/do_not_type/097fun_vs_list.ml | ../bin/REPL.exe --dinference
- Inferencer error: Failed to unify types: 'ty0 -> 'ty0 and 'ty2 list
-
-
- $ cat ./manytests/do_not_type/097fun_vs_unit.ml | ../bin/REPL.exe --dinference
- Inferencer error: Failed to unify types: 'ty0 -> 'ty0 and unit
-
-
- $ cat ./manytests/do_not_type/098rec_int.ml | ../bin/REPL.exe --dinference
- Inferencer error: This kind of expression is not allowed as right-hand side of `let rec'
-
- $ cat ./manytests/do_not_type/099.ml | ../bin/REPL.exe --dinference
- Inferencer error: Only variables are allowed as left-hand side of `let rec'
diff --git a/ETenyaeva/tests/interpreter.ml b/ETenyaeva/tests/interpreter.ml
deleted file mode 100644
index 4386cc7a9..000000000
--- a/ETenyaeva/tests/interpreter.ml
+++ /dev/null
@@ -1,117 +0,0 @@
-(** Copyright 2024-2025, Ekaterina Tenyaeva *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open ETenyaeva_lib.Parser
-open ETenyaeva_lib.Interpreter
-
-let run input =
- match parse input with
- | Ok ast ->
- (match run_interpreter env_with_print_funs ast with
- | Ok (_, out_list) ->
- List.iter
- (function
- | Some id, val' -> Format.printf "val %s = %a\n" id pp_value val'
- | None, val' -> Format.printf "- = %a\n" pp_value val')
- out_list
- | Error e -> Format.printf "Interpreter error: %a\n" pp_error e)
- | Error err -> Stdlib.Format.printf "%s\n" err
-;;
-
-let%expect_test "eval simple let binding" =
- run {|
- let a = -(4 + 4)
- and b = true;;
- |};
- [%expect {|
- val a = -8
- val b = true
- |}]
-;;
-
-let%expect_test "eval tuple and list let bindings" =
- run {|
- let a, b = 1, (2, 3);;
- let [ c; d ] = 3::4::[]
- |};
- [%expect {|
- val a = 1
- val b = (2, 3)
- val c = 3
- val d = 4
- |}]
-;;
-
-let%expect_test "eval `let in'" =
- run {|
- let f =
- let x = "abc" in
- let y = "qwerty" in
- x <> y
- ;;
- |};
- [%expect {|
- val f = true
- |}]
-;;
-
-let%expect_test "eval 'Struct_eval'" =
- run {|
- 1;;
- |};
- [%expect {|
- - = 1
- |}]
-;;
-
-let%expect_test "eval 'Exp_fun'" =
- run {|
- let foo x y = x * y
- let q = foo 1 6
- let w = foo 2 (-5)
- |};
- [%expect {|
- val foo =
- val q = 6
- val w = -10
- |}]
-;;
-
-let%expect_test "eval recursive value binding 1" =
- run {|
- let rec x = 21 and y = x + 1;;
- |};
- [%expect {|
- val x = 21
- val y = 22
- |}]
-;;
-
-let%expect_test "eval recursive value binding 2" =
- run
- {|
- let rec factorial n = if n <= 1 then 1 else n * factorial (n - 1);;
- factorial 5
- |};
- [%expect {|
- val factorial =
- - = 120
- |}]
-;;
-
-let%expect_test "eval pattern-matching" =
- run
- {|
- let f =
- match [ 1; 2; 3 ] with
- | a :: [] -> a
- | a :: b :: [] -> a + b
- | a :: b :: c :: [] -> a + b + c
- | _ -> 0
- ;;
- |};
- [%expect {|
- val f = 6
- |}]
-;;
diff --git a/ETenyaeva/tests/interpreter.mli b/ETenyaeva/tests/interpreter.mli
deleted file mode 100644
index 72580acbb..000000000
--- a/ETenyaeva/tests/interpreter.mli
+++ /dev/null
@@ -1,3 +0,0 @@
-(** Copyright 2024-2025, Ekaterina Tenyaeva *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
diff --git a/ETenyaeva/tests/interpreter_mantests_typed.t b/ETenyaeva/tests/interpreter_mantests_typed.t
deleted file mode 100644
index cb5d7a180..000000000
--- a/ETenyaeva/tests/interpreter_mantests_typed.t
+++ /dev/null
@@ -1,112 +0,0 @@
- $ cat manytests/typed/001fac.ml | ../bin/REPL.exe
- 24
- val fac =
- val main = 0
-
- $ cat manytests/typed/002fac.ml | ../bin/REPL.exe
- 24
- val fac_cps =
- val main = 0
-
- $ cat manytests/typed/003fib.ml | ../bin/REPL.exe
- 3
- 3
- val fib_acc =
- val fib =
- val main = 0
-
- $ cat manytests/typed/004manyargs.ml | ../bin/REPL.exe
- 1111111111
- 1
- 10
- 100
- val wrap =
- val test3 =
- val test10 =
- val main = 0
-
- $ cat manytests/typed/005fix.ml | ../bin/REPL.exe
- 720
- val fix =
- val fac =
- val main = 0
-
- $ cat manytests/typed/006partial.ml | ../bin/REPL.exe
- 1122
- val foo =
- val main = 0
-
- $ cat manytests/typed/006partial2.ml | ../bin/REPL.exe
- 1
- 2
- 3
- 7
- val foo =
- val main = 0
-
- $ cat manytests/typed/006partial3.ml | ../bin/REPL.exe
- 4
- 8
- 9
- val foo =
- val main = 0
-
- $ cat manytests/typed/007order.ml | ../bin/REPL.exe
- 1
- 2
- 4
- -1
- 103
- -555555
- 10000
- val _start =
- val main = ()
-
- $ cat manytests/typed/008ascription.ml | ../bin/REPL.exe
- 8
- val addi =
- val main = 0
-
- $ cat manytests/typed/009let_poly.ml | ../bin/REPL.exe
- val temp = (1, true)
-
- $ cat manytests/typed/010sukharev.ml | ../bin/REPL.exe
- val _1 =
- val _2 = 1
- val _3 = Some (1, "hi")
- val _4 =
- val _5 = 42
- val _6 =
- val int_of_option =
- val _42 =
- val id1 =
- val id2 =
-
- $ cat manytests/typed/015tuples.ml | ../bin/REPL.exe
- 1
- 1
- 1
- 1
- val fix =
- val map =
- val fixpoly =
- val feven =
- val fodd =
- val tie = (, )
- val meven =
- val modd =
- val main = 0
-
- $ cat manytests/typed/016lists.ml | ../bin/REPL.exe
- 1
- 2
- 3
- 8
- val length =
- val length_tail =
- val map =
- val append =
- val concat =
- val iter =
- val cartesian =
- val main = 0
diff --git a/ETenyaeva/tests/manytests b/ETenyaeva/tests/manytests
deleted file mode 120000
index 0bd48791d..000000000
--- a/ETenyaeva/tests/manytests
+++ /dev/null
@@ -1 +0,0 @@
-../../manytests
\ No newline at end of file
diff --git a/ETenyaeva/tests/parser.ml b/ETenyaeva/tests/parser.ml
deleted file mode 100644
index 6b39ec6d0..000000000
--- a/ETenyaeva/tests/parser.ml
+++ /dev/null
@@ -1,459 +0,0 @@
-(** Copyright 2024-2025, Ekaterina Tenyaeva *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open ETenyaeva_lib.Parser
-open ETenyaeva_lib.Ast
-
-let run input =
- match parse input with
- | Ok structure -> Stdlib.Format.printf "%s\n" (show_structure structure)
- | Error err -> Stdlib.Format.printf "%s\n" err
-;;
-
-let%expect_test "parse_multiple_bindings" =
- run "let x = 10;; let y = x + 5;;";
- [%expect
- {|
- [(Binding (NonRec, { pat = (PatVar "x"); expr = (ExpConst (Int 10)) }, []));
- (Binding (NonRec,
- { pat = (PatVar "y");
- expr = (ExpBinOper (Add, (ExpVar "x"), (ExpConst (Int 5)))) },
- []))
- ]|}]
-;;
-
-let%expect_test "parse_list_construct_case" =
- run "a::b::c::[];;";
- [%expect
- {|
- [(EvalExp
- (ExpListConstructor
- [(ExpVar "a"); (ExpVar "b"); (ExpVar "c"); (ExpList [])]))
- ]
-|}]
-;;
-
-let%expect_test "parse_application" =
- run "fact (n - 1);;";
- [%expect
- {|
- [(EvalExp
- (ExpApp ((ExpVar "fact"),
- (ExpBinOper (Sub, (ExpVar "n"), (ExpConst (Int 1)))))))
- ] |}]
-;;
-
-let%expect_test "parse_multiple_evaluations" =
- run "1 + 1;; 2 + 2;;";
- [%expect
- {|
- [(EvalExp (ExpBinOper (Add, (ExpConst (Int 1)), (ExpConst (Int 1)))));
- (EvalExp (ExpBinOper (Add, (ExpConst (Int 2)), (ExpConst (Int 2)))))] |}]
-;;
-
-let%expect_test "parse_case_expression" =
- run "match x with | 1 -> \"one\" | 2 -> \"two\";;";
- [%expect
- {|
- [(EvalExp
- (ExpMatch ((ExpVar "x"),
- { case_pat = (PatConst (Int 1)); case_expr = (ExpConst (String "one"))
- },
- [{ case_pat = (PatConst (Int 2));
- case_expr = (ExpConst (String "two")) }
- ]
- )))
- ] |}]
-;;
-
-let%expect_test "parse_tuple" =
- run "(1, 2, 3);;";
- [%expect
- {|
- [(EvalExp
- (ExpTup ((ExpConst (Int 1)), (ExpConst (Int 2)), [(ExpConst (Int 3))])))
- ] |}]
-;;
-
-let%expect_test "parse_eval;;" =
- run "1 + 1";
- [%expect
- {|
- [(EvalExp (ExpBinOper (Add, (ExpConst (Int 1)), (ExpConst (Int 1)))))] |}]
-;;
-
-let%expect_test "parse_sub_without_ws" =
- run "n-1;;";
- [%expect {|
- [(EvalExp (ExpBinOper (Sub, (ExpVar "n"), (ExpConst (Int 1)))))]|}]
-;;
-
-let%expect_test "parse_brackets" =
- run "(((1 + 2) * 3));;";
- [%expect
- {|
- [(EvalExp
- (ExpBinOper (Mult,
- (ExpBinOper (Add, (ExpConst (Int 1)), (ExpConst (Int 2)))),
- (ExpConst (Int 3)))))
- ] |}]
-;;
-
-let%expect_test "parse_factorial" =
- run "let rec fact n = if n <= 1 then 1 else n * fact (n - 1);;";
- [%expect
- {|
- [(Binding (Rec,
- { pat = (PatVar "fact");
- expr =
- (ExpFun ((PatVar "n"),
- (ExpIfThenElse (
- (ExpBinOper (LessEquals, (ExpVar "n"), (ExpConst (Int 1)))),
- (ExpConst (Int 1)),
- (Some (ExpBinOper (Mult, (ExpVar "n"),
- (ExpApp ((ExpVar "fact"),
- (ExpBinOper (Sub, (ExpVar "n"), (ExpConst (Int 1))))
- ))
- )))
- ))
- ))
- },
- []))
- ] |}]
-;;
-
-let%expect_test "parse_arithmetic" =
- run "1 + 2 * 3;;";
- [%expect
- {|
- [(EvalExp
- (ExpBinOper (Add, (ExpConst (Int 1)),
- (ExpBinOper (Mult, (ExpConst (Int 2)), (ExpConst (Int 3)))))))
- ] |}]
-;;
-
-let%expect_test "parse_ifthen" =
- run "let ifthen n = if n > 0 then 1";
- [%expect
- {|
- [(Binding (NonRec,
- { pat = (PatVar "ifthen");
- expr =
- (ExpFun ((PatVar "n"),
- (ExpIfThenElse (
- (ExpBinOper (GreaterThan, (ExpVar "n"), (ExpConst (Int 0)))),
- (ExpConst (Int 1)), None))
- ))
- },
- []))
- ] |}]
-;;
-
-let%expect_test "parse_ifthen_without_else" =
- run "if x > 0 then x + 4 ";
- [%expect
- {|
- [(EvalExp
- (ExpIfThenElse (
- (ExpBinOper (GreaterThan, (ExpVar "x"), (ExpConst (Int 0)))),
- (ExpBinOper (Add, (ExpVar "x"), (ExpConst (Int 4)))), None)))
- ] |}]
-;;
-
-let%expect_test "parse_list" =
- run "let lst = [1; 2; 3]";
- [%expect
- {|
- [(Binding (NonRec,
- { pat = (PatVar "lst");
- expr =
- (ExpList [(ExpConst (Int 1)); (ExpConst (Int 2)); (ExpConst (Int 3))])
- },
- []))
- ] |}]
-;;
-
-let%expect_test "parse_with_type" =
- run "let (x : int) = 5;;";
- [%expect
- {|
- [(Binding (NonRec,
- { pat = (PatWithTyp (TypInt, (PatVar "x"))); expr = (ExpConst (Int 5)) },
- []))
- ] |}]
-;;
-
-let%expect_test "parse_with_type2" =
- run "let add (a : int) (b : int) =\n a + b;;";
- [%expect
- {|
- [(Binding (NonRec,
- { pat = (PatVar "add");
- expr =
- (ExpFun ((PatWithTyp (TypInt, (PatVar "a"))),
- (ExpFun ((PatWithTyp (TypInt, (PatVar "b"))),
- (ExpBinOper (Add, (ExpVar "a"), (ExpVar "b")))))
- ))
- },
- []))
- ] |}]
-;;
-
-let%expect_test "fibonacci" =
- run "let rec fibo n = if n < 2 then 1 else fibo(n - 1) + fibo(n - 2) ;;";
- [%expect
- {|
- [(Binding (Rec,
- { pat = (PatVar "fibo");
- expr =
- (ExpFun ((PatVar "n"),
- (ExpIfThenElse (
- (ExpBinOper (LessThan, (ExpVar "n"), (ExpConst (Int 2)))),
- (ExpConst (Int 1)),
- (Some (ExpBinOper (Add,
- (ExpApp ((ExpVar "fibo"),
- (ExpBinOper (Sub, (ExpVar "n"), (ExpConst (Int 1))))
- )),
- (ExpApp ((ExpVar "fibo"),
- (ExpBinOper (Sub, (ExpVar "n"), (ExpConst (Int 2))))
- ))
- )))
- ))
- ))
- },
- []))
- ]
-|}]
-;;
-
-let%expect_test "lambda_test" =
- run "let add x = fun y -> x + y;;";
- [%expect
- {|
- [(Binding (NonRec,
- { pat = (PatVar "add");
- expr =
- (ExpFun ((PatVar "x"),
- (ExpFun ((PatVar "y"),
- (ExpBinOper (Add, (ExpVar "x"), (ExpVar "y")))))
- ))
- },
- []))
- ]
-|}]
-;;
-
-let%expect_test "lambda_test_2" =
- run "let add x = fun y -> y b;;";
- [%expect
- {|
- [(Binding (NonRec,
- { pat = (PatVar "add");
- expr =
- (ExpFun ((PatVar "x"),
- (ExpFun ((PatVar "y"), (ExpApp ((ExpVar "y"), (ExpVar "b")))))))
- },
- []))
- ]
-|}]
-;;
-
-let%expect_test "lambda_test_3" =
- run
- "let foo a =\n\
- \ let () = print_int a in fun b ->\n\
- \ let () = print_int b in fun c ->\n\
- \ print_int c\n";
- [%expect
- {|
- [(Binding (NonRec,
- { pat = (PatVar "foo");
- expr =
- (ExpFun ((PatVar "a"),
- (ExpLet (NonRec,
- { pat = (PatConst Unit);
- expr = (ExpApp ((ExpVar "print_int"), (ExpVar "a"))) },
- [],
- (ExpFun ((PatVar "b"),
- (ExpLet (NonRec,
- { pat = (PatConst Unit);
- expr = (ExpApp ((ExpVar "print_int"), (ExpVar "b"))) },
- [],
- (ExpFun ((PatVar "c"),
- (ExpApp ((ExpVar "print_int"), (ExpVar "c")))))
- ))
- ))
- ))
- ))
- },
- []))
- ]
-|}]
-;;
-
-let%expect_test "test_tuple" =
- run "let x = (1, 2, true);;";
- [%expect
- {|
- [(Binding (NonRec,
- { pat = (PatVar "x");
- expr =
- (ExpTup ((ExpConst (Int 1)), (ExpConst (Int 2)),
- [(ExpConst (Bool true))]))
- },
- []))
- ]
-|}]
-;;
-
-let%expect_test "test_annotate_type" =
- run "let (a : int list) = [] ";
- [%expect
- {|
-[(Binding (NonRec,
- { pat = (PatWithTyp (TypInt, (PatVar "a"))); expr = (ExpList []) },
- []))
- ]
-|}]
-;;
-
-let%expect_test "test_arithmetic2" =
- run "-1 -2 - (-1) -(3)";
- [%expect
- {|
-[(EvalExp
- (ExpUnOper (Neg,
- (ExpBinOper (Sub,
- (ExpBinOper (Sub,
- (ExpBinOper (Sub, (ExpConst (Int 1)), (ExpConst (Int 2)))),
- (ExpUnOper (Neg, (ExpConst (Int 1)))))),
- (ExpConst (Int 3))))
- )))
- ]
- |}]
-;;
-
-let%expect_test "test_let-match" =
- run
- "let _5 =\n\
- \ let id x = x in\n\
- \ match Some id with\n\
- \ | Some f -> let _ = f \"42\" in f 42\n\
- \ | None -> 0";
- [%expect
- {|
-[(Binding (NonRec,
- { pat = (PatVar "_5");
- expr =
- (ExpLet (NonRec,
- { pat = (PatVar "id"); expr = (ExpFun ((PatVar "x"), (ExpVar "x")))
- },
- [],
- (ExpMatch ((ExpOption (Some (ExpVar "id"))),
- { case_pat = (PatOption (Some (PatVar "f")));
- case_expr =
- (ExpLet (NonRec,
- { pat = PatAny;
- expr = (ExpApp ((ExpVar "f"), (ExpConst (String "42")))) },
- [], (ExpApp ((ExpVar "f"), (ExpConst (Int 42))))))
- },
- [{ case_pat = (PatOption None); case_expr = (ExpConst (Int 0)) }]
- ))
- ))
- },
- []))
- ]
- |}]
-;;
-
-let%expect_test "test_fib" =
- run "let rec fib n =\n if n<2\n then n\n else fib (n - 1) + fib (n - 2)";
- [%expect
- {|
-[(Binding (Rec,
- { pat = (PatVar "fib");
- expr =
- (ExpFun ((PatVar "n"),
- (ExpIfThenElse (
- (ExpBinOper (LessThan, (ExpVar "n"), (ExpConst (Int 2)))),
- (ExpVar "n"),
- (Some (ExpBinOper (Add,
- (ExpApp ((ExpVar "fib"),
- (ExpBinOper (Sub, (ExpVar "n"), (ExpConst (Int 1))))
- )),
- (ExpApp ((ExpVar "fib"),
- (ExpBinOper (Sub, (ExpVar "n"), (ExpConst (Int 2))))
- ))
- )))
- ))
- ))
- },
- []))
- ]
- |}]
-;;
-
-let%expect_test "test_partial" =
- run
- "let foo a b c =\n\
- \ let () = print_int a in\n\
- \ let () = print_int b in\n\
- \ let () = print_int c in\n\
- \ a + b * c";
- [%expect
- {|
-[(Binding (NonRec,
- { pat = (PatVar "foo");
- expr =
- (ExpFun ((PatVar "a"),
- (ExpFun ((PatVar "b"),
- (ExpFun ((PatVar "c"),
- (ExpLet (NonRec,
- { pat = (PatConst Unit);
- expr = (ExpApp ((ExpVar "print_int"), (ExpVar "a"))) },
- [],
- (ExpLet (NonRec,
- { pat = (PatConst Unit);
- expr = (ExpApp ((ExpVar "print_int"), (ExpVar "b"))) },
- [],
- (ExpLet (NonRec,
- { pat = (PatConst Unit);
- expr =
- (ExpApp ((ExpVar "print_int"), (ExpVar "c"))) },
- [],
- (ExpBinOper (Add, (ExpVar "a"),
- (ExpBinOper (Mult, (ExpVar "b"), (ExpVar "c")))))
- ))
- ))
- ))
- ))
- ))
- ))
- },
- []))
- ]
- |}]
-;;
-
-let%expect_test "parse_let_and" =
- run {|
- let x = 10 and y = 3 + 5 and z = (1, true, ("katya", "nastya"));;
- |};
- [%expect
- {|
- [(Binding (NonRec, { pat = (PatVar "x"); expr = (ExpConst (Int 10)) },
- [{ pat = (PatVar "y");
- expr = (ExpBinOper (Add, (ExpConst (Int 3)), (ExpConst (Int 5)))) };
- { pat = (PatVar "z");
- expr =
- (ExpTup ((ExpConst (Int 1)), (ExpConst (Bool true)),
- [(ExpTup ((ExpConst (String "katya")),
- (ExpConst (String "nastya")), []))
- ]
- ))
- }
- ]
- ))
- ] |}]
-;;
diff --git a/ETenyaeva/tests/parser.mli b/ETenyaeva/tests/parser.mli
deleted file mode 100644
index 72580acbb..000000000
--- a/ETenyaeva/tests/parser.mli
+++ /dev/null
@@ -1,3 +0,0 @@
-(** Copyright 2024-2025, Ekaterina Tenyaeva *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
diff --git a/EUsoltsev/.envrc b/EUsoltsev/.envrc
deleted file mode 100644
index e6bd6786d..000000000
--- a/EUsoltsev/.envrc
+++ /dev/null
@@ -1,3 +0,0 @@
-export OPAMSWITCH=4.14.2+flambda
-eval $(opam env)
-
diff --git a/EUsoltsev/.gitignore b/EUsoltsev/.gitignore
deleted file mode 100644
index 7102a822c..000000000
--- a/EUsoltsev/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-_build
-_coverage
-/_esy
-/node_modules
-/esy.lock
-/.melange.eobjs
diff --git a/EUsoltsev/.ocamlformat b/EUsoltsev/.ocamlformat
deleted file mode 100644
index 97f970802..000000000
--- a/EUsoltsev/.ocamlformat
+++ /dev/null
@@ -1,2 +0,0 @@
-profile=janestreet
-version=0.26.2
diff --git a/EUsoltsev/.zanuda b/EUsoltsev/.zanuda
deleted file mode 100644
index 0f09b19b2..000000000
--- a/EUsoltsev/.zanuda
+++ /dev/null
@@ -1 +0,0 @@
-forward mutability_check ignore REPL.ml
diff --git a/EUsoltsev/COPYING b/EUsoltsev/COPYING
deleted file mode 100644
index f288702d2..000000000
--- a/EUsoltsev/COPYING
+++ /dev/null
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is 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. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- 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.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- 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 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. Use with the GNU Affero General Public License.
-
- 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 Affero 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 special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU 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 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 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 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.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- Copyright (C)
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- 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 GPL, see
-.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-.
diff --git a/EUsoltsev/COPYING.CC0 b/EUsoltsev/COPYING.CC0
deleted file mode 100644
index 0e259d42c..000000000
--- a/EUsoltsev/COPYING.CC0
+++ /dev/null
@@ -1,121 +0,0 @@
-Creative Commons Legal Code
-
-CC0 1.0 Universal
-
- CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
- LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
- ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
- INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
- REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
- PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
- THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
- HEREUNDER.
-
-Statement of Purpose
-
-The laws of most jurisdictions throughout the world automatically confer
-exclusive Copyright and Related Rights (defined below) upon the creator
-and subsequent owner(s) (each and all, an "owner") of an original work of
-authorship and/or a database (each, a "Work").
-
-Certain owners wish to permanently relinquish those rights to a Work for
-the purpose of contributing to a commons of creative, cultural and
-scientific works ("Commons") that the public can reliably and without fear
-of later claims of infringement build upon, modify, incorporate in other
-works, reuse and redistribute as freely as possible in any form whatsoever
-and for any purposes, including without limitation commercial purposes.
-These owners may contribute to the Commons to promote the ideal of a free
-culture and the further production of creative, cultural and scientific
-works, or to gain reputation or greater distribution for their Work in
-part through the use and efforts of others.
-
-For these and/or other purposes and motivations, and without any
-expectation of additional consideration or compensation, the person
-associating CC0 with a Work (the "Affirmer"), to the extent that he or she
-is an owner of Copyright and Related Rights in the Work, voluntarily
-elects to apply CC0 to the Work and publicly distribute the Work under its
-terms, with knowledge of his or her Copyright and Related Rights in the
-Work and the meaning and intended legal effect of CC0 on those rights.
-
-1. Copyright and Related Rights. A Work made available under CC0 may be
-protected by copyright and related or neighboring rights ("Copyright and
-Related Rights"). Copyright and Related Rights include, but are not
-limited to, the following:
-
- i. the right to reproduce, adapt, distribute, perform, display,
- communicate, and translate a Work;
- ii. moral rights retained by the original author(s) and/or performer(s);
-iii. publicity and privacy rights pertaining to a person's image or
- likeness depicted in a Work;
- iv. rights protecting against unfair competition in regards to a Work,
- subject to the limitations in paragraph 4(a), below;
- v. rights protecting the extraction, dissemination, use and reuse of data
- in a Work;
- vi. database rights (such as those arising under Directive 96/9/EC of the
- European Parliament and of the Council of 11 March 1996 on the legal
- protection of databases, and under any national implementation
- thereof, including any amended or successor version of such
- directive); and
-vii. other similar, equivalent or corresponding rights throughout the
- world based on applicable law or treaty, and any national
- implementations thereof.
-
-2. Waiver. To the greatest extent permitted by, but not in contravention
-of, applicable law, Affirmer hereby overtly, fully, permanently,
-irrevocably and unconditionally waives, abandons, and surrenders all of
-Affirmer's Copyright and Related Rights and associated claims and causes
-of action, whether now known or unknown (including existing as well as
-future claims and causes of action), in the Work (i) in all territories
-worldwide, (ii) for the maximum duration provided by applicable law or
-treaty (including future time extensions), (iii) in any current or future
-medium and for any number of copies, and (iv) for any purpose whatsoever,
-including without limitation commercial, advertising or promotional
-purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
-member of the public at large and to the detriment of Affirmer's heirs and
-successors, fully intending that such Waiver shall not be subject to
-revocation, rescission, cancellation, termination, or any other legal or
-equitable action to disrupt the quiet enjoyment of the Work by the public
-as contemplated by Affirmer's express Statement of Purpose.
-
-3. Public License Fallback. Should any part of the Waiver for any reason
-be judged legally invalid or ineffective under applicable law, then the
-Waiver shall be preserved to the maximum extent permitted taking into
-account Affirmer's express Statement of Purpose. In addition, to the
-extent the Waiver is so judged Affirmer hereby grants to each affected
-person a royalty-free, non transferable, non sublicensable, non exclusive,
-irrevocable and unconditional license to exercise Affirmer's Copyright and
-Related Rights in the Work (i) in all territories worldwide, (ii) for the
-maximum duration provided by applicable law or treaty (including future
-time extensions), (iii) in any current or future medium and for any number
-of copies, and (iv) for any purpose whatsoever, including without
-limitation commercial, advertising or promotional purposes (the
-"License"). The License shall be deemed effective as of the date CC0 was
-applied by Affirmer to the Work. Should any part of the License for any
-reason be judged legally invalid or ineffective under applicable law, such
-partial invalidity or ineffectiveness shall not invalidate the remainder
-of the License, and in such case Affirmer hereby affirms that he or she
-will not (i) exercise any of his or her remaining Copyright and Related
-Rights in the Work or (ii) assert any associated claims and causes of
-action with respect to the Work, in either case contrary to Affirmer's
-express Statement of Purpose.
-
-4. Limitations and Disclaimers.
-
- a. No trademark or patent rights held by Affirmer are waived, abandoned,
- surrendered, licensed or otherwise affected by this document.
- b. Affirmer offers the Work as-is and makes no representations or
- warranties of any kind concerning the Work, express, implied,
- statutory or otherwise, including without limitation warranties of
- title, merchantability, fitness for a particular purpose, non
- infringement, or the absence of latent or other defects, accuracy, or
- the present or absence of errors, whether or not discoverable, all to
- the greatest extent permissible under applicable law.
- c. Affirmer disclaims responsibility for clearing rights of other persons
- that may apply to the Work or any use thereof, including without
- limitation any person's Copyright and Related Rights in the Work.
- Further, Affirmer disclaims responsibility for obtaining any necessary
- consents, permissions or other rights required for any use of the
- Work.
- d. Affirmer understands and acknowledges that Creative Commons is not a
- party to this document and has no duty or obligation with respect to
- this CC0 or use of the Work.
diff --git a/EUsoltsev/COPYING.LESSER b/EUsoltsev/COPYING.LESSER
deleted file mode 100644
index 0a041280b..000000000
--- a/EUsoltsev/COPYING.LESSER
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser 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
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/EUsoltsev/DONT_REMOVE_THIS_DIRECTORY.md b/EUsoltsev/DONT_REMOVE_THIS_DIRECTORY.md
deleted file mode 100644
index e0530079f..000000000
--- a/EUsoltsev/DONT_REMOVE_THIS_DIRECTORY.md
+++ /dev/null
@@ -1,3 +0,0 @@
-This file should be contained in template directoty `Lambda`.
-You should remove it when you copy `Lambda` for your
-personal pet project.
diff --git a/EUsoltsev/EUsoltsev.opam b/EUsoltsev/EUsoltsev.opam
deleted file mode 100644
index 96c01087a..000000000
--- a/EUsoltsev/EUsoltsev.opam
+++ /dev/null
@@ -1,37 +0,0 @@
-# This file is generated by dune, edit dune-project instead
-opam-version: "2.0"
-version: "0.1"
-synopsis: "An interpreter for MiniML language"
-description:
- "FIXME. A longer description, for example, which are the most interesing features being supported, etc."
-maintainer: ["Danil Usoltsev"]
-authors: ["Danil Usoltsev"]
-license: "LGPL-3.0-or-later"
-homepage: "https://github.com/Kakadu/fp2024"
-doc: "https://kakadu.github.io/fp2024/docs/Lambda"
-bug-reports: "https://github.com/Kakadu/fp2024"
-depends: [
- "dune" {>= "3.7"}
- "angstrom"
- "ppx_inline_test" {with-test}
- "ppx_expect"
- "ppx_deriving"
- "bisect_ppx"
- "odoc" {with-doc}
- "ocamlformat" {build}
- "base"
-]
-build: [
- ["dune" "subst"] {dev}
- [
- "dune"
- "build"
- "-p"
- name
- "-j"
- jobs
- "@install"
- "@runtest" {with-test}
- "@doc" {with-doc}
- ]
-]
diff --git a/EUsoltsev/Makefile b/EUsoltsev/Makefile
deleted file mode 100644
index 79fbb624c..000000000
--- a/EUsoltsev/Makefile
+++ /dev/null
@@ -1,49 +0,0 @@
-.PHONY: repl tests test fmt lint celan
-
-all:
- dune build
-
-repl:
- dune build ./REPL.exe && rlwrap _build/default/REPL.exe
-
-tests: test
-test:
- dune runtest
-
-celan: clean
-clean:
- @$(RM) -r _build _coverage
-
-fmt:
- dune build @fmt --auto-promote
-
-lint:
- dune build @lint --force
-
-release:
- dune build --profile=release
- dune runtest --profile=release
-
-install:
- dune b @install --profile=release
- dune install
-
-ODIG_SWITCHES = --odoc-theme=odig.gruvbox.light
-ODIG_SWITCHES += --no-tag-index
-ODIG_SWITCHES += --no-pkg-deps
-odig:
- odig odoc $(ODIG_SWITCHES) Lambda
-
-TEST_COV_D = /tmp/cov
-COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect tests/
-
-.PHONY: test_coverage coverage
-test_coverage: coverage
-coverage:
- $(RM) -r $(TEST_COV_D)
- mkdir -p $(TEST_COV_D)
- BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \
- --instrument-with bisect_ppx --force
- bisect-ppx-report html $(COVERAGE_OPTS)
- bisect-ppx-report summary $(COVERAGE_OPTS)
- @echo "Use 'xdg-open _coverage/index.html' to see coverage report"
diff --git a/EUsoltsev/bin/dune b/EUsoltsev/bin/dune
deleted file mode 100644
index 1bccdb570..000000000
--- a/EUsoltsev/bin/dune
+++ /dev/null
@@ -1,6 +0,0 @@
-(executable
- (name main)
- (public_name main)
- (libraries EUsoltsev_lib)
- (instrumentation
- (backend bisect_ppx)))
diff --git a/EUsoltsev/bin/main.ml b/EUsoltsev/bin/main.ml
deleted file mode 100644
index 3073e6861..000000000
--- a/EUsoltsev/bin/main.ml
+++ /dev/null
@@ -1,82 +0,0 @@
-(** Copyright 2024-2025, Danil Usoltsev *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open EUsoltsev_lib
-open Inferencer
-open Interpreter
-open Parser
-open Printf
-open Ast
-
-let run_inference input =
- match parse input with
- | Ok parsed ->
- (match run_infer parsed with
- | Ok env ->
- let filtered_env =
- Base.Map.filter_keys env ~f:(fun key ->
- not (List.mem key [ "print_int"; "print_endline"; "print_bool" ]))
- in
- Base.Map.iteri filtered_env ~f:(fun ~key ~data:(S (_, ty)) ->
- Format.printf "val %s: %a\n" key pp_ty ty)
- | Error e -> Format.printf "Infer error. %a\n" pp_error e)
- | Error e -> Format.printf "Parsing error. %s\n" e
-;;
-
-let run_interpreter s =
- let open Stdlib.Format in
- match Parser.parse s with
- | Ok parsed ->
- (match Inter.eval_structure parsed with
- | Ok _ -> ()
- | Error e -> printf "Interpreter error: %a\n" pp_value_error e)
- | Error e -> printf "Parsing error: %s\n" e
-;;
-
-let read_file filename =
- let channel = open_in filename in
- let content = really_input_string channel (in_channel_length channel) in
- close_in channel;
- content
-;;
-
-type config =
- { infer_flag : bool
- ; interpret_flag : bool
- ; file : string option
- ; input : string option
- }
-
-let parse_arguments () =
- let rec parse_args args config =
- match args with
- | [] -> config
- | "-infer" :: rest -> parse_args rest { config with infer_flag = true }
- | "-interpret" :: rest -> parse_args rest { config with interpret_flag = true }
- | "-file" :: filename :: rest -> parse_args rest { config with file = Some filename }
- | arg :: rest -> parse_args rest { config with input = Some arg }
- in
- parse_args
- (Array.to_list Sys.argv |> List.tl)
- { infer_flag = false; interpret_flag = false; file = None; input = None }
-;;
-
-let main () =
- let config = parse_arguments () in
- let input_content =
- match config.file with
- | Some filename -> read_file filename
- | None ->
- (match config.input with
- | Some s -> s
- | None -> "")
- in
- if config.infer_flag
- then run_inference input_content
- else if config.interpret_flag
- then run_interpreter input_content
- else printf "Please specify either -infer or -interpret flag.\n"
-;;
-
-let () = main ()
diff --git a/EUsoltsev/dune b/EUsoltsev/dune
deleted file mode 100644
index 0ef8774ec..000000000
--- a/EUsoltsev/dune
+++ /dev/null
@@ -1,16 +0,0 @@
-(env
- (dev
- (flags
- (:standard -alert @deprecated -warn-error -A -w -3-9-32-34-58)))
- (release
- (flags
- (:standard -alert @deprecated -warn-error +A -w +A-4-40-42-44-70))))
-
-; (executable
-; (name REPL)
-; (public_name REPL)
-; (modules REPL)
-; (libraries lambda_lib stdio))
-
-; (cram
-; (deps ./REPL.exe %{bin:REPL}))
diff --git a/EUsoltsev/dune-project b/EUsoltsev/dune-project
deleted file mode 100644
index 754811a92..000000000
--- a/EUsoltsev/dune-project
+++ /dev/null
@@ -1,35 +0,0 @@
-(lang dune 3.7)
-
-(generate_opam_files true)
-
-(cram enable)
-
-(license LGPL-3.0-or-later)
-
-(authors "Danil Usoltsev")
-
-(maintainers "Danil Usoltsev")
-
-(bug_reports "https://github.com/Kakadu/fp2024")
-
-(homepage "https://github.com/Kakadu/fp2024")
-
-(package
- (name EUsoltsev) ; FIXME and regenerate .opam file using 'dune build @install'
- (synopsis "An interpreter for MiniML language")
- (description
- "FIXME. A longer description, for example, which are the most interesing features being supported, etc.")
- (documentation "https://kakadu.github.io/fp2024/docs/Lambda")
- (version 0.1)
- (depends
- dune
- angstrom
- (ppx_inline_test :with-test)
- ppx_expect
- ppx_deriving
- bisect_ppx
- (odoc :with-doc)
- (ocamlformat :build)
- base
- ; After adding dependencies to 'dune' files and the same dependecies here too
- ))
diff --git a/EUsoltsev/lib/ast.ml b/EUsoltsev/lib/ast.ml
deleted file mode 100644
index 1c23fe76d..000000000
--- a/EUsoltsev/lib/ast.ml
+++ /dev/null
@@ -1,103 +0,0 @@
-(** Copyright 2024-2025, Danil Usoltsev *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Format
-
-type ident = string [@@deriving show { with_path = false }]
-type is_rec = bool [@@deriving show { with_path = false }]
-
-type bin_oper =
- | Plus (* [+] *)
- | Minus (* [-] *)
- | Multiply (* [*] *)
- | Division (* [/] *)
- | And (* [&&] *)
- | Or (* [||] *)
- | GretestEqual (* [>=] *)
- | LowestEqual (* [<=] *)
- | GreaterThan (* [>] *)
- | LowerThan (* [<] *)
- | Equal (* [=] *)
- | NotEqual (* [<>] *)
-[@@deriving show { with_path = false }]
-
-type unar_oper =
- | Negative (* [-x] *)
- | Not (* [not x]*)
-[@@deriving show { with_path = false }]
-
-type const =
- | ConstInt of int (* Integer constant: Example - [21] *)
- | ConstBool of bool (* Boolean constant: Example - [true] or [false] *)
- | ConstString of string (* String constant: Example - "I like OCaml!" *)
-[@@deriving show { with_path = false }]
-
-type binder = int [@@deriving show { with_path = false }]
-
-type ty =
- | TyVar of binder
- | TyPrim of string
- | TyArrow of ty * ty
- | TyList of ty
- | TyTuple of ty list
- | TyOption of ty
-[@@deriving show { with_path = false }]
-
-type pattern =
- | PatVariable of ident (* [x] *)
- | PatConst of const (* [21] or [true] or [false] *)
- | PatTuple of pattern * pattern * pattern list (* (x1; x2 ... xn) *)
- | PatAny
- | PatType of pattern * ty
- | PatUnit
- | PatList of pattern list
- | PatOption of pattern option
-[@@deriving show { with_path = false }]
-
-type expr =
- | ExpIdent of ident (* ExpIdent "x" *)
- | ExpConst of const (* ExpConst (ConstInt 666) *)
- | ExpBranch of expr * expr * expr option
- | ExpBinOper of bin_oper * expr * expr (* ExpBinOper(Plus, 1, 2) *)
- | ExpUnarOper of unar_oper * expr (* ExpUnarOper(not, x)*)
- | ExpTuple of expr * expr * expr list (* ExpTuple[x1; x2 .. xn] *)
- | ExpList of expr list (* ExpList[x1; x2 .. xn] *)
- | ExpLambda of pattern list * expr (* ExpLambda([x;y;z], x+y+z)*)
- | ExpTypeAnnotation of expr * ty
- | ExpLet of is_rec * bind * bind list * expr
- | ExpFunction of expr * expr (* ExpFunction(x, y)*)
- | ExpOption of expr option
-[@@deriving show { with_path = false }]
-
-and bind = pattern * expr [@@deriving show { with_path = false }]
-
-type structure =
- | SEval of expr
- | SValue of is_rec * bind * bind list
-[@@deriving show { with_path = false }]
-
-type program = structure list [@@deriving show { with_path = false }]
-
-let rec pp_ty fmt = function
- | TyPrim x -> fprintf fmt "%s" x
- | TyVar x -> fprintf fmt "'%d" x
- | TyArrow (l, r) ->
- (match l, r with
- | TyArrow _, _ -> fprintf fmt "(%a) -> %a" pp_ty l pp_ty r
- | _, _ -> fprintf fmt "%a -> %a" pp_ty l pp_ty r)
- | TyTuple elems ->
- fprintf
- fmt
- "(%a)"
- (pp_print_list ~pp_sep:(fun fmt () -> fprintf fmt " * ") pp_ty)
- elems
- | TyList ty ->
- (match ty with
- | TyArrow _ | TyTuple _ -> fprintf fmt "(%a) list" pp_ty ty
- | _ -> fprintf fmt "%a list" pp_ty ty)
- | TyOption ty ->
- (match ty with
- | TyArrow _ | TyTuple _ -> fprintf fmt "(%a) option" pp_ty ty
- | _ -> fprintf fmt "%a option" pp_ty ty)
-;;
diff --git a/EUsoltsev/lib/dune b/EUsoltsev/lib/dune
deleted file mode 100644
index fd5a33446..000000000
--- a/EUsoltsev/lib/dune
+++ /dev/null
@@ -1,9 +0,0 @@
-(library
- (name EUsoltsev_lib)
- (public_name EUsoltsev.Lib)
- (modules Inferencer Ast Parser Interpreter)
- (libraries base angstrom)
- (preprocess
- (pps ppx_deriving.show))
- (instrumentation
- (backend bisect_ppx)))
diff --git a/EUsoltsev/lib/inferencer.ml b/EUsoltsev/lib/inferencer.ml
deleted file mode 100644
index 15e8caf16..000000000
--- a/EUsoltsev/lib/inferencer.ml
+++ /dev/null
@@ -1,657 +0,0 @@
-(** Copyright 2024-2025, Danil Usoltsev *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-(* Template: https://gitlab.com/Kakadu/fp2020course-materials/-/tree/master/code/miniml?ref_type=heads*)
-
-open Base
-open Ast
-open Stdlib.Format
-
-type error =
- | OccursCheck of int * ty
- | NoVariable of string
- | UnificationFailed of ty * ty
- | SeveralBounds of string
- | LHS of string
- | RHS of string
- | UnexpectedFunction of ty
-
-let pp_error fmt = function
- | OccursCheck (id, ty) ->
- fprintf fmt "Occurs check failed. Type variable '%d occurs inside %a." id pp_ty ty
- | NoVariable name -> fprintf fmt "Unbound variable '%s'." name
- | UnificationFailed (ty1, ty2) ->
- fprintf fmt "Failed to unify types: %a and %a." pp_ty ty1 pp_ty ty2
- | SeveralBounds name -> fprintf fmt "Multiple bounds for variable '%s'." name
- | LHS msg -> fprintf fmt "Left-hand side error: %s." msg
- | RHS msg -> fprintf fmt "Right-hand side error: %s." msg
- | UnexpectedFunction ty1 -> fprintf fmt "UnexpectedFunction error: %a" pp_ty ty1
-;;
-
-module IntSet = struct
- include Stdlib.Set.Make (Int)
-end
-
-module ResultMonad : sig
- type 'a t
-
- val return : 'a -> 'a t
- val fail : error -> 'a t
-
- include Monad.Infix with type 'a t := 'a t
-
- module Syntax : sig
- val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t
- end
-
- val fresh : int t
- val run : 'a t -> ('a, error) Result.t
-
- module RMap : sig
- val fold : ('a, 'b, 'c) Map.t -> init:'d t -> f:('a -> 'b -> 'd -> 'd t) -> 'd t
- end
-end = struct
- type 'a t = int -> int * ('a, error) Result.t
-
- let ( >>= ) m f state =
- let last, r = m state in
- match r with
- | Result.Error x -> last, Result.fail x
- | Result.Ok a -> f a last
- ;;
-
- let return x last = last, Result.return x
- let fail e st = st, Result.fail e
-
- let ( >>| ) m f st =
- match m st with
- | st, Ok x -> st, Result.return (f x)
- | st, Result.Error e -> st, Result.fail e
- ;;
-
- module Syntax = struct
- let ( let* ) = ( >>= )
- end
-
- module RMap = struct
- let fold map ~init ~f =
- Map.fold map ~init ~f:(fun ~key ~data acc ->
- let open Syntax in
- let* acc = acc in
- f key data acc)
- ;;
- end
-
- let fresh : int t = fun last -> last + 1, Result.return last
- let run monad = snd (monad 0)
-end
-
-module Type = struct
- let rec occurs_in var = function
- | TyVar b -> b = var
- | TyArrow (left, right) -> occurs_in var left || occurs_in var right
- | TyTuple types -> List.exists types ~f:(occurs_in var)
- | TyList ty -> occurs_in var ty
- | TyOption ty -> occurs_in var ty
- | TyPrim _ -> false
- ;;
-
- let free_vars =
- let rec helper acc = function
- | TyVar b -> IntSet.add b acc
- | TyArrow (left, right) -> helper (helper acc left) right
- | TyTuple types -> List.fold_left types ~init:acc ~f:helper
- | TyList ty -> helper acc ty
- | TyOption ty -> helper acc ty
- | TyPrim _ -> acc
- in
- helper IntSet.empty
- ;;
-end
-
-module Substitution : sig
- type t
-
- val empty : t
- val singleton : int -> ty -> t ResultMonad.t
- val remove : t -> int -> t
- val apply : t -> ty -> ty
- val unify : ty -> ty -> t ResultMonad.t
- val compose : t -> t -> t ResultMonad.t
- val compose_all : t list -> t ResultMonad.t
-end = struct
- open ResultMonad
- open ResultMonad.Syntax
-
- type t = (int, ty, Int.comparator_witness) Map.t
-
- let empty = Map.empty (module Int)
-
- let mapping key value =
- if Type.occurs_in key value
- then fail (OccursCheck (key, value))
- else return (key, value)
- ;;
-
- let singleton key value =
- let* key, value = mapping key value in
- return (Map.singleton (module Int) key value)
- ;;
-
- let find = Map.find
- let remove = Map.remove
-
- let apply subst =
- let rec helper = function
- | TyPrim x -> TyPrim x
- | TyVar b as ty ->
- (match find subst b with
- | None -> ty
- | Some x -> x)
- | TyArrow (left, right) -> TyArrow (helper left, helper right)
- | TyList ty -> TyList (helper ty)
- | TyOption ty -> TyOption (helper ty)
- | TyTuple types -> TyTuple (List.map ~f:helper types)
- in
- helper
- ;;
-
- let rec unify left right =
- match left, right with
- | TyPrim l, TyPrim r when String.equal l r -> return empty
- | TyPrim _, TyPrim _ -> fail (UnificationFailed (left, right))
- | TyVar l, TyVar r when l = r -> return empty
- | TyVar b, ty | ty, TyVar b -> singleton b ty
- | TyArrow (left1, right1), TyArrow (left2, right2) ->
- let* subst1 = unify left1 left2 in
- let* subst2 = unify (apply subst1 right1) (apply subst1 right2) in
- compose subst1 subst2
- | TyTuple types1, TyTuple types2 ->
- if List.length types1 <> List.length types2
- then fail (UnificationFailed (left, right))
- else (
- let rec unify_tuples subst types1 types2 =
- match types1, types2 with
- | [], [] -> return subst
- | t1 :: rest1, t2 :: rest2 ->
- let* subst' = unify (apply subst t1) (apply subst t2) in
- let* composed_subst = compose subst subst' in
- unify_tuples composed_subst rest1 rest2
- | _, _ -> fail (UnificationFailed (left, right))
- in
- unify_tuples empty types1 types2)
- | TyList ty1, TyList ty2 -> unify ty1 ty2
- | TyOption ty1, TyOption ty2 -> unify ty1 ty2
- | _ -> fail (UnificationFailed (left, right))
-
- and extend key value subst =
- match find subst key with
- | None ->
- let value = apply subst value in
- let* subst2 = singleton key value in
- RMap.fold subst ~init:(return subst2) ~f:(fun key value acc ->
- let value = apply subst2 value in
- let* key, value = mapping key value in
- return (Map.update acc key ~f:(fun _ -> value)))
- | Some value2 ->
- let* subst2 = unify value value2 in
- compose subst subst2
-
- and compose subst1 subst2 = RMap.fold subst2 ~init:(return subst1) ~f:extend
-
- let compose_all =
- List.fold_left ~init:(return empty) ~f:(fun acc subst ->
- let* acc = acc in
- compose acc subst)
- ;;
-end
-
-module Scheme = struct
- type t = S of IntSet.t * ty
-
- let free_vars (S (vars, ty)) = IntSet.diff (Type.free_vars ty) vars
-
- let apply subst (S (vars, ty)) =
- let subst2 =
- IntSet.fold (fun key subst -> Substitution.remove subst key) vars subst
- in
- S (vars, Substitution.apply subst2 ty)
- ;;
-end
-
-module TypeEnv = struct
- type t = (ident, Scheme.t, String.comparator_witness) Map.t
-
- let extend env key value = Map.update env key ~f:(fun _ -> value)
-
- let free_vars : t -> IntSet.t =
- Map.fold ~init:IntSet.empty ~f:(fun ~key:_ ~data:scheme acc ->
- IntSet.union acc (Scheme.free_vars scheme))
- ;;
-
- let apply subst env = Map.map env ~f:(Scheme.apply subst)
- let find = Map.find
-
- let initial_env =
- let open Base.Map in
- empty (module String)
- |> set
- ~key:"print_int"
- ~data:(Scheme.S (IntSet.empty, TyArrow (TyPrim "int", TyPrim "unit")))
- |> set
- ~key:"print_endline"
- ~data:(Scheme.S (IntSet.empty, TyArrow (TyPrim "string", TyPrim "unit")))
- |> set
- ~key:"print_bool"
- ~data:(Scheme.S (IntSet.empty, TyArrow (TyPrim "bool", TyPrim "unit")))
- ;;
-end
-
-open ResultMonad
-open ResultMonad.Syntax
-
-let fresh_var = fresh >>| fun n -> TyVar n
-
-let instantiate : Scheme.t -> ty ResultMonad.t =
- fun (S (vars, ty)) ->
- IntSet.fold
- (fun var typ ->
- let* typ = typ in
- let* fresh_ty = fresh_var in
- let* subst = Substitution.singleton var fresh_ty in
- return (Substitution.apply subst typ))
- vars
- (return ty)
-;;
-
-let generalize env ty =
- let free = IntSet.diff (Type.free_vars ty) (TypeEnv.free_vars env) in
- Scheme.S (free, ty)
-;;
-
-let infer_const = function
- | ConstInt _ -> TyPrim "int"
- | ConstBool _ -> TyPrim "bool"
- | ConstString _ -> TyPrim "string"
-;;
-
-let rec infer_pattern env = function
- | PatAny ->
- let* fresh = fresh_var in
- return (Substitution.empty, fresh, env)
- | PatConst const -> return (Substitution.empty, infer_const const, env)
- | PatVariable var ->
- let* fresh = fresh_var in
- let env = TypeEnv.extend env var (Scheme.S (IntSet.empty, fresh)) in
- return (Substitution.empty, fresh, env)
- | PatTuple (first_pat, second_pat, rest_pats) ->
- let* sub_first, type_first, env_first = infer_pattern env first_pat in
- let updated_env_second = TypeEnv.apply sub_first env_first in
- let* sub_second, type_second, env_second =
- infer_pattern updated_env_second second_pat
- in
- let process_remaining_patterns acc pat =
- let open ResultMonad.Syntax in
- let* current_sub, types, current_env = acc in
- let* sub_new, type_new, env_new = infer_pattern current_env pat in
- let* combined_sub = Substitution.compose current_sub sub_new in
- return (combined_sub, type_new :: types, env_new)
- in
- let initial_state = return (sub_second, [ type_second; type_first ], env_second) in
- let* final_sub, collected_types, final_env =
- List.fold_left rest_pats ~init:initial_state ~f:process_remaining_patterns
- in
- let tuple_type = TyTuple (List.rev collected_types) in
- return (final_sub, tuple_type, final_env)
- | PatList pats ->
- let* fresh_el_type = fresh_var in
- let* final_sub, final_env =
- List.fold_left
- pats
- ~init:(return (Substitution.empty, env))
- ~f:(fun acc pat ->
- let open ResultMonad.Syntax in
- let* sub_acc, env_acc = acc in
- let* sub_cur, el_type, env_cur = infer_pattern env_acc pat in
- let* unified_sub = Substitution.compose sub_acc sub_cur in
- let* final_sub =
- Substitution.unify (Substitution.apply sub_cur fresh_el_type) el_type
- in
- let* combined_sub = Substitution.compose unified_sub final_sub in
- return (combined_sub, TypeEnv.apply final_sub env_cur))
- in
- return (final_sub, TyList (Substitution.apply final_sub fresh_el_type), final_env)
- | PatOption opt ->
- let* sub, typ, env =
- match opt with
- | None ->
- let* fresh = fresh_var in
- return (Substitution.empty, fresh, env)
- | Some p -> infer_pattern env p
- in
- return (sub, TyOption typ, env)
- | PatType (pat, annotated_ty) ->
- let* subst, inferred_ty, env = infer_pattern env pat in
- let* unified_subst = Substitution.unify inferred_ty annotated_ty in
- let* total_subst = Substitution.compose subst unified_subst in
- return
- ( total_subst
- , Substitution.apply total_subst annotated_ty
- , TypeEnv.apply total_subst env )
- | PatUnit -> return (Substitution.empty, TyPrim "unit", env)
-;;
-
-let infer_binop_type = function
- | Equal | NotEqual | GreaterThan | GretestEqual | LowerThan | LowestEqual ->
- fresh_var >>| fun fresh_ty -> fresh_ty, fresh_ty, TyPrim "bool"
- | Plus | Minus | Multiply | Division -> return (TyPrim "int", TyPrim "int", TyPrim "int")
- | And | Or -> return (TyPrim "bool", TyPrim "bool", TyPrim "bool")
-;;
-
-let rec infer_expr env = function
- | ExpConst const -> return (Substitution.empty, infer_const const)
- | ExpIdent var ->
- (match TypeEnv.find env var with
- | Some scheme ->
- let* ty = instantiate scheme in
- return (Substitution.empty, ty)
- | None -> fail (NoVariable var))
- | ExpUnarOper (operation, expr) ->
- let* subst, ty = infer_expr env expr in
- let* operation_type =
- match operation with
- | Negative -> return (TyArrow (TyPrim "int", TyPrim "int"))
- | Not -> return (TyArrow (TyPrim "bool", TyPrim "bool"))
- in
- let* subst2 =
- match operation_type with
- | TyArrow (arg, _) -> Substitution.unify ty arg
- | ty -> fail (UnexpectedFunction ty)
- in
- let* subst2 = Substitution.compose_all [ subst2; subst ] in
- (match operation_type with
- | TyArrow (_, x) -> return (subst2, Substitution.apply subst2 x)
- | ty -> fail (UnexpectedFunction ty))
- | ExpBinOper (op, expr1, expr2) ->
- let* subst1, ty = infer_expr env expr1 in
- let* subst2, ty' = infer_expr (TypeEnv.apply subst1 env) expr2 in
- let* ty1_op, ty2_op, ty_res = infer_binop_type op in
- let* subst3 = Substitution.unify (Substitution.apply subst2 ty) ty1_op in
- let* subst4 = Substitution.unify (Substitution.apply subst3 ty') ty2_op in
- let* subst = Substitution.compose_all [ subst1; subst2; subst3; subst4 ] in
- return (subst, Substitution.apply subst ty_res)
- | ExpBranch (cond, then_expr, else_expr) ->
- let* subst1, ty1 = infer_expr env cond in
- let* subst2, ty2 = infer_expr (TypeEnv.apply subst1 env) then_expr in
- let* ty3 =
- match else_expr with
- | Some el ->
- let* _, ty3 = infer_expr (TypeEnv.apply subst2 env) el in
- return ty3
- | None -> return (TyPrim "unit")
- in
- let* subst4 = Substitution.unify ty1 (TyPrim "bool") in
- let* subst5 = Substitution.unify ty2 ty3 in
- let* total_subst =
- match else_expr with
- | Some el ->
- let* subst3, _ = infer_expr (TypeEnv.apply subst2 env) el in
- Substitution.compose_all [ subst5; subst4; subst3; subst2; subst1 ]
- | None -> Substitution.compose_all [ subst5; subst4; subst2; subst1 ]
- in
- return (total_subst, Substitution.apply total_subst ty2)
- | ExpTuple (expr1, expr2, exprs) ->
- let* subst1, ty1 = infer_expr env expr1 in
- let* subst2, ty2 = infer_expr (TypeEnv.apply subst1 env) expr2 in
- let infer_tuple_elements env es =
- let rec aux env = function
- | [] -> return ([], [])
- | e :: es' ->
- let* s, t = infer_expr env e in
- let* s', ts = aux (TypeEnv.apply s env) es' in
- return (s' @ [ s ], t :: ts)
- in
- aux env es
- in
- let* subst3, tys = infer_tuple_elements (TypeEnv.apply subst2 env) exprs in
- let* subst = Substitution.compose_all (subst3 @ [ subst2; subst1 ]) in
- return (subst, TyTuple (ty1 :: ty2 :: tys))
- | ExpList exprs ->
- (match exprs with
- | [] ->
- let* fresh = fresh_var in
- return (Substitution.empty, TyList fresh)
- | _ :: _ ->
- let infer_list_elements env es =
- let rec aux env = function
- | [] -> return ([], [])
- | e :: es' ->
- let* s, t = infer_expr env e in
- let* s', ts = aux (TypeEnv.apply s env) es' in
- return (s' @ [ s ], t :: ts)
- in
- aux env es
- in
- let* subst, tys = infer_list_elements env exprs in
- let* total_subst = Substitution.compose_all subst in
- (match tys with
- | [] -> fail (SeveralBounds "inferred empty list type")
- | ty :: _ -> return (total_subst, TyList ty)))
- | ExpLet (false, (PatVariable x, expr1), _, expr2) ->
- let* subst1, ty1 = infer_expr env expr1 in
- let env2 = TypeEnv.apply subst1 env in
- let ty_gen = generalize env2 ty1 in
- let env3 = TypeEnv.extend env x ty_gen in
- let* subst2, ty2 = infer_expr (TypeEnv.apply subst1 env3) expr2 in
- let* total_subst = Substitution.compose subst1 subst2 in
- return (total_subst, ty2)
- | ExpLet (false, (pattern, expr1), bindings, expr2) ->
- let* subst1, ty1 = infer_expr env expr1 in
- let* subst2, ty_pat, env1 = infer_pattern env pattern in
- let* subst = Substitution.compose subst1 subst2 in
- let* unified_subst = Substitution.unify (Substitution.apply subst ty_pat) ty1 in
- let initial_env = TypeEnv.apply unified_subst env1 in
- let* extended_env =
- List.fold_left
- ~f:(fun acc_env (pattern, expr) ->
- let* acc_env = acc_env in
- let* subst_bind, ty_bind = infer_expr acc_env expr in
- let* subst_pattern, _, env_pattern = infer_pattern acc_env pattern in
- let* combined_subst = Substitution.compose subst_bind subst_pattern in
- let* final_subst =
- Substitution.unify (Substitution.apply combined_subst ty_pat) ty_bind
- in
- let updated_env =
- Map.fold
- ~init:(TypeEnv.apply final_subst acc_env)
- ~f:(fun ~key ~data acc_env -> TypeEnv.extend acc_env key data)
- (TypeEnv.apply final_subst env_pattern)
- in
- return updated_env)
- ~init:(return initial_env)
- bindings
- in
- let* subst3, ty2 = infer_expr extended_env expr2 in
- let* total_subst = Substitution.compose_all [ subst3; unified_subst; subst ] in
- return (total_subst, ty2)
- | ExpLet (true, (PatVariable x, expr1), [], expr2) ->
- let* expr1 =
- match expr1 with
- | ExpLambda _ -> return expr1
- | _ -> fail (RHS "Right-hand side of let rec must be a lambda expression")
- in
- let* tv = fresh_var in
- let env2 = TypeEnv.extend env x (S (IntSet.empty, tv)) in
- let* subst1, ty1 = infer_expr env2 expr1 in
- let* subst2 = Substitution.unify (Substitution.apply subst1 tv) ty1 in
- let* subst_total = Substitution.compose subst1 subst2 in
- let env3 = TypeEnv.apply subst_total env in
- let env4 = TypeEnv.apply subst1 env3 in
- let ty_gen = generalize env4 (Substitution.apply subst_total tv) in
- let* subst3, ty2 = infer_expr (TypeEnv.extend env4 x ty_gen) expr2 in
- let* subst_total = Substitution.compose subst_total subst3 in
- return (subst_total, ty2)
- | ExpLet (true, value_binding, value_bindings, expr2) ->
- let* env_ext, subst_acc =
- List.fold_left
- ~f:(fun acc_env (pat, expr) ->
- let* expr =
- match expr with
- | ExpLambda _ -> return expr
- | _ -> fail (RHS "Right-hand side of let rec must be a lambda expression")
- in
- let* pat =
- match pat with
- | PatVariable _ -> return pat
- | _ ->
- fail (LHS "Only variables are allowed on the left-hand side of let rec")
- in
- let* env_acc, _ = acc_env in
- let* subst_expr, ty_expr = infer_expr env_acc expr in
- let* subst_pattern, ty_pat, env_pat = infer_pattern env_acc pat in
- let* subst = Substitution.compose subst_expr subst_pattern in
- let* unified_subst = Substitution.unify ty_expr ty_pat in
- let* combined_subst = Substitution.compose subst unified_subst in
- let extended_env = TypeEnv.apply combined_subst env_pat in
- return (extended_env, combined_subst))
- ~init:(return (env, Substitution.empty))
- (value_binding :: value_bindings)
- in
- let* subst2, ty2 = infer_expr env_ext expr2 in
- let* total_subst = Substitution.compose subst_acc subst2 in
- return (total_subst, ty2)
- | ExpLambda (patterns, body) ->
- let* env, pat_types =
- List.fold_left
- patterns
- ~init:(return (env, []))
- ~f:(fun acc pat ->
- let* env, pat_types = acc in
- let* _, typ, env = infer_pattern env pat in
- return (env, typ :: pat_types))
- in
- let* subst_body, ty_body = infer_expr env body in
- let arrow_type =
- List.fold_right
- ~f:(fun pat_type acc -> TyArrow (Substitution.apply subst_body pat_type, acc))
- ~init:ty_body
- (List.rev pat_types)
- in
- return (subst_body, arrow_type)
- | ExpFunction (param, body) ->
- let* subst1, ty1 = infer_expr env param in
- let* subst2, ty2 = infer_expr (TypeEnv.apply subst1 env) body in
- let* tv = fresh_var in
- let* subst3 =
- Substitution.unify (Substitution.apply subst2 ty1) (TyArrow (ty2, tv))
- in
- let* total_subst = Substitution.compose_all [ subst3; subst2; subst1 ] in
- return (total_subst, Substitution.apply total_subst tv)
- | ExpOption opt_expr ->
- (match opt_expr with
- | Some expr ->
- let* subst, ty = infer_expr env expr in
- return (subst, TyOption ty)
- | None ->
- let* tv = fresh_var in
- return (Substitution.empty, TyOption tv))
- | ExpTypeAnnotation (expr, t) ->
- let* subst1, ty1 = infer_expr env expr in
- let* subst2 = Substitution.unify ty1 (Substitution.apply subst1 t) in
- let* total_subst = Substitution.compose subst1 subst2 in
- return (total_subst, Substitution.apply subst2 ty1)
-;;
-
-let infer_structure_item env = function
- | SEval expr ->
- let* subst, _ = infer_expr env expr in
- let updated_env = TypeEnv.apply subst env in
- return (subst, updated_env)
- | SValue (true, (PatVariable x, expr), []) ->
- let* expr =
- match expr with
- | ExpLambda _ -> return expr
- | _ -> fail (RHS "Right-hand side of let rec must be a lambda expression")
- in
- let* tv = fresh_var in
- let env = TypeEnv.extend env x (S (IntSet.empty, tv)) in
- let* subst, ty = infer_expr env expr in
- let* subst2 = Substitution.unify (Substitution.apply subst tv) ty in
- let* composed_subst = Substitution.compose subst subst2 in
- let env2 = TypeEnv.apply composed_subst env in
- let generalized_ty = generalize env2 (Substitution.apply composed_subst ty) in
- let env = TypeEnv.extend env2 x generalized_ty in
- return (composed_subst, env)
- | SValue (true, value_binding, value_bindings) ->
- let all_bindings = value_binding :: value_bindings in
- let* env_with_placeholders =
- List.fold_left
- ~f:(fun acc_env (pat, _) ->
- let* pat =
- match pat with
- | PatVariable _ -> return pat
- | _ ->
- fail (LHS "Only variables are allowed on the left-hand side of let rec")
- in
- let* env_acc = acc_env in
- let* subst_pat, _, env_pat = infer_pattern env_acc pat in
- let extended_env = TypeEnv.apply subst_pat env_pat in
- return extended_env)
- ~init:(return env)
- all_bindings
- in
- let* env_ext, subst_acc =
- List.fold_left
- ~f:(fun acc_env (ty_pattern, expr) ->
- let* expr =
- match expr with
- | ExpLambda _ -> return expr
- | _ -> fail (RHS "Right-hand side of let rec must be a lambda expression")
- in
- let* env_acc, _ = acc_env in
- let* subst_expr, ty_expr = infer_expr env_acc expr in
- let* subst_pat, ty_pat, env_pat = infer_pattern env_acc ty_pattern in
- let* subst = Substitution.compose subst_expr subst_pat in
- let* unified_subst = Substitution.unify ty_expr ty_pat in
- let* combined_subst = Substitution.compose subst unified_subst in
- let extended_env = TypeEnv.apply combined_subst env_pat in
- return (extended_env, combined_subst))
- ~init:(return (env_with_placeholders, Substitution.empty))
- all_bindings
- in
- return (subst_acc, env_ext)
- | SValue (false, (PatVariable x, expr), _) ->
- let* subst, ty = infer_expr env expr in
- let env2 = TypeEnv.apply subst env in
- let generalized_ty = generalize env2 ty in
- let env = TypeEnv.extend (TypeEnv.apply subst env) x generalized_ty in
- return (subst, env)
- | SValue (false, (pattern, expr), _) ->
- let* subst_expr, ty = infer_expr env expr in
- let* subst_pat, ty_pat, env_pat = infer_pattern env pattern in
- let* combined_subst = Substitution.compose subst_expr subst_pat in
- let* unified_subst =
- Substitution.unify (Substitution.apply combined_subst ty_pat) ty
- in
- let updated_env = TypeEnv.apply unified_subst env_pat in
- let* final_subst = Substitution.compose unified_subst combined_subst in
- return (final_subst, updated_env)
-;;
-
-let infer_structure env structure =
- let rec process_structure env subst = function
- | [] -> return (subst, env)
- | item :: rest ->
- let* subst1, env1 = infer_structure_item env item in
- let* composed_subst = Substitution.compose subst subst1 in
- process_structure env1 composed_subst rest
- in
- process_structure env Substitution.empty structure
-;;
-
-let infer_simple_expression expr =
- Result.map ~f:snd (run (infer_expr TypeEnv.initial_env expr))
-;;
-
-let run_infer str = Result.map ~f:snd (run (infer_structure TypeEnv.initial_env str))
diff --git a/EUsoltsev/lib/inferencer.mli b/EUsoltsev/lib/inferencer.mli
deleted file mode 100644
index bd19629ab..000000000
--- a/EUsoltsev/lib/inferencer.mli
+++ /dev/null
@@ -1,32 +0,0 @@
-(** Copyright 2024-2025, Danil Usoltsev *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-open Base
-
-module IntSet : sig
- type t = Stdlib.Set.Make(Int).t
-end
-
-type error =
- | OccursCheck of int * ty
- | NoVariable of string
- | UnificationFailed of ty * ty
- | SeveralBounds of string
- | LHS of string
- | RHS of string
- | UnexpectedFunction of ty
-
-val pp_error : Stdlib.Format.formatter -> error -> unit
-
-module Scheme : sig
- type t = S of IntSet.t * ty
-end
-
-module TypeEnv : sig
- type t = (ident, Scheme.t, String.comparator_witness) Map.t
-end
-
-val infer_simple_expression : expr -> (ty, error) Result.t
-val run_infer : Ast.program -> (TypeEnv.t, error) Result.t
diff --git a/EUsoltsev/lib/interpreter.ml b/EUsoltsev/lib/interpreter.ml
deleted file mode 100644
index 2928fcd49..000000000
--- a/EUsoltsev/lib/interpreter.ml
+++ /dev/null
@@ -1,414 +0,0 @@
-(** Copyright 2024-2025, Danil Usoltsev *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-open Base
-open Stdlib.Format
-
-type env = (ident, value, String.comparator_witness) Map.t
-
-and value =
- | ValueInt of int
- | ValueBool of bool
- | ValueString of string
- | ValueUnit
- | ValueClosure of is_rec * pattern * pattern list * expr * env
- | ValueTuple of value * value * value list
- | ValueList of value list
- | ValueOption of value option
- | ValueBuiltin of (value -> (value, value_error) Result.t)
-
-and value_error =
- | UnboundVariable of ident
- | TypeError
- | DivisionByZeroError
- | PatternMatchingError
- | LHS
-
-let pp_value_error fmt = function
- | UnboundVariable ident -> fprintf fmt "UnboundVariable: %S" ident
- | TypeError -> fprintf fmt "TypeError"
- | DivisionByZeroError -> fprintf fmt "DivisionByZeroError"
- | PatternMatchingError -> fprintf fmt "PatternMatchingError"
- | LHS -> fprintf fmt "LeftHandSide"
-;;
-
-module type Monad = sig
- type ('a, 'e) t
-
- val return : 'a -> ('a, 'e) t
- val fail : 'e -> ('a, 'e) t
- val ( let* ) : ('a, 'e) t -> ('a -> ('b, 'e) t) -> ('b, 'e) t
-end
-
-module Env (M : Monad) = struct
- open M
-
- let extend env key value = Map.update env key ~f:(fun _ -> value)
-
- let find map key =
- match Map.find map key with
- | Some value -> return value
- | None -> fail (UnboundVariable key)
- ;;
-end
-
-module Eval (M : Monad) : sig
- val eval_structure : program -> (env, value_error) M.t
-end = struct
- open M
- open Env (M)
-
- let initial_env =
- let open Base.Map in
- empty (module String)
- |> set
- ~key:"print_int"
- ~data:
- (ValueBuiltin
- (function
- | ValueInt i ->
- Stdlib.print_int i;
- Stdlib.print_newline ();
- Result.return ValueUnit
- | _ -> Result.fail TypeError))
- |> set
- ~key:"print_endline"
- ~data:
- (ValueBuiltin
- (function
- | ValueString s ->
- Stdlib.print_endline s;
- Result.return ValueUnit
- | _ -> Result.fail TypeError))
- |> set
- ~key:"print_bool"
- ~data:
- (ValueBuiltin
- (function
- | ValueBool b ->
- Stdlib.print_string (Bool.to_string b);
- Stdlib.print_newline ();
- Result.return ValueUnit
- | _ -> Result.fail TypeError))
- ;;
-
- let rec check_match env = function
- | PatAny, _ -> Some env
- | PatUnit, ValueUnit -> Some env
- | PatConst (ConstInt i1), ValueInt i2 when i1 = i2 -> Some env
- | PatConst (ConstBool b1), ValueBool b2 when Bool.equal b1 b2 -> Some env
- | PatConst (ConstString s1), ValueString s2 when String.equal s1 s2 -> Some env
- | PatVariable x, v -> Some (extend env x v)
- | PatType (pat, _), v -> check_match env (pat, v)
- | PatTuple (p1, p2, pl), ValueTuple (v1, v2, vl) ->
- (match check_match env (p1, v1) with
- | None -> None
- | Some env1 ->
- (match check_match env1 (p2, v2) with
- | None -> None
- | Some env2 ->
- (match
- List.fold2 pl vl ~init:(Some env2) ~f:(fun acc_env p v ->
- match acc_env with
- | Some env' -> check_match env' (p, v)
- | None -> None)
- with
- | Ok result -> result
- | Unequal_lengths -> None)))
- | PatList patterns, ValueList values when List.length patterns = List.length values ->
- let rec match_lists env pat_list val_list =
- match pat_list, val_list with
- | [], [] -> Some env
- | p :: ps, v :: vs ->
- (match check_match env (p, v) with
- | Some new_env -> match_lists new_env ps vs
- | None -> None)
- | _ -> None
- in
- match_lists env patterns values
- | PatOption p, ValueOption v ->
- (match p, v with
- | Some p, Some v -> check_match env (p, v)
- | None, None -> Some env
- | _ -> None)
- | _ -> None
- ;;
-
- let eval_un_op = function
- | Negative, ValueInt i -> return (ValueInt (-i))
- | Not, ValueBool b -> return (ValueBool (not b))
- | _ -> fail TypeError
- ;;
-
- let eval_binop (bop, v1, v2) =
- match bop, v1, v2 with
- | Multiply, ValueInt x, ValueInt y -> return (ValueInt (x * y))
- | Division, ValueInt _, ValueInt y when y = 0 -> fail DivisionByZeroError
- | Division, ValueInt x, ValueInt y -> return (ValueInt (x / y))
- | Plus, ValueInt x, ValueInt y -> return (ValueInt (x + y))
- | Minus, ValueInt x, ValueInt y -> return (ValueInt (x - y))
- | Equal, ValueInt x, ValueInt y -> return (ValueBool (x = y))
- | NotEqual, ValueInt x, ValueInt y -> return (ValueBool (x <> y))
- | LowerThan, ValueInt x, ValueInt y -> return (ValueBool (x < y))
- | LowestEqual, ValueInt x, ValueInt y -> return (ValueBool (x <= y))
- | GreaterThan, ValueInt x, ValueInt y -> return (ValueBool (x > y))
- | GretestEqual, ValueInt x, ValueInt y -> return (ValueBool (x >= y))
- | And, ValueBool x, ValueBool y -> return (ValueBool (x && y))
- | Or, ValueBool x, ValueBool y -> return (ValueBool (x || y))
- | _ -> fail TypeError
- ;;
-
- let rec eval_expr env = function
- | ExpConst c ->
- (match c with
- | ConstInt i -> return (ValueInt i)
- | ConstBool b -> return (ValueBool b)
- | ConstString s -> return (ValueString s))
- | ExpIdent x -> find env x
- | ExpUnarOper (op, e) ->
- let* v = eval_expr env e in
- eval_un_op (op, v)
- | ExpBinOper (op, e1, e2) ->
- let* v1 = eval_expr env e1 in
- let* v2 = eval_expr env e2 in
- eval_binop (op, v1, v2)
- | ExpBranch (cond, then_expr, else_expr_opt) ->
- let* cond_value = eval_expr env cond in
- (match cond_value with
- | ValueBool true -> eval_expr env then_expr
- | ValueBool false ->
- (match else_expr_opt with
- | Some else_expr -> eval_expr env else_expr
- | None -> return ValueUnit)
- | _ -> fail TypeError)
- | ExpLet (false, (PatList patterns, e1), _, e2) ->
- let check_list_pattern = function
- | PatVariable _ | PatAny | PatUnit | PatOption (Some (PatVariable _)) -> true
- | _ -> false
- in
- if not (List.for_all patterns ~f:check_list_pattern)
- then fail LHS
- else
- let* v = eval_expr env e1 in
- (match check_match env (PatList patterns, v) with
- | Some env' -> eval_expr env' e2
- | None -> fail PatternMatchingError)
- | ExpLet (false, (PatTuple (p1, p2, rest), e1), _, e2) ->
- let check_tuple_pattern = function
- | PatVariable _ | PatAny | PatUnit | PatOption (Some (PatVariable _)) -> true
- | _ -> false
- in
- if not (List.for_all ~f:check_tuple_pattern (p1 :: p2 :: rest))
- then fail LHS
- else
- let* v = eval_expr env e1 in
- (match check_match env (PatTuple (p1, p2, rest), v) with
- | Some env' -> eval_expr env' e2
- | None -> fail PatternMatchingError)
- | ExpLet (false, (pat, e1), _, e2) ->
- let check_simple_pattern =
- match pat with
- | PatAny | PatVariable _ | PatUnit | PatOption (Some (PatVariable _)) -> true
- | _ -> false
- in
- if not check_simple_pattern
- then fail LHS
- else
- let* v = eval_expr env e1 in
- (match check_match env (pat, v) with
- | Some env' -> eval_expr env' e2
- | None -> fail PatternMatchingError)
- | ExpLet (true, (pat, e1), [], e2) ->
- (match pat with
- | PatVariable _ ->
- let* v = eval_expr env e1 in
- let* rec_env =
- match check_match env (pat, v) with
- | Some new_env -> return new_env
- | None -> fail PatternMatchingError
- in
- let* recursive_value =
- match v with
- | ValueClosure (_, p, pl, e, _) ->
- return (ValueClosure (true, p, pl, e, rec_env))
- | _ -> fail TypeError
- in
- let* final_env =
- match check_match env (pat, recursive_value) with
- | Some updated_env -> return updated_env
- | None -> fail PatternMatchingError
- in
- eval_expr final_env e2
- | _ -> fail LHS)
- | ExpLet (true, value_binding, value_bindings, e2) ->
- let bindings = List.map ~f:(fun (p, e) -> p, e) (value_binding :: value_bindings) in
- let rec update_env acc_env = function
- | [] -> return acc_env
- | (PatVariable name, expr) :: tl ->
- let* value =
- match expr with
- | ExpLambda (patterns, e) ->
- let head = Option.value_exn (List.hd patterns) in
- let tail = Option.value_exn (List.tl patterns) in
- return (ValueClosure (true, head, tail, e, acc_env))
- | _ -> eval_expr acc_env expr
- in
- let updated_env = extend acc_env name value in
- update_env updated_env tl
- | _ -> fail LHS
- in
- let* final_env = update_env env bindings in
- eval_expr final_env e2
- | ExpTuple (e1, e2, es) ->
- let* v1 = eval_expr env e1 in
- let* v2 = eval_expr env e2 in
- let* vs =
- List.fold_right es ~init:(return []) ~f:(fun e acc ->
- let* acc = acc in
- let* v = eval_expr env e in
- return (v :: acc))
- in
- return (ValueTuple (v1, v2, vs))
- | ExpLambda (patterns, e) ->
- let head = Option.value_exn (List.hd patterns) in
- let tail = Option.value_exn (List.tl patterns) in
- return (ValueClosure (false, head, tail, e, env))
- | ExpTypeAnnotation (e, _) -> eval_expr env e
- | ExpFunction (e1, e2) ->
- let* v1 = eval_expr env e1 in
- let* v2 = eval_expr env e2 in
- (match v1 with
- | ValueBuiltin f ->
- (match f v2 with
- | Ok result -> return result
- | Error err -> fail err)
- | ValueClosure (_, pat, pats, body, func_env) ->
- (match check_match func_env (pat, v2) with
- | Some extended_env ->
- let env' =
- Map.fold extended_env ~init:env ~f:(fun ~key ~data acc_env ->
- Map.update acc_env key ~f:(fun _ -> data))
- in
- (match pats with
- | [] -> eval_expr env' body
- | p :: pl -> return (ValueClosure (false, p, pl, body, env')))
- | None -> fail PatternMatchingError)
- | _ -> fail TypeError)
- | ExpList el ->
- let rec eval_list_elements env = function
- | [] -> return []
- | e :: es ->
- let* v = eval_expr env e in
- let* vs = eval_list_elements env es in
- return (v :: vs)
- in
- let* vl = eval_list_elements env el in
- return (ValueList vl)
- | ExpOption opt ->
- let* value =
- match opt with
- | Some expr ->
- let* v = eval_expr env expr in
- return (Some v)
- | None -> return None
- in
- return (ValueOption value)
- ;;
-
- let eval_str_item env = function
- | SEval expr ->
- let* _ = eval_expr env expr in
- return env
- | SValue (false, (PatList patterns, e), _) ->
- let check_list_pattern = function
- | PatVariable _ | PatAny | PatUnit | PatOption (Some (PatVariable _)) -> true
- | _ -> false
- in
- if not (List.for_all ~f:check_list_pattern patterns)
- then fail LHS
- else
- let* v = eval_expr env e in
- (match check_match env (PatList patterns, v) with
- | Some env' -> return env'
- | None -> fail PatternMatchingError)
- | SValue (false, (PatTuple (p1, p2, rest), e), _) ->
- let check_tuple_pattern = function
- | PatVariable _ | PatAny | PatUnit | PatOption (Some (PatVariable _)) -> true
- | _ -> false
- in
- if not (List.for_all ~f:check_tuple_pattern (p1 :: p2 :: rest))
- then fail LHS
- else
- let* v = eval_expr env e in
- (match check_match env (PatTuple (p1, p2, rest), v) with
- | Some env' -> return env'
- | None -> fail PatternMatchingError)
- | SValue (false, (pattern, expr), _) ->
- let check_simple_pattern =
- match pattern with
- | PatAny | PatVariable _ | PatUnit | PatOption (Some (PatVariable _)) -> true
- | _ -> false
- in
- if not check_simple_pattern
- then fail LHS
- else
- let* v = eval_expr env expr in
- (match check_match env (pattern, v) with
- | Some env' -> return env'
- | None -> fail PatternMatchingError)
- | SValue (true, ((PatVariable _ as pattern), expr), []) ->
- let* v = eval_expr env expr in
- let* rec_env =
- match check_match env (pattern, v) with
- | Some new_env -> return new_env
- | None -> fail PatternMatchingError
- in
- let* recursive_value =
- match v with
- | ValueClosure (_, p, pl, expr, _) ->
- return (ValueClosure (true, p, pl, expr, rec_env))
- | _ -> fail TypeError
- in
- let* final_env =
- match check_match env (pattern, recursive_value) with
- | Some updated_env -> return updated_env
- | None -> fail PatternMatchingError
- in
- return final_env
- | SValue (true, _, []) -> fail LHS
- | SValue (true, value_binding, value_bindings) ->
- let bindings = value_binding :: value_bindings in
- let rec update_env acc_env = function
- | [] -> return acc_env
- | (PatVariable name, expr) :: tl ->
- let* value =
- match expr with
- | ExpLambda (patterns, expr) ->
- let head = Option.value_exn (List.hd patterns) in
- let tail = Option.value_exn (List.tl patterns) in
- return (ValueClosure (true, head, tail, expr, acc_env))
- | _ -> eval_expr acc_env expr
- in
- let updated_env = extend acc_env name value in
- update_env updated_env tl
- | _ -> fail LHS
- in
- let* final_env = update_env env bindings in
- return final_env
- ;;
-
- let eval_structure structure =
- List.fold_left structure ~init:(return initial_env) ~f:(fun env str_item ->
- let* env = env in
- let* env = eval_str_item env str_item in
- return env)
- ;;
-end
-
-module Inter = Eval (struct
- include Result
-
- let ( let* ) m f = bind m ~f
- end)
diff --git a/EUsoltsev/lib/interpreter.mli b/EUsoltsev/lib/interpreter.mli
deleted file mode 100644
index f130cf5e6..000000000
--- a/EUsoltsev/lib/interpreter.mli
+++ /dev/null
@@ -1,32 +0,0 @@
-(** Copyright 2024-2025, Danil Usoltsev *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-open Base
-
-type env = (ident, value, String.comparator_witness) Map.t
-
-and value =
- | ValueInt of int
- | ValueBool of bool
- | ValueString of string
- | ValueUnit
- | ValueClosure of is_rec * pattern * pattern list * expr * env
- | ValueTuple of value * value * value list
- | ValueList of value list
- | ValueOption of value option
- | ValueBuiltin of (value -> (value, value_error) Result.t)
-
-and value_error =
- | UnboundVariable of ident
- | TypeError
- | DivisionByZeroError
- | PatternMatchingError
- | LHS
-
-val pp_value_error : Stdlib.Format.formatter -> value_error -> unit
-
-module Inter : sig
- val eval_structure : program -> (env, value_error) Result.t
-end
diff --git a/EUsoltsev/lib/parser.ml b/EUsoltsev/lib/parser.ml
deleted file mode 100644
index e79a4f74d..000000000
--- a/EUsoltsev/lib/parser.ml
+++ /dev/null
@@ -1,313 +0,0 @@
-(** Copyright 2024-2025, Danil Usoltsev *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-open Base
-open Angstrom
-
-let is_keyword = function
- | "let"
- | "match"
- | "in"
- | "if"
- | "then"
- | "else"
- | "fun"
- | "rec"
- | "true"
- | "false"
- | "Some"
- | "and" -> true
- | _ -> false
-;;
-
-let is_lowercase = function
- | 'a' .. 'z' -> true
- | _ -> false
-;;
-
-let is_uppercase = function
- | 'A' .. 'Z' -> true
- | _ -> false
-;;
-
-let is_digit = function
- | '0' .. '9' -> true
- | _ -> false
-;;
-
-let white_space = take_while Char.is_whitespace
-let token s = white_space *> string s
-let token1 s = white_space *> s
-let parse_parens p = token "(" *> p <* token ")"
-
-let parse_const_int =
- let sign = choice [ token "" ] in
- let num = take_while1 Char.is_digit in
- lift2 (fun s n -> ConstInt (Int.of_string (s ^ n))) sign num
-;;
-
-let parse_const_bool =
- choice
- [ token "true" *> return (ConstBool true); token "false" *> return (ConstBool false) ]
-;;
-
-let parse_const_string =
- token "\"" *> take_till (Char.equal '\"') <* token "\"" >>| fun s -> ConstString s
-;;
-
-let parse_const = choice [ parse_const_int; parse_const_bool; parse_const_string ]
-let parse_unar_oper = choice [ token "-" *> return Negative; token "not" *> return Not ]
-
-let parse_ident =
- let parse_first_char =
- satisfy (fun ch -> is_lowercase ch || is_uppercase ch || Char.equal ch '_')
- >>| Char.escaped
- in
- let parse_other_chars =
- take_while (fun ch ->
- is_lowercase ch || is_uppercase ch || is_digit ch || Char.equal ch '_')
- in
- token1 @@ lift2 ( ^ ) parse_first_char parse_other_chars
- >>= fun s -> if is_keyword s then fail "It is not identifier" else return s
-;;
-
-let parse_base_type =
- choice
- [ token "int" *> return (TyPrim "int")
- ; token "bool" *> return (TyPrim "bool")
- ; token "string" *> return (TyPrim "string")
- ; token "unit" *> return (TyPrim "unit")
- ]
-;;
-
-let rec parse_type_list t =
- let* base = t in
- white_space
- *> token "list"
- *> (parse_type_list (return (TyList base)) <|> return (TyList base))
-;;
-
-let parse_type =
- let base_type = parse_base_type in
- let list_type = parse_type_list base_type <|> base_type in
- list_type
-;;
-
-let parse_pattern_with_type parse_pattern =
- let* pat = white_space *> token "(" *> parse_pattern in
- let* constr =
- white_space *> token ":" *> white_space *> parse_type <* white_space <* token ")"
- in
- return (PatType (pat, constr))
-;;
-
-let parse_pattern_var = parse_ident >>| fun id -> PatVariable id
-let parse_pattern_const = parse_const >>| fun c -> PatConst c
-let parse_pattern_any = token "_" *> return PatAny
-
-let parse_pattern_tuple parse_pattern =
- let parse_unparenthesized =
- lift3
- (fun p1 p2 rest -> PatTuple (p1, p2, rest))
- parse_pattern
- (token "," *> parse_pattern)
- (many (token "," *> parse_pattern))
- <* white_space
- in
- parse_parens parse_unparenthesized <|> parse_unparenthesized
-;;
-
-let parse_pattern_list parse_pattern =
- let semicols = token ";" in
- token "[" *> (sep_by semicols parse_pattern >>| fun patterns -> PatList patterns)
- <* token "]"
-;;
-
-let parse_pattern_empty = token "()" *> return PatUnit
-
-let parse_pattern_option parse_pattern =
- lift
- (fun e -> PatOption e)
- (token "Some" *> parse_pattern
- >>| (fun e -> Some e)
- <|> (token "None" >>| fun _ -> None))
-;;
-
-let parse_pattern =
- fix (fun pat ->
- let atom =
- choice
- [ parse_pattern_var
- ; parse_pattern_any
- ; parse_pattern_const
- ; parse_pattern_empty
- ; parse_pattern_with_type pat
- ; parse_parens pat
- ; parse_pattern_option pat
- ]
- in
- let tuple = parse_pattern_tuple atom <|> atom in
- let lst = parse_pattern_list tuple <|> tuple in
- lst)
-;;
-
-let parse_left_associative expr oper =
- let rec go acc = lift2 (fun f x -> f acc x) oper expr >>= go <|> return acc in
- expr >>= go
-;;
-
-let parse_expr_bin_oper parse_bin_op tkn =
- token tkn *> return (fun e1 e2 -> ExpBinOper (parse_bin_op, e1, e2))
-;;
-
-let multiply = parse_expr_bin_oper Multiply "*"
-let division = parse_expr_bin_oper Division "/"
-let plus = parse_expr_bin_oper Plus "+"
-let minus = parse_expr_bin_oper Minus "-"
-
-let compare =
- choice
- [ parse_expr_bin_oper Equal "="
- ; parse_expr_bin_oper NotEqual "<>"
- ; parse_expr_bin_oper LowestEqual "<="
- ; parse_expr_bin_oper LowerThan "<"
- ; parse_expr_bin_oper GretestEqual ">="
- ; parse_expr_bin_oper GreaterThan ">"
- ]
-;;
-
-let and_op = parse_expr_bin_oper And "&&"
-let or_op = parse_expr_bin_oper Or "||"
-let parse_expr_ident = parse_ident >>| fun x -> ExpIdent x
-let parse_expr_const = parse_const >>| fun c -> ExpConst c
-
-let parse_expr_with_type parse_expr =
- let parse_annotated_type = token ":" *> parse_type in
- lift2 (fun expr t -> ExpTypeAnnotation (expr, t)) parse_expr parse_annotated_type
-;;
-
-let parse_expr_branch parse_expr =
- lift3
- (fun cond t f -> ExpBranch (cond, t, f))
- (token "if" *> parse_expr)
- (token "then" *> parse_expr)
- (option None (token "else" *> parse_expr >>| Option.some))
-;;
-
-let parse_expr_option parse_expr =
- choice
- [ token "None" *> return (ExpOption None)
- ; (token "Some" *> choice [ parse_parens parse_expr; parse_expr ]
- >>| fun e -> ExpOption (Some e))
- ]
-;;
-
-let parse_expr_unar_oper parse_expr =
- parse_unar_oper >>= fun op -> parse_expr >>= fun expr -> return (ExpUnarOper (op, expr))
-;;
-
-let parse_expr_list parse_expr =
- let parse_elements = sep_by (token ";") parse_expr in
- token "[" *> parse_elements <* token "]" >>| fun elements -> ExpList elements
-;;
-
-let parse_expr_function e =
- parse_left_associative e (return (fun e1 e2 -> ExpFunction (e1, e2)))
-;;
-
-let parse_expr_lambda parse_expr =
- token "fun" *> sep_by1 white_space parse_pattern
- <* token "->"
- >>= fun params -> parse_expr >>| fun body -> ExpLambda (params, body)
-;;
-
-let parse_expr_tuple parse_expr =
- let commas = token "," in
- let tuple =
- lift3
- (fun e1 e2 rest -> ExpTuple (e1, e2, rest))
- (parse_expr <* commas)
- parse_expr
- (many (commas *> parse_expr))
- <* white_space
- in
- parse_parens tuple <|> tuple
-;;
-
-let parse_body parse_expr =
- many1 parse_pattern
- >>= fun patterns -> token "=" *> parse_expr >>| fun body -> ExpLambda (patterns, body)
-;;
-
-let parse_expr_let parse_expr =
- token "let"
- *> lift4
- (fun rec_flag value_bindings and_bindings body ->
- ExpLet (rec_flag, value_bindings, and_bindings, body))
- (token "rec" *> (take_while1 Char.is_whitespace *> return true) <|> return false)
- (lift2
- (fun pat expr -> pat, expr)
- parse_pattern
- (token "=" *> parse_expr <|> parse_body parse_expr))
- (many
- (token "and"
- *> lift2
- (fun pat expr -> pat, expr)
- parse_pattern
- (token "=" *> parse_expr <|> parse_body parse_expr)))
- (token "in" *> parse_expr)
-;;
-
-let parse_expr =
- fix (fun expr ->
- let term =
- choice
- [ parse_expr_ident
- ; parse_expr_const
- ; parse_expr_list expr
- ; parse_parens expr
- ; parse_parens (parse_expr_with_type expr)
- ]
- in
- let func = parse_expr_function term in
- let cons = parse_expr_option func <|> func in
- let ife = parse_expr_branch expr <|> cons in
- let unops = parse_expr_unar_oper ife <|> ife in
- let ops1 = parse_left_associative unops (multiply <|> division) in
- let ops2 = parse_left_associative ops1 (plus <|> minus) in
- let cmp = parse_left_associative ops2 compare in
- let boolean = parse_left_associative cmp (and_op <|> or_op) in
- let tuple = parse_expr_tuple boolean <|> boolean in
- let lambda = parse_expr_lambda expr <|> tuple in
- choice [ parse_expr_let expr; parse_expr_lambda expr; lambda ])
-;;
-
-let parse_structure =
- let parse_eval = parse_expr >>| fun e -> SEval e in
- let parse_value =
- token "let"
- *> lift3
- (fun r id id_list -> SValue (r, id, id_list))
- (token "rec" *> (take_while1 Char.is_whitespace *> return true) <|> return false)
- (lift2
- (fun pat expr -> pat, expr)
- parse_pattern
- (token "=" *> parse_expr <|> parse_body parse_expr))
- (many
- (token "and"
- *> lift2
- (fun pat expr -> pat, expr)
- parse_pattern
- (token "=" *> parse_expr <|> parse_body parse_expr)))
- in
- choice [ parse_eval; parse_value ]
-;;
-
-let parse_program =
- let definitions_or_exprs = many parse_structure <* option () (token ";;" >>| ignore) in
- definitions_or_exprs <* white_space
-;;
-
-let parse input = parse_string ~consume:All parse_program input
diff --git a/EUsoltsev/lib/parser.mli b/EUsoltsev/lib/parser.mli
deleted file mode 100644
index 2236c1979..000000000
--- a/EUsoltsev/lib/parser.mli
+++ /dev/null
@@ -1,5 +0,0 @@
-(** Copyright 2024-2025, Danil Usoltsev *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-val parse : string -> (Ast.program, string) result
diff --git a/EUsoltsev/tests/.gitignore b/EUsoltsev/tests/.gitignore
deleted file mode 100644
index 26685e795..000000000
--- a/EUsoltsev/tests/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-lam*.txt
\ No newline at end of file
diff --git a/EUsoltsev/tests/dune b/EUsoltsev/tests/dune
deleted file mode 100644
index 4e481bc8c..000000000
--- a/EUsoltsev/tests/dune
+++ /dev/null
@@ -1,38 +0,0 @@
-(library
- (name tests)
- (libraries EUsoltsev_lib)
- (preprocess
- (pps ppx_expect ppx_deriving.show))
- (inline_tests)
- (instrumentation
- (backend bisect_ppx)))
-
-(cram
- (applies_to tests)
- (deps
- ../bin/main.exe
- manytests/do_not_type/001.ml
- manytests/do_not_type/002if.ml
- manytests/do_not_type/003occurs.ml
- manytests/do_not_type/004let_poly.ml
- manytests/do_not_type/005.ml
- manytests/do_not_type/015tuples.ml
- manytests/do_not_type/016tuples_mismatch.ml
- manytests/do_not_type/097fun_vs_list.ml
- manytests/do_not_type/097fun_vs_unit.ml
- manytests/do_not_type/098rec_int.ml
- manytests/do_not_type/099.ml
- manytests/typed/001fac.ml
- manytests/typed/002fac.ml
- manytests/typed/003fib.ml
- manytests/typed/004manyargs.ml
- manytests/typed/005fix.ml
- manytests/typed/006partial.ml
- manytests/typed/006partial2.ml
- manytests/typed/006partial3.ml
- manytests/typed/007order.ml
- manytests/typed/008ascription.ml
- manytests/typed/009let_poly.ml
- manytests/typed/010sukharev.ml
- manytests/typed/015tuples.ml
- manytests/typed/016lists.ml))
diff --git a/EUsoltsev/tests/inferencer_tests.ml b/EUsoltsev/tests/inferencer_tests.ml
deleted file mode 100644
index 73f040cd6..000000000
--- a/EUsoltsev/tests/inferencer_tests.ml
+++ /dev/null
@@ -1,166 +0,0 @@
-(** Copyright 2024-2025, Danil Usoltsev *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open EUsoltsev_lib
-open Inferencer
-open Ast
-
-let pretty_printer_parse_and_infer s =
- match Parser.parse s with
- | Ok parsed ->
- (match run_infer parsed with
- | Ok env ->
- let filtered_env =
- Base.Map.filter_keys env ~f:(fun key ->
- not (List.mem key [ "print_int"; "print_endline"; "print_bool" ]))
- in
- Base.Map.iteri filtered_env ~f:(fun ~key ~data:(S (_, ty)) ->
- Format.printf "val %s: %a\n" key pp_ty ty)
- | Error e -> Format.printf "Infer error. %a\n" pp_error e)
- | Error e -> Format.printf "Parsing error. %s\n" e
-;;
-
-let pretty_printer_parse_and_infer_simple s =
- match Parser.parse s with
- | Ok parsed ->
- (match parsed with
- | [ SEval expr ] ->
- (match infer_simple_expression expr with
- | Ok ty -> Format.printf "%a\n" pp_ty ty
- | Error e -> Format.printf "Infer error. %a\n" pp_error e)
- | _ ->
- Format.printf
- "Expected a single expression, but got a program with multiple structures.\n")
- | Error e -> Format.printf "Parsing error. %s\n" e
-;;
-
-let%expect_test "test_binary_oper" =
- pretty_printer_parse_and_infer_simple "10/2 + 56*2 - 10 / 10 / 20 + 666 - 777 + 1";
- [%expect {|int|}]
-;;
-
-let%expect_test "test_bool" =
- pretty_printer_parse_and_infer_simple "false";
- [%expect {|bool|}]
-;;
-
-let%expect_test "test_string" =
- pretty_printer_parse_and_infer_simple "\"I like OCaml\" ";
- [%expect {|string|}]
-;;
-
-let%expect_test "test_option" =
- pretty_printer_parse_and_infer_simple "Some 10";
- [%expect {|int option|}]
-;;
-
-let%expect_test "test_binary_oper_and_arg" =
- pretty_printer_parse_and_infer_simple "fun x -> x * 69 + 100 - 201 / 777";
- [%expect {|int -> int|}]
-;;
-
-let%expect_test "test_rec" =
- pretty_printer_parse_and_infer "let rec func arg = func arg";
- [%expect {|val func: '1 -> '2|}]
-;;
-
-let%expect_test "test_func_apply_some_args" =
- pretty_printer_parse_and_infer "let func a1 a2 a3 = a1 a2 a3";
- [%expect {|val func: ('1 -> '2 -> '4) -> '1 -> '2 -> '4|}]
-;;
-
-let%expect_test "test_tuple" =
- pretty_printer_parse_and_infer_simple "fun x y z -> (x + 10, y / 2 , z)";
- [%expect {|int -> int -> '2 -> (int * int * '2)|}]
-;;
-
-let%expect_test "test_list" =
- pretty_printer_parse_and_infer "let arr = [1;2;3]";
- [%expect {|val arr: int list|}]
-;;
-
-let%expect_test "test_binary_oper" =
- pretty_printer_parse_and_infer "let is_above_10 x = if x > 10 then true else false ";
- [%expect {|val is_above_10: int -> bool|}]
-;;
-
-let%expect_test "test_binary_oper" =
- pretty_printer_parse_and_infer "let is_above_10 x = x > 10";
- [%expect {|val is_above_10: int -> bool|}]
-;;
-
-let%expect_test "test_factorial" =
- pretty_printer_parse_and_infer "let rec fac n = if n < 2 then 1 else n * fac (n - 1)";
- [%expect {|val fac: int -> int|}]
-;;
-
-let%expect_test "test_nested_list_function" =
- pretty_printer_parse_and_infer "let f x = [ [x; x]; [x] ]";
- [%expect {|val f: '0 -> '0 list list|}]
-;;
-
-let%expect_test "test_nested_option_function" =
- pretty_printer_parse_and_infer "let f x = Some x";
- [%expect {|val f: '0 -> '0 option|}]
-;;
-
-let%expect_test "test_fibonacci" =
- pretty_printer_parse_and_infer
- "let rec fibo n = if n < 2 then 1 else fibo(n - 1) + fibo(n - 2)";
- [%expect {|val fibo: int -> int|}]
-;;
-
-let%expect_test "test_unbound_var" =
- pretty_printer_parse_and_infer "let f = x";
- [%expect {|Infer error. Unbound variable 'x'.|}]
-;;
-
-let%expect_test "test_annotate" =
- pretty_printer_parse_and_infer "let sum = fun (x : int) (y : int) -> x + y";
- [%expect {|val sum: int -> int -> int|}]
-;;
-
-let%expect_test "test_annotate_fac" =
- pretty_printer_parse_and_infer
- "let rec fac = fun (n : int) (acc : int) -> if n < 2 then acc else fac (n-1) (acc * \
- n);;";
- [%expect {|val fac: int -> int -> int|}]
-;;
-
-let%expect_test "test_program_1" =
- pretty_printer_parse_and_infer
- "let div = fun x y -> x / y \n\
- \ let sum = fun x y -> x + y\n\
- \ let res = fun x y z -> div x (sum y z)";
- [%expect
- {|
- val div: int -> int -> int
- val res: int -> int -> int -> int
- val sum: int -> int -> int|}]
-;;
-
-let%expect_test "test_program_2" =
- pretty_printer_parse_and_infer
- "let square = fun x -> x * x\n\
- \ let result = square 10";
- [%expect {|
- val result: int
- val square: int -> int|}]
-;;
-
-let%expect_test "test_annotate_error" =
- pretty_printer_parse_and_infer "let sum (x : int) (y : string) = x + y";
- [%expect {|Infer error. Failed to unify types: string and int.|}]
-;;
-
-let%expect_test "test_unification_types" =
- pretty_printer_parse_and_infer "fun x -> x + true";
- [%expect {|Infer error. Failed to unify types: bool and int.|}]
-;;
-
-let%expect_test "test_option_type_error" =
- pretty_printer_parse_and_infer
- "let f x = Some (x + 1) in let g y = Some (y && true) in f = g";
- [%expect {|Infer error. Failed to unify types: bool and int.|}]
-;;
diff --git a/EUsoltsev/tests/inferencer_tests.mli b/EUsoltsev/tests/inferencer_tests.mli
deleted file mode 100644
index 54e45fa8d..000000000
--- a/EUsoltsev/tests/inferencer_tests.mli
+++ /dev/null
@@ -1,3 +0,0 @@
-(** Copyright 2024-2025, Danil Usoltsev *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
diff --git a/EUsoltsev/tests/interpreter_tests.ml b/EUsoltsev/tests/interpreter_tests.ml
deleted file mode 100644
index c3207d4ab..000000000
--- a/EUsoltsev/tests/interpreter_tests.ml
+++ /dev/null
@@ -1,241 +0,0 @@
-(** Copyright 2024-2025, Danil Usoltsev *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open EUsoltsev_lib
-open Interpreter
-
-let test_interpret s =
- let open Stdlib.Format in
- match Parser.parse s with
- | Ok parsed ->
- (match Inter.eval_structure parsed with
- | Ok _ -> ()
- | Error e -> printf "Interpreter error: %a\n" pp_value_error e)
- | Error e -> printf "Parsing error: %s\n" e
-;;
-
-let%expect_test "test_unit" =
- test_interpret "let () = print_int(10 / 10 + 2 * 50 + 89 - 89)";
- [%expect {|101|}]
-;;
-
-let%expect_test "test_bool" =
- test_interpret
- "let () = print_bool(true) in\n\
- \ let () = print_bool(false) in\n\
- \ let () = print_bool(not true) in \n\
- \ let () = print_bool(not false) in\n\
- \ let () = print_bool(true && false) in\n\
- \ let () = print_bool(true || false ) in 9";
- [%expect {|
- true
- false
- false
- true
- false
- true|}]
-;;
-
-let%expect_test "test_bin_oper" =
- test_interpret
- "let a = 1\n\
- \ let b = 2\n\
- \ let () = print_bool(a = a)\n\
- \ let () = print_bool(b > a)\n\
- \ let () = print_bool(a < b)\n\
- \ let () = print_bool(a <> b)\n\
- \ let () = print_bool(a <> a)\n\
- \ let () = print_bool(a <= a)\n\
- \ let () = print_bool(a >= a)\n\
- \ let () = print_bool(a <= b)\n\
- \ let () = print_bool(a >= b)";
- [%expect
- {|
- true
- true
- true
- true
- false
- true
- true
- true
- false|}]
-;;
-
-let%expect_test "test_adder" =
- test_interpret
- "let create_adder x =\n\
- \ let adder y = x + y in\n\
- \ adder\n\
- \ let sum_two_arg = print_int(create_adder 10 20)";
- [%expect {|30|}]
-;;
-
-let%expect_test "test_lambda" =
- test_interpret
- "let create_adder = fun x -> fun y -> x + y\n\
- \ let () = print_int(create_adder 7 8)";
- [%expect {|15|}]
-;;
-
-let%expect_test "test_print_string" =
- test_interpret "let () = print_endline \"I like OCaml\"";
- [%expect {|I like OCaml|}]
-;;
-
-let%expect_test "test_not_print" =
- test_interpret
- "let create_adder x =\n\
- \ let adder y = x + y in\n\
- \ adder\n\
- \ let fac n = if n < 2 then 1 else n * fac(n-1) \n\
- \ let x = 1\n\
- \ let y = true";
- [%expect {||}]
-;;
-
-let%expect_test "test_factorial" =
- test_interpret
- "let rec fac n = if n < 2 then 1 else n * fac(n-1) \n\
- \ let result = print_int(fac 5)";
- [%expect {|120|}]
-;;
-
-let%expect_test "test_factorial_cps" =
- test_interpret
- "let rec fac_cps n k =\n\
- \ if n=1 then k 1 else\n\
- \ fac_cps (n-1) (fun p -> k (p*n))\n\
- \ let result = print_int(fac_cps 5 (fun x -> x))";
- [%expect {|120|}]
-;;
-
-let%expect_test "test_fibonacci" =
- test_interpret
- "let rec fibo n = if n < 2 then 1 else fibo(n-1) + fibo(n-2)\n\
- \ let result = print_int(fibo 5)";
- [%expect {|8|}]
-;;
-
-let%expect_test "test_fix" =
- test_interpret
- "let rec fix f x = f (fix f) x\n\
- \ let fac self n = if n<=1 then 1 else n * self (n-1)\n\
- \ let f = print_int (fix fac 5)";
- [%expect {|120|}]
-;;
-
-let%expect_test "test_nested_recursive_closure" =
- test_interpret
- "\n\
- \ let rec outer x =\n\
- \ let rec inner y = x + y in\n\
- \ inner\n\
- \ let inner = outer 10\n\
- \ let () = print_int (inner 5)";
- [%expect {|15|}]
-;;
-
-let%expect_test "test_annotate_sum" =
- test_interpret "let sum (x : int) (y : int) = x + y let res = print_int(sum 10 20)";
- [%expect {|30|}]
-;;
-
-let%expect_test "test_annotate_fac" =
- test_interpret
- "let rec fac (n : int) (acc : int) = if n < 2 then acc else fac (n-1) (acc * n)\n\
- \ let res = print_int (fac 5 1)";
- [%expect {|120|}]
-;;
-
-let%expect_test "test_tuple" =
- test_interpret
- "let (a,b) = (1 + 1 * 10,2 - 1 * 5)\n\
- \ let () = print_int a \n\
- \ let () = print_int b";
- [%expect {|
- 11
- -3|}]
-;;
-
-let%expect_test "test_nested_tuple" =
- test_interpret
- "\n\
- \ let (a, b) = (1 + 2, 3 * 4)\n\
- \ let (c, d) = (a + b, b - a)\n\
- \ let () = print_int c\n\
- \ let () = print_int d";
- [%expect {|
- 15
- 9|}]
-;;
-
-let%expect_test "test_pattern_list" =
- test_interpret
- "let lst = [1;2;3]\n\
- \ let [a; b; c] = lst in \n\
- \ let () = print_int(a) in\n\
- \ let () = print_int(b) in \n\
- \ let () = print_int(c) in 0";
- [%expect {|
- 1
- 2
- 3|}]
-;;
-
-let%expect_test "test_closure" =
- test_interpret
- "let x = \n\
- \ let y = \n\
- \ let z = \n\
- \ let w = 1\n\
- \ in w\n\
- \ in z\n\
- \ in y\n\
- \ \n\
- \ let () = print_int x";
- [%expect {|1|}]
-;;
-
-let%expect_test "test_let_and_fac" =
- test_interpret
- {|
- let rec factorial n = if n <= 1 then 1 else n * helper (n - 1)
- and helper x = factorial x in
- let () = print_int (factorial 5) in 0
- |};
- [%expect {|
- 120
- |}]
-;;
-
-let%expect_test "test_div_error" =
- test_interpret "let div = fun x y -> x / y\n let res = div 10 0";
- [%expect {|Interpreter error: DivisionByZeroError|}]
-;;
-
-let%expect_test "test_div_error" =
- test_interpret "let div = fun x y -> x / y \n let res = div 10 0";
- [%expect {|Interpreter error: DivisionByZeroError|}]
-;;
-
-let%expect_test "test_pm_error" =
- test_interpret "let (a, b) = (1,2,3)";
- [%expect {|Interpreter error: PatternMatchingError|}]
-;;
-
-let%expect_test "test_pm_error" =
- test_interpret "let x = x + 1";
- [%expect {|Interpreter error: UnboundVariable: "x"|}]
-;;
-
-let%expect_test "test_type_error_addition" =
- test_interpret "let x = 10 + true";
- [%expect {|Interpreter error: TypeError|}]
-;;
-
-let%expect_test "test_type_error_addition" =
- test_interpret "let rec (a, b) = (1,2)";
- [%expect {|Interpreter error: LeftHandSide|}]
-;;
diff --git a/EUsoltsev/tests/interpreter_tests.mli b/EUsoltsev/tests/interpreter_tests.mli
deleted file mode 100644
index 54e45fa8d..000000000
--- a/EUsoltsev/tests/interpreter_tests.mli
+++ /dev/null
@@ -1,3 +0,0 @@
-(** Copyright 2024-2025, Danil Usoltsev *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
diff --git a/EUsoltsev/tests/manytests b/EUsoltsev/tests/manytests
deleted file mode 120000
index 0bd48791d..000000000
--- a/EUsoltsev/tests/manytests
+++ /dev/null
@@ -1 +0,0 @@
-../../manytests
\ No newline at end of file
diff --git a/EUsoltsev/tests/parser_tests.ml b/EUsoltsev/tests/parser_tests.ml
deleted file mode 100644
index 7cc349880..000000000
--- a/EUsoltsev/tests/parser_tests.ml
+++ /dev/null
@@ -1,181 +0,0 @@
-(** Copyright 2024-2025, Danil Usoltsev *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open EUsoltsev_lib
-open Ast
-open Parser
-open Printf
-
-let parse_test input =
- match parse input with
- | Ok ast -> printf "%s\n" (show_program ast)
- | Error fail -> printf "Ошибка: %s\n" fail
-;;
-
-let%expect_test "factorial" =
- parse_test "let rec factorial n = if n < 2 then 1 else n * factorial(n - 1);;";
- [%expect
- {|
- [(SValue (true,
- ((PatVariable "factorial"),
- (ExpLambda ([(PatVariable "n")],
- (ExpBranch (
- (ExpBinOper (LowerThan, (ExpIdent "n"), (ExpConst (ConstInt 2)))),
- (ExpConst (ConstInt 1)),
- (Some (ExpBinOper (Multiply, (ExpIdent "n"),
- (ExpFunction ((ExpIdent "factorial"),
- (ExpBinOper (Minus, (ExpIdent "n"),
- (ExpConst (ConstInt 1))))
- ))
- )))
- ))
- ))),
- []))
- ]
-|}]
-;;
-
-let%expect_test "fibonacci" =
- parse_test "let rec fibo n = if n < 2 then 1 else fibo(n - 1) + fibo(n - 2) ;;";
- [%expect
- {|
- [(SValue (true,
- ((PatVariable "fibo"),
- (ExpLambda ([(PatVariable "n")],
- (ExpBranch (
- (ExpBinOper (LowerThan, (ExpIdent "n"), (ExpConst (ConstInt 2)))),
- (ExpConst (ConstInt 1)),
- (Some (ExpBinOper (Plus,
- (ExpFunction ((ExpIdent "fibo"),
- (ExpBinOper (Minus, (ExpIdent "n"),
- (ExpConst (ConstInt 1))))
- )),
- (ExpFunction ((ExpIdent "fibo"),
- (ExpBinOper (Minus, (ExpIdent "n"),
- (ExpConst (ConstInt 2))))
- ))
- )))
- ))
- ))),
- []))
- ]
-|}]
-;;
-
-let%expect_test "lambda_test" =
- parse_test "let add x = fun y -> x + y;;";
- [%expect
- {|
- [(SValue (false,
- ((PatVariable "add"),
- (ExpLambda ([(PatVariable "x")],
- (ExpLambda ([(PatVariable "y")],
- (ExpBinOper (Plus, (ExpIdent "x"), (ExpIdent "y")))))
- ))),
- []))
- ]
-|}]
-;;
-
-let%expect_test "test_tuple" =
- parse_test "let x = (1, 2, true) in x;;";
- [%expect
- {|
- [(SEval
- (ExpLet (false,
- ((PatVariable "x"),
- (ExpTuple ((ExpConst (ConstInt 1)), (ExpConst (ConstInt 2)),
- [(ExpConst (ConstBool true))]))),
- [], (ExpIdent "x"))))
- ]
-|}]
-;;
-
-let%expect_test "test_list" =
- parse_test "let arr = [1;2;true]";
- [%expect
- {|
- [(SValue (false,
- ((PatVariable "arr"),
- (ExpList
- [(ExpConst (ConstInt 1)); (ExpConst (ConstInt 2));
- (ExpConst (ConstBool true))])),
- []))
- ]
-|}]
-;;
-
-let%expect_test "test_one_element_in_tuple" =
- parse_test "let x = (666)";
- [%expect
- {|
- [(SValue (false, ((PatVariable "x"), (ExpConst (ConstInt 666))), []))]
-|}]
-;;
-
-let%expect_test "test_sum_two_args" =
- parse_test "let sum x y = x + y";
- [%expect
- {|
-[(SValue (false,
- ((PatVariable "sum"),
- (ExpLambda ([(PatVariable "x"); (PatVariable "y")],
- (ExpBinOper (Plus, (ExpIdent "x"), (ExpIdent "y")))))),
- []))
- ]
-|}]
-;;
-
-let%expect_test "test_annotate_type_1" =
- parse_test "let sum (x:int) (y:int) = x + y";
- [%expect
- {|
-[(SValue (false,
- ((PatVariable "sum"),
- (ExpLambda (
- [(PatType ((PatVariable "x"), (TyPrim "int")));
- (PatType ((PatVariable "y"), (TyPrim "int")))],
- (ExpBinOper (Plus, (ExpIdent "x"), (ExpIdent "y")))))),
- []))
- ]
-|}]
-;;
-
-let%expect_test "test_annotate_type_2" =
- parse_test "let (a : int list) = [] ";
- [%expect
- {|
-[(SValue (false,
- ((PatType ((PatVariable "a"), (TyList (TyPrim "int")))), (ExpList [])),
- []))
- ]
-|}]
-;;
-
-let%expect_test "test_minus" =
- parse_test "-1 -2 - (-1) -(3)";
- [%expect
- {|
-[(SEval
- (ExpBinOper (Minus,
- (ExpBinOper (Minus,
- (ExpBinOper (Minus,
- (ExpUnarOper (Negative, (ExpConst (ConstInt 1)))),
- (ExpConst (ConstInt 2)))),
- (ExpUnarOper (Negative, (ExpConst (ConstInt 1)))))),
- (ExpConst (ConstInt 3)))))
- ]
- |}]
-;;
-
-let%expect_test "test_unit" =
- parse_test "let () = print_int 5";
- [%expect
- {|
-[(SValue (false,
- (PatUnit, (ExpFunction ((ExpIdent "print_int"), (ExpConst (ConstInt 5))))),
- []))
- ]
- |}]
-;;
diff --git a/EUsoltsev/tests/parser_tests.mli b/EUsoltsev/tests/parser_tests.mli
deleted file mode 100644
index 54e45fa8d..000000000
--- a/EUsoltsev/tests/parser_tests.mli
+++ /dev/null
@@ -1,3 +0,0 @@
-(** Copyright 2024-2025, Danil Usoltsev *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
diff --git a/EUsoltsev/tests/tests.t b/EUsoltsev/tests/tests.t
deleted file mode 100644
index a68929689..000000000
--- a/EUsoltsev/tests/tests.t
+++ /dev/null
@@ -1,143 +0,0 @@
-(** Copyright 2024-2025, Danil Usoltsev *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
- $ ../bin/main.exe -interpret -file manytests/typed/001fac.ml
- 24
-
- $ ../bin/main.exe -interpret -file manytests/typed/002fac.ml
- 24
-
- $ ../bin/main.exe -interpret -file manytests/typed/003fib.ml
- 3
- 3
-
- $ ../bin/main.exe -interpret -file manytests/typed/004manyargs.ml
- 1111111111
- 1
- 10
- 100
-
- $ ../bin/main.exe -interpret -file manytests/typed/005fix.ml
- 720
-
- $ ../bin/main.exe -interpret -file manytests/typed/006partial.ml
- 1122
-
- $ ../bin/main.exe -interpret -file manytests/typed/006partial2.ml
- 1
- 2
- 3
- 7
-
- $ ../bin/main.exe -interpret -file manytests/typed/006partial3.ml
- 4
- 8
- 9
-
- $ ../bin/main.exe -interpret -file manytests/typed/007order.ml
- 1
- 2
- 4
- -1
- 103
- -555555
- 10000
-
- $ ../bin/main.exe -interpret -file manytests/typed/008ascription.ml
- 8
-
- $ ../bin/main.exe -interpret -file manytests/typed/009let_poly.ml
-
- $ ../bin/main.exe -interpret -file manytests/typed/015tuples.ml
- 1
- 1
- 1
- 1
-
- $ ../bin/main.exe -infer -file manytests/typed/001fac.ml
- val fac: int -> int
- val main: int
-
- $ ../bin/main.exe -infer -file manytests/typed/002fac.ml
- val fac_cps: int -> (int -> int) -> int
- val main: int
-
- $ ../bin/main.exe -infer -file manytests/typed/003fib.ml
- val fib: int -> int
- val fib_acc: int -> int -> int -> int
- val main: int
-
- $ ../bin/main.exe -infer -file manytests/typed/004manyargs.ml
- val main: int
- val test10: int -> int -> int -> int -> int -> int -> int -> int -> int -> int -> int
- val test3: int -> int -> int -> int
- val wrap: '0 -> '0
-
- $ ../bin/main.exe -infer -file manytests/typed/005fix.ml
- val fac: (int -> int) -> int -> int
- val fix: ((int -> int) -> int -> int) -> int -> int
- val main: int
-
- $ ../bin/main.exe -infer -file manytests/typed/006partial.ml
- val foo: int -> int
- val main: int
-
- $ ../bin/main.exe -infer -file manytests/typed/006partial2.ml
- val foo: int -> int -> int -> int
- val main: int
-
- $ ../bin/main.exe -infer -file manytests/typed/006partial3.ml
- val foo: int -> int -> int -> unit
- val main: int
-
- $ ../bin/main.exe -infer -file manytests/typed/007order.ml
- val _start: unit -> unit -> int -> unit -> int -> int -> unit -> int -> int -> int
- val main: unit
-
- $ ../bin/main.exe -infer -file manytests/typed/008ascription.ml
- val addi: ('2 -> bool -> int) -> ('2 -> bool) -> '2 -> int
- val main: int
-
- $ ../bin/main.exe -infer -file manytests/typed/009let_poly.ml
- val temp: (int * bool)
-
- $ ../bin/main.exe -infer -file manytests/typed/015tuples.ml
- val feven: ('29 * int -> '33) -> int -> int
- val fix: ((((int -> int * int -> int) -> int -> int * (int -> int * int -> int) -> int -> int) -> (int -> int * int -> int)) -> ((int -> int * int -> int) -> int -> int * (int -> int * int -> int) -> int -> int) -> (int -> int * int -> int)) -> ((int -> int * int -> int) -> int -> int * (int -> int * int -> int) -> int -> int) -> (int -> int * int -> int)
- val fixpoly: ((int -> int * int -> int) -> int -> int * (int -> int * int -> int) -> int -> int) -> (int -> int * int -> int)
- val fodd: (int -> '40 * '37) -> int -> int
- val main: int
- val map: ('9 -> '11) -> ('9 * '9) -> ('10 * '11)
- val meven: int -> int
- val modd: int -> int
- val tie: (int -> int * int -> int)
-
-
- $ ../bin/main.exe -infer -file manytests/do_not_type/001.ml
- Infer error. Unbound variable 'fac'.
-
- $ ../bin/main.exe -infer -file manytests/do_not_type/002if.ml
- Infer error. Failed to unify types: int and bool.
-
- $ ../bin/main.exe -infer -file manytests/do_not_type/003occurs.ml
- Infer error. Occurs check failed. Type variable '1 occurs inside '1 -> '3.
-
- $ ../bin/main.exe -infer -file manytests/do_not_type/004let_poly.ml
- Infer error. Failed to unify types: int and bool.
-
- $ ../bin/main.exe -infer -file manytests/do_not_type/015tuples.ml
- Infer error. Left-hand side error: Only variables are allowed on the left-hand side of let rec.
-
- $ ../bin/main.exe -infer -file manytests/do_not_type/016tuples_mismatch.ml
- Infer error. Failed to unify types: ('0 * '1) and (int * int * int).
-
- $ ../bin/main.exe -infer -file manytests/do_not_type/097fun_vs_list.ml
- Infer error. Failed to unify types: '2 list and '0 -> '0.
-
- $ ../bin/main.exe -infer -file manytests/do_not_type/097fun_vs_unit.ml
- Infer error. Failed to unify types: unit and '0 -> '0.
-
- $ ../bin/main.exe -infer -file manytests/do_not_type/098rec_int.ml
- Infer error. Right-hand side error: Right-hand side of let rec must be a lambda expression.
-
diff --git a/FSharpActivePatterns/.envrc b/FSharpActivePatterns/.envrc
deleted file mode 100644
index e6bd6786d..000000000
--- a/FSharpActivePatterns/.envrc
+++ /dev/null
@@ -1,3 +0,0 @@
-export OPAMSWITCH=4.14.2+flambda
-eval $(opam env)
-
diff --git a/FSharpActivePatterns/.gitignore b/FSharpActivePatterns/.gitignore
deleted file mode 100644
index 7102a822c..000000000
--- a/FSharpActivePatterns/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-_build
-_coverage
-/_esy
-/node_modules
-/esy.lock
-/.melange.eobjs
diff --git a/FSharpActivePatterns/.ocamlformat b/FSharpActivePatterns/.ocamlformat
deleted file mode 100644
index 97f970802..000000000
--- a/FSharpActivePatterns/.ocamlformat
+++ /dev/null
@@ -1,2 +0,0 @@
-profile=janestreet
-version=0.26.2
diff --git a/FSharpActivePatterns/.zanuda b/FSharpActivePatterns/.zanuda
deleted file mode 100644
index 43cfa2792..000000000
--- a/FSharpActivePatterns/.zanuda
+++ /dev/null
@@ -1 +0,0 @@
-forward mutability_check ignore exec.ml
diff --git a/FSharpActivePatterns/COPYING b/FSharpActivePatterns/COPYING
deleted file mode 100644
index f288702d2..000000000
--- a/FSharpActivePatterns/COPYING
+++ /dev/null
@@ -1,674 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is 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. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- 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.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- 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 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. Use with the GNU Affero General Public License.
-
- 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 Affero 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 special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU 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 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 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 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.
-
-
- Copyright (C)
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- Copyright (C)
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- 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 GPL, see
-.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-.
diff --git a/FSharpActivePatterns/COPYING.CC0 b/FSharpActivePatterns/COPYING.CC0
deleted file mode 100644
index 0e259d42c..000000000
--- a/FSharpActivePatterns/COPYING.CC0
+++ /dev/null
@@ -1,121 +0,0 @@
-Creative Commons Legal Code
-
-CC0 1.0 Universal
-
- CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
- LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
- ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
- INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
- REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
- PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
- THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
- HEREUNDER.
-
-Statement of Purpose
-
-The laws of most jurisdictions throughout the world automatically confer
-exclusive Copyright and Related Rights (defined below) upon the creator
-and subsequent owner(s) (each and all, an "owner") of an original work of
-authorship and/or a database (each, a "Work").
-
-Certain owners wish to permanently relinquish those rights to a Work for
-the purpose of contributing to a commons of creative, cultural and
-scientific works ("Commons") that the public can reliably and without fear
-of later claims of infringement build upon, modify, incorporate in other
-works, reuse and redistribute as freely as possible in any form whatsoever
-and for any purposes, including without limitation commercial purposes.
-These owners may contribute to the Commons to promote the ideal of a free
-culture and the further production of creative, cultural and scientific
-works, or to gain reputation or greater distribution for their Work in
-part through the use and efforts of others.
-
-For these and/or other purposes and motivations, and without any
-expectation of additional consideration or compensation, the person
-associating CC0 with a Work (the "Affirmer"), to the extent that he or she
-is an owner of Copyright and Related Rights in the Work, voluntarily
-elects to apply CC0 to the Work and publicly distribute the Work under its
-terms, with knowledge of his or her Copyright and Related Rights in the
-Work and the meaning and intended legal effect of CC0 on those rights.
-
-1. Copyright and Related Rights. A Work made available under CC0 may be
-protected by copyright and related or neighboring rights ("Copyright and
-Related Rights"). Copyright and Related Rights include, but are not
-limited to, the following:
-
- i. the right to reproduce, adapt, distribute, perform, display,
- communicate, and translate a Work;
- ii. moral rights retained by the original author(s) and/or performer(s);
-iii. publicity and privacy rights pertaining to a person's image or
- likeness depicted in a Work;
- iv. rights protecting against unfair competition in regards to a Work,
- subject to the limitations in paragraph 4(a), below;
- v. rights protecting the extraction, dissemination, use and reuse of data
- in a Work;
- vi. database rights (such as those arising under Directive 96/9/EC of the
- European Parliament and of the Council of 11 March 1996 on the legal
- protection of databases, and under any national implementation
- thereof, including any amended or successor version of such
- directive); and
-vii. other similar, equivalent or corresponding rights throughout the
- world based on applicable law or treaty, and any national
- implementations thereof.
-
-2. Waiver. To the greatest extent permitted by, but not in contravention
-of, applicable law, Affirmer hereby overtly, fully, permanently,
-irrevocably and unconditionally waives, abandons, and surrenders all of
-Affirmer's Copyright and Related Rights and associated claims and causes
-of action, whether now known or unknown (including existing as well as
-future claims and causes of action), in the Work (i) in all territories
-worldwide, (ii) for the maximum duration provided by applicable law or
-treaty (including future time extensions), (iii) in any current or future
-medium and for any number of copies, and (iv) for any purpose whatsoever,
-including without limitation commercial, advertising or promotional
-purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
-member of the public at large and to the detriment of Affirmer's heirs and
-successors, fully intending that such Waiver shall not be subject to
-revocation, rescission, cancellation, termination, or any other legal or
-equitable action to disrupt the quiet enjoyment of the Work by the public
-as contemplated by Affirmer's express Statement of Purpose.
-
-3. Public License Fallback. Should any part of the Waiver for any reason
-be judged legally invalid or ineffective under applicable law, then the
-Waiver shall be preserved to the maximum extent permitted taking into
-account Affirmer's express Statement of Purpose. In addition, to the
-extent the Waiver is so judged Affirmer hereby grants to each affected
-person a royalty-free, non transferable, non sublicensable, non exclusive,
-irrevocable and unconditional license to exercise Affirmer's Copyright and
-Related Rights in the Work (i) in all territories worldwide, (ii) for the
-maximum duration provided by applicable law or treaty (including future
-time extensions), (iii) in any current or future medium and for any number
-of copies, and (iv) for any purpose whatsoever, including without
-limitation commercial, advertising or promotional purposes (the
-"License"). The License shall be deemed effective as of the date CC0 was
-applied by Affirmer to the Work. Should any part of the License for any
-reason be judged legally invalid or ineffective under applicable law, such
-partial invalidity or ineffectiveness shall not invalidate the remainder
-of the License, and in such case Affirmer hereby affirms that he or she
-will not (i) exercise any of his or her remaining Copyright and Related
-Rights in the Work or (ii) assert any associated claims and causes of
-action with respect to the Work, in either case contrary to Affirmer's
-express Statement of Purpose.
-
-4. Limitations and Disclaimers.
-
- a. No trademark or patent rights held by Affirmer are waived, abandoned,
- surrendered, licensed or otherwise affected by this document.
- b. Affirmer offers the Work as-is and makes no representations or
- warranties of any kind concerning the Work, express, implied,
- statutory or otherwise, including without limitation warranties of
- title, merchantability, fitness for a particular purpose, non
- infringement, or the absence of latent or other defects, accuracy, or
- the present or absence of errors, whether or not discoverable, all to
- the greatest extent permissible under applicable law.
- c. Affirmer disclaims responsibility for clearing rights of other persons
- that may apply to the Work or any use thereof, including without
- limitation any person's Copyright and Related Rights in the Work.
- Further, Affirmer disclaims responsibility for obtaining any necessary
- consents, permissions or other rights required for any use of the
- Work.
- d. Affirmer understands and acknowledges that Creative Commons is not a
- party to this document and has no duty or obligation with respect to
- this CC0 or use of the Work.
diff --git a/FSharpActivePatterns/COPYING.LESSER b/FSharpActivePatterns/COPYING.LESSER
deleted file mode 100644
index 0a041280b..000000000
--- a/FSharpActivePatterns/COPYING.LESSER
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser 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
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/FSharpActivePatterns/FSharpActivePatterns.opam b/FSharpActivePatterns/FSharpActivePatterns.opam
deleted file mode 100644
index bb90632fe..000000000
--- a/FSharpActivePatterns/FSharpActivePatterns.opam
+++ /dev/null
@@ -1,38 +0,0 @@
-# This file is generated by dune, edit dune-project instead
-opam-version: "2.0"
-version: "0.1"
-synopsis: "An interpreter for F# with active patterns"
-description:
- "An interpreter for F# with supported active patterns feature (mb fix later)"
-maintainer: ["Ksenia Kotelnikova, Gleb Nasretdinov"]
-authors: ["Ksenia Kotelnikova, Gleb Nasretdinov"]
-license: "LGPL-3.0-or-later"
-homepage: "https://github.com/Ycyken/fp2024"
-doc: "FIX LATER https://kakadu.github.io/fp2024/docs/Lambda"
-bug-reports: "https://github.com/Ycyken/fp2024"
-depends: [
- "dune" {>= "3.7"}
- "qcheck-core"
- "angstrom"
- "ppx_inline_test" {with-test}
- "ppx_expect"
- "ppx_deriving"
- "ppx_deriving_qcheck"
- "bisect_ppx"
- "odoc" {with-doc}
- "ocamlformat" {build}
-]
-build: [
- ["dune" "subst"] {dev}
- [
- "dune"
- "build"
- "-p"
- name
- "-j"
- jobs
- "@install"
- "@runtest" {with-test}
- "@doc" {with-doc}
- ]
-]
diff --git a/FSharpActivePatterns/Makefile b/FSharpActivePatterns/Makefile
deleted file mode 100644
index 79fbb624c..000000000
--- a/FSharpActivePatterns/Makefile
+++ /dev/null
@@ -1,49 +0,0 @@
-.PHONY: repl tests test fmt lint celan
-
-all:
- dune build
-
-repl:
- dune build ./REPL.exe && rlwrap _build/default/REPL.exe
-
-tests: test
-test:
- dune runtest
-
-celan: clean
-clean:
- @$(RM) -r _build _coverage
-
-fmt:
- dune build @fmt --auto-promote
-
-lint:
- dune build @lint --force
-
-release:
- dune build --profile=release
- dune runtest --profile=release
-
-install:
- dune b @install --profile=release
- dune install
-
-ODIG_SWITCHES = --odoc-theme=odig.gruvbox.light
-ODIG_SWITCHES += --no-tag-index
-ODIG_SWITCHES += --no-pkg-deps
-odig:
- odig odoc $(ODIG_SWITCHES) Lambda
-
-TEST_COV_D = /tmp/cov
-COVERAGE_OPTS = --coverage-path $(TEST_COV_D) --expect lib/ --expect tests/
-
-.PHONY: test_coverage coverage
-test_coverage: coverage
-coverage:
- $(RM) -r $(TEST_COV_D)
- mkdir -p $(TEST_COV_D)
- BISECT_FILE=$(TEST_COV_D)/langauge dune runtest --no-print-directory \
- --instrument-with bisect_ppx --force
- bisect-ppx-report html $(COVERAGE_OPTS)
- bisect-ppx-report summary $(COVERAGE_OPTS)
- @echo "Use 'xdg-open _coverage/index.html' to see coverage report"
diff --git a/FSharpActivePatterns/abc.txt b/FSharpActivePatterns/abc.txt
deleted file mode 100644
index 7b28e9a78..000000000
--- a/FSharpActivePatterns/abc.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-;;
-;;
-;;
-;;
-1;;
-;;
-2;;
-
-
-
-
diff --git a/FSharpActivePatterns/bin/REPL.ml b/FSharpActivePatterns/bin/REPL.ml
deleted file mode 100644
index f7f0260c0..000000000
--- a/FSharpActivePatterns/bin/REPL.ml
+++ /dev/null
@@ -1,31 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open FSharpActivePatterns.REPLUtils
-
-type opts =
- { mutable dump_parsetree : bool
- ; mutable input_file : string option
- }
-
-let () =
- let opts = { dump_parsetree = false; input_file = None } in
- let open Stdlib.Arg in
- let speclist =
- [ ( "-dparsetree"
- , Unit (fun _ -> opts.dump_parsetree <- true)
- , "Dump parse tree, don't evaluate anything" )
- ; ( "-fromfile"
- , String (fun filename -> opts.input_file <- Some filename)
- , "Input file name" )
- ]
- in
- let anon_func _ =
- Stdlib.Format.eprintf "Positioned arguments are not supported\n";
- Stdlib.exit 1
- in
- let usage_msg = "Read-Eval-Print-Loop for F# with Active Patterns" in
- let () = parse speclist anon_func usage_msg in
- run_repl opts.dump_parsetree opts.input_file
-;;
diff --git a/FSharpActivePatterns/bin/dune b/FSharpActivePatterns/bin/dune
deleted file mode 100644
index 1e10d57b2..000000000
--- a/FSharpActivePatterns/bin/dune
+++ /dev/null
@@ -1,6 +0,0 @@
-(executable
- (public_name repl)
- (name REPL)
- (libraries FSharpActivePatterns stdlib str)
- (instrumentation
- (backend bisect_ppx)))
diff --git a/FSharpActivePatterns/bin/input.txt b/FSharpActivePatterns/bin/input.txt
deleted file mode 100644
index 707522f2c..000000000
--- a/FSharpActivePatterns/bin/input.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-let (|Even|Odd|) v =
- if v+2 = 0 then Even (v+10)
- else Odd (v)
-
-let res = match 1 with
- | Even val -> val
- | Odd val -> val
- in print_int res
-
diff --git a/FSharpActivePatterns/dune b/FSharpActivePatterns/dune
deleted file mode 100644
index 98e54536a..000000000
--- a/FSharpActivePatterns/dune
+++ /dev/null
@@ -1,7 +0,0 @@
-(env
- (dev
- (flags
- (:standard -alert @deprecated -warn-error -A -w -3-9-32-34-58)))
- (release
- (flags
- (:standard -alert @deprecated -warn-error +A -w +A-4-40-42-44-70))))
diff --git a/FSharpActivePatterns/dune-project b/FSharpActivePatterns/dune-project
deleted file mode 100644
index d26478070..000000000
--- a/FSharpActivePatterns/dune-project
+++ /dev/null
@@ -1,34 +0,0 @@
-(lang dune 3.7)
-
-(generate_opam_files true)
-
-(cram enable)
-
-(license LGPL-3.0-or-later)
-
-(authors "Ksenia Kotelnikova, Gleb Nasretdinov")
-
-(maintainers "Ksenia Kotelnikova, Gleb Nasretdinov")
-
-(bug_reports "https://github.com/Ycyken/fp2024")
-
-(homepage "https://github.com/Ycyken/fp2024")
-
-(package
- (name FSharpActivePatterns)
- (synopsis "An interpreter for F# with active patterns")
- (description
- "An interpreter for F# with supported active patterns feature (mb fix later)")
- (documentation "FIX LATER https://kakadu.github.io/fp2024/docs/Lambda")
- (version 0.1)
- (depends
- dune
- qcheck-core
- angstrom
- (ppx_inline_test :with-test)
- ppx_expect
- ppx_deriving
- ppx_deriving_qcheck
- bisect_ppx
- (odoc :with-doc)
- (ocamlformat :build)))
diff --git a/FSharpActivePatterns/lib/REPLUtils.ml b/FSharpActivePatterns/lib/REPLUtils.ml
deleted file mode 100644
index c58438bba..000000000
--- a/FSharpActivePatterns/lib/REPLUtils.ml
+++ /dev/null
@@ -1,163 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open AstPrinter
-open Parser
-open Inferencer
-open TypesPp
-open Ast
-open Interpreter
-open Stdlib
-
-type input =
- | Input of string
- | EOF
-
-type run_result =
- | Result of (construction, string) result
- | Empty
- | End
-
-let input_upto_sep sep ic =
- let sep_len = String.length sep in
- let take_line () = In_channel.input_line ic in
- let rec fill_buffer b =
- let line = take_line () in
- match line with
- | None -> EOF
- | Some line ->
- let line = String.trim line in
- let len = String.length line in
- if String.ends_with ~suffix:sep line
- then (
- Buffer.add_substring b line 0 (len - sep_len);
- Buffer.add_string b "\n";
- Input (Buffer.contents b))
- else (
- Buffer.add_string b line;
- Buffer.add_string b "\n";
- fill_buffer b)
- in
- let buffer = Buffer.create 1024 in
- fill_buffer buffer
-;;
-
-let input_with_indents ic =
- let take_line () = In_channel.input_line ic in
- let rec fill_buffer b =
- let start_pos = pos_in ic in
- let line = take_line () in
- match line with
- | None -> Input (Buffer.contents b)
- | Some line ->
- let is_empty = String.length line = 0 in
- let is_continue =
- List.exists (fun pref -> String.starts_with ~prefix:pref line) [ " "; "\t"; "\n" ]
- || is_empty
- || String.starts_with ~prefix:"and" (String.trim line)
- in
- if is_continue
- then (
- Buffer.add_string b (line ^ "\n");
- fill_buffer b)
- else (
- seek_in ic start_pos;
- Buffer.add_string b "\n";
- Input (Buffer.contents b))
- in
- let buffer = Buffer.create 1024 in
- let first_line = take_line () in
- match first_line with
- | None -> EOF
- | Some first_line ->
- Buffer.add_string buffer (first_line ^ "\n");
- fill_buffer buffer
-;;
-
-type in_channel =
- | File of Stdlib.in_channel
- | Stdin
-
-let run_single ic =
- let input =
- match ic with
- | Stdin -> input_upto_sep ";;" Stdlib.stdin
- | File ic -> input_with_indents ic
- in
- match input with
- | EOF -> End
- | Input input -> if String.trim input = "" then Empty else Result (parse input)
-;;
-
-let run_repl dump_parsetree input_file =
- let ic =
- match input_file with
- | Some n -> File (open_in n)
- | None -> Stdin
- in
- let rec run_repl_helper run type_env value_env state values_acc =
- let open Format in
- match run ic with
- | Result (Error _) ->
- fprintf err_formatter "Parsing error\n";
- run_repl_helper run type_env value_env state values_acc
- | Empty ->
- fprintf std_formatter "\n";
- print_flush ();
- run_repl_helper run type_env value_env state values_acc
- | End -> type_env, value_env, values_acc
- | Result (Ok ast) ->
- if dump_parsetree
- then (
- print_construction std_formatter ast;
- run_repl_helper run type_env value_env state values_acc)
- else (
- let result = run_interpreter type_env value_env state ast in
- match result with
- | new_state, Error err ->
- fprintf err_formatter "Error occured: %a\n" pp_global_error err;
- print_flush ();
- run_repl_helper run type_env value_env new_state values_acc
- | new_state, Ok (new_type_env, new_value_env, evaled_names) ->
- (match ic with
- | Stdin ->
- Base.Map.iteri
- ~f:(fun ~key ~data ->
- let t, v = data in
- fprintf
- std_formatter
- "val %s : %a = %a\n"
- key
- pp_typ
- t
- ValueEnv.pp_value
- v)
- evaled_names;
- print_flush ();
- run_repl_helper run new_type_env new_value_env new_state values_acc
- | File _ ->
- let overwrite map1 map2 =
- Base.Map.fold
- ~init:map1
- ~f:(fun ~key ~data map1 -> Base.Map.set map1 ~key ~data)
- map2
- in
- let values_acc = overwrite values_acc evaled_names in
- run_repl_helper run new_type_env new_value_env new_state values_acc))
- in
- let type_env = TypeEnv.default in
- let value_env = ValueEnv.default in
- let _, _, evaled_values =
- run_repl_helper run_single type_env value_env 0 (Base.Map.empty (module Base.String))
- in
- Base.Map.iteri evaled_values ~f:(fun ~key ~data:(typ, value) ->
- Format.fprintf
- Format.std_formatter
- "val %s : %a = %a\n"
- key
- pp_typ
- typ
- ValueEnv.pp_value
- value)
-;;
diff --git a/FSharpActivePatterns/lib/REPLUtils.mli b/FSharpActivePatterns/lib/REPLUtils.mli
deleted file mode 100644
index 7ae8b592b..000000000
--- a/FSharpActivePatterns/lib/REPLUtils.mli
+++ /dev/null
@@ -1,5 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-val run_repl : bool -> string option -> unit
diff --git a/FSharpActivePatterns/lib/ast.ml b/FSharpActivePatterns/lib/ast.ml
deleted file mode 100644
index cd1c8d13a..000000000
--- a/FSharpActivePatterns/lib/ast.ml
+++ /dev/null
@@ -1,200 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open KeywordChecker
-open TypedTree
-open TypesPp
-
-type ident = Ident of string (** identifier *) [@@deriving show { with_path = false }]
-
-let gen_char_of_range l r =
- QCheck.Gen.(map Char.chr (int_range (Char.code l) (Char.code r)))
-;;
-
-let gen_varname ~uppercase =
- let open QCheck.Gen in
- let loop =
- let gen_first_char =
- if uppercase
- then frequency [ 26, gen_char_of_range 'A' 'Z'; 1, return '_' ]
- else frequency [ 26, gen_char_of_range 'a' 'z'; 1, return '_' ]
- in
- let gen_next_char =
- frequency [ 26 + 26 + 1, gen_first_char; 10, gen_char_of_range '0' '9' ]
- in
- map2
- (fun first rest -> String.make 1 first ^ Base.String.of_char_list rest)
- gen_first_char
- (list_size (1 -- 3) gen_next_char)
- in
- loop >>= fun name -> if is_keyword name then loop else return name
-;;
-
-let gen_ident = QCheck.Gen.map (fun s -> Ident s) (gen_varname ~uppercase:false)
-let gen_ident_uppercase = QCheck.Gen.map (fun s -> Ident s) (gen_varname ~uppercase:true)
-
-let gen_escape_sequence =
- let open QCheck.Gen in
- oneofl [ "\\\""; "\\\\"; "\\n"; "\\t" ]
-;;
-
-let gen_string_of_regular_char =
- let open QCheck.Gen in
- let gen_int =
- frequency
- [ 33 - 32 + 1, int_range 32 33
- ; 91 - 35 + 1, int_range 35 91
- ; 126 - 93 + 1, int_range 93 126
- ]
- in
- map (fun c -> String.make 1 c) (map Char.chr gen_int)
-;;
-
-let gen_string =
- let open QCheck.Gen in
- let atom = frequency [ 1, gen_escape_sequence; 30, gen_string_of_regular_char ] in
- let+ atoms = list_size (0 -- 20) atom in
- String.concat "" atoms
-;;
-
-type literal =
- | Int_lt of (int[@gen QCheck.Gen.pint]) (** [0], [1], [30] *)
- | Bool_lt of bool (** [false], [true] *)
- | String_lt of (string[@gen gen_string]) (** ["Hello world"] *)
- | Unit_lt (** [Unit] *)
-[@@deriving show { with_path = false }, qcheck]
-
-type binary_operator =
- | Binary_equal (** [=] *)
- | Binary_unequal (** [<>] *)
- | Binary_less (** [<] *)
- | Binary_less_or_equal (** [<=] *)
- | Binary_greater (** [>] *)
- | Binary_greater_or_equal (** [>=] *)
- | Binary_add (** [+] *)
- | Binary_subtract (** [-] *)
- | Binary_multiply (** [*] *)
- | Logical_or (** [||] *)
- | Logical_and (** [&&] *)
- | Binary_divide (** [/] *)
- | Binary_or_bitwise (** [|||] *)
- | Binary_xor_bitwise (** [^^^] *)
- | Binary_and_bitwise (** [&&&] *)
- | Binary_cons (** [::] *)
-[@@deriving show { with_path = false }, qcheck]
-
-type unary_operator =
- | Unary_minus (** unary [-] *)
- | Unary_not (** unary [not] *)
-[@@deriving show { with_path = false }, qcheck]
-
-type pattern =
- | Wild (** [_] *)
- | PList of
- (pattern list[@gen QCheck.Gen.(list_size (0 -- 3) (gen_pattern_sized (n / 20)))])
- (**[ [], [1;2;3] ] *)
- | PCons of pattern * pattern (**[ hd :: tl ] *)
- | PTuple of
- pattern
- * pattern
- * (pattern list[@gen QCheck.Gen.(list_size (0 -- 2) (gen_pattern_sized (n / 20)))])
- (** | [(a, b)] -> *)
- | PConst of literal (** | [4] -> *)
- | PVar of ident (** pattern identifier *)
- | POption of pattern option
- (*| Variant of (ident list[@gen gen_ident_small_list]) (** | [Blue, Green, Yellow] -> *) *)
- | PConstraint of pattern * (typ[@gen gen_typ_primitive])
- | PActive of (ident[@gen gen_ident_uppercase]) * pattern
- (** | Email str -> _ | Phone [(num, country)] -> _ *)
-[@@deriving show { with_path = false }, qcheck]
-
-type is_recursive =
- | Nonrec (** let factorial n = ... *)
- | Rec (** let rec factorial n = ... *)
-[@@deriving show { with_path = false }, qcheck]
-
-type case = (pattern[@gen gen_pattern_sized n]) * (expr[@gen gen_expr_sized n])
-[@@deriving show { with_path = false }, qcheck]
-
-and expr =
- | Const of literal (** [Int], [Bool], [String], [Unit], [Null] *)
- | Tuple of
- (expr[@gen gen_expr_sized (n / 4)])
- * (expr[@gen gen_expr_sized (n / 4)])
- * (expr list[@gen QCheck.Gen.(list_size (0 -- 2) (gen_expr_sized (n / 20)))])
- (** [(1, "Hello world", true)] *)
- | List of (expr list[@gen QCheck.Gen.(list_size (0 -- 3) (gen_expr_sized (n / 20)))])
- (** [], [1;2;3] *)
- | Variable of ident (** [x], [y] *)
- | Unary_expr of unary_operator * expr (** -x *)
- | Bin_expr of binary_operator * expr * expr (** [1 + 2], [3 ||| 12], hd :: tl *)
- | If_then_else of
- (expr[@gen gen_expr_sized (n / 4)])
- * (expr[@gen gen_expr_sized (n / 4)])
- * (expr option[@gen QCheck.Gen.option (gen_expr_sized (n / 4))])
- (** [if n % 2 = 0 then "Even" else "Odd"] *)
- | Lambda of
- (pattern[@gen gen_pattern_sized (n / 2)])
- * (pattern list[@gen QCheck.Gen.(list_size (0 -- 2) (gen_pattern_sized (n / 20)))])
- * expr (** fun x y -> x + y *)
- | Apply of (expr[@gen gen_expr_sized (n / 4)]) * (expr[@gen gen_expr_sized (n / 4)])
- (** [sum 1 ] *)
- | Function of
- (case[@gen gen_case_sized (n / 4)])
- * (case list[@gen QCheck.Gen.(list_size (0 -- 2) (gen_case_sized (n / 20)))])
- (** [function | p1 -> e1 | p2 -> e2 | ... |]*)
- | Match of
- (expr[@gen gen_expr_sized (n / 4)])
- * (case[@gen gen_case_sized (n / 4)])
- * (case list[@gen QCheck.Gen.(list_size (0 -- 2) (gen_case_sized (n / 20)))])
- (** [match x with | p1 -> e1 | p2 -> e2 | ...] *)
- | LetIn of
- is_recursive
- * let_bind
- * (let_bind list
- [@gen QCheck.Gen.(list_size (0 -- 2) (gen_let_bind_sized (n / 20)))])
- * expr (** [let rec f x = if (x <= 0) then x else g x and g x = f (x-2) in f 3] *)
- | Option of expr option (** [int option] *)
- | EConstraint of expr * (typ[@gen gen_typ_primitive])
- | ActPatConstructor of
- (ident[@gen gen_ident_uppercase]) * (expr[@gen gen_expr_sized (n / 4)])
- (** return Phone [(num, country)] *)
-[@@deriving show { with_path = false }, qcheck]
-
-and let_bind =
- | Let_bind of
- (pattern[@gen gen_pattern_sized (n / 2)])
- * (pattern list[@gen QCheck.Gen.(list_size (0 -- 3) (gen_pattern_sized (n / 4)))])
- * expr (** [let sum n m = n + m] *)
-[@@deriving show { with_path = false }, qcheck]
-
-let gen_expr =
- QCheck.Gen.(
- let* n = small_nat in
- gen_expr_sized n)
-;;
-
-let gen_let_bind =
- QCheck.Gen.(
- let* n = small_nat in
- gen_let_bind_sized n)
-;;
-
-type statement =
- | Let of
- is_recursive
- * let_bind
- * (let_bind list[@gen QCheck.Gen.(list_size (0 -- 2) gen_let_bind)])
- (** [let name = expr] *)
- | ActPat of
- (ident[@gen gen_ident_uppercase])
- * (ident list[@gen QCheck.Gen.(list_size (0 -- 3) gen_ident_uppercase)])
- * (pattern list[@gen QCheck.Gen.(list_size (0 -- 2) gen_pattern)])
- * expr (** [let (|Even|Odd|) input = if input % 2 = 0 then Even else Odd] *)
-[@@deriving show { with_path = false }, qcheck]
-
-type construction =
- | Expr of expr (** expression *)
- | Statement of statement (** statement *)
-[@@deriving show { with_path = false }, qcheck]
diff --git a/FSharpActivePatterns/lib/astPrinter.ml b/FSharpActivePatterns/lib/astPrinter.ml
deleted file mode 100644
index 7b639e9c3..000000000
--- a/FSharpActivePatterns/lib/astPrinter.ml
+++ /dev/null
@@ -1,217 +0,0 @@
-[@@@ocaml.text "/*"]
-
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-[@@@ocaml.text "/*"]
-
-open Format
-open Ast
-open TypesPp
-
-let print_bin_op indent fmt = function
- | Binary_equal -> fprintf fmt "%s| Binary Equal\n" (String.make indent '-')
- | Binary_unequal -> fprintf fmt "%s| Binary Unequal\n" (String.make indent '-')
- | Binary_less -> fprintf fmt "%s| Binary Less\n" (String.make indent '-')
- | Binary_less_or_equal ->
- fprintf fmt "%s| Binary Less Or Equal\n" (String.make indent '-')
- | Binary_greater -> fprintf fmt "%s| Binary Greater\n" (String.make indent '-')
- | Binary_greater_or_equal ->
- fprintf fmt "%s| Binary Greater Or Equal\n" (String.make indent '-')
- | Binary_add -> fprintf fmt "%s| Binary Add\n" (String.make indent '-')
- | Binary_subtract -> fprintf fmt "%s| Binary Subtract\n" (String.make indent '-')
- | Binary_multiply -> fprintf fmt "%s| Binary Multiply\n" (String.make indent '-')
- | Logical_or -> fprintf fmt "%s| Logical Or\n" (String.make indent '-')
- | Logical_and -> fprintf fmt "%s| Logical And\n" (String.make indent '-')
- | Binary_divide -> fprintf fmt "%s| Binary Divide\n" (String.make indent '-')
- | Binary_or_bitwise -> fprintf fmt "%s| Binary Or Bitwise\n" (String.make indent '-')
- | Binary_xor_bitwise -> fprintf fmt "%s| Binary Xor Bitwise\n" (String.make indent '-')
- | Binary_and_bitwise -> fprintf fmt "%s| Binary And Bitwise\n" (String.make indent '-')
- | Binary_cons -> fprintf fmt "%s| Binary Cons\n" (String.make indent '-')
-;;
-
-let rec print_pattern indent fmt = function
- | Wild -> fprintf fmt "%s| Wild\n" (String.make indent '-')
- | PList l ->
- fprintf fmt "%s| PList:\n" (String.make indent '-');
- List.iter (print_pattern (indent + 2) fmt) l
- | PTuple (p1, p2, rest) ->
- fprintf fmt "%s| PTuple:\n" (String.make indent '-');
- List.iter (print_pattern (indent + 2) fmt) (p1 :: p2 :: rest)
- | PConst literal ->
- fprintf fmt "%s| PConst:\n" (String.make indent '-');
- (match literal with
- | Int_lt i -> fprintf fmt "%sInt: %d\n" (String.make (indent + 2) '-') i
- | Bool_lt b -> fprintf fmt "%sBool: %b\n" (String.make (indent + 2) '-') b
- | String_lt s -> fprintf fmt "%sString: %S\n" (String.make (indent + 2) '-') s
- | Unit_lt -> fprintf fmt "%sUnit\n" (String.make (indent + 2) '-'))
- | PCons (l, r) ->
- fprintf fmt "%s| PCons:\n" (String.make indent '-');
- print_pattern (indent + 2) fmt l;
- print_pattern (indent + 2) fmt r
- | PVar (Ident name) -> fprintf fmt "%s| PVar(%s)\n" (String.make indent '-') name
- | POption p ->
- fprintf fmt "%s| POption " (String.make indent '-');
- (match p with
- | None -> fprintf fmt "None\n"
- | Some p ->
- fprintf fmt "Some:\n";
- print_pattern (indent + 2) fmt p)
- | PConstraint (p, t) ->
- fprintf fmt "%s| PConstraint\n" (String.make indent ' ');
- fprintf fmt "%sPattern:\n" (String.make (indent + 2) ' ');
- print_pattern (indent + 2) fmt p;
- fprintf fmt "%sType:\n" (String.make (indent + 2) ' ');
- fprintf fmt "%s| %a\n" (String.make (indent + 2) '-') pp_typ t
- | PActive (Ident name, p) ->
- fprintf fmt "%s| PActive\n" (String.make indent ' ');
- fprintf fmt "%sName: %s \n" (String.make (indent + 2) ' ') name;
- fprintf fmt "%sPattern:\n" (String.make (indent + 2) ' ');
- print_pattern (indent + 2) fmt p
-;;
-
-let print_unary_op indent fmt = function
- | Unary_minus -> fprintf fmt "%s| Unary minus\n" (String.make indent '-')
- | Unary_not -> fprintf fmt "%s| Unary negative\n" (String.make indent '-')
-;;
-
-let rec print_let_bind indent fmt = function
- | Let_bind (name, args, body) ->
- fprintf fmt "%s| Let_bind:\n" (String.make indent '-');
- fprintf fmt "%sNAME:\n" (String.make (indent + 4) ' ');
- print_pattern (indent + 4) fmt name;
- fprintf fmt "%sARGS:\n" (String.make (indent + 4) ' ');
- List.iter (fun arg -> print_pattern (indent + 2) fmt arg) args;
- fprintf fmt "%sBODY:\n" (String.make (indent + 4) ' ');
- print_expr (indent + 2) fmt body
-
-and print_expr indent fmt expr =
- match expr with
- | Const (Int_lt i) -> fprintf fmt "%s| Const(Int: %d)\n" (String.make indent '-') i
- | Const (Bool_lt b) -> fprintf fmt "%s| Const(Bool: %b)\n" (String.make indent '-') b
- | Const (String_lt s) ->
- fprintf fmt "%s| Const(String: %S)\n" (String.make indent '-') s
- | Const Unit_lt -> fprintf fmt "%s| Const(Unit)\n" (String.make indent '-')
- | List l ->
- fprintf fmt "%s| PList:\n" (String.make indent '-');
- List.iter (print_expr (indent + 2) fmt) l
- | Tuple (e1, e2, rest) ->
- fprintf fmt "%s| Tuple:\n" (String.make indent '-');
- List.iter (print_expr (indent + 2) fmt) (e1 :: e2 :: rest)
- | Function ((pat1, expr1), cases) ->
- fprintf fmt "%s| Function:\n" (String.make indent '-');
- List.iter
- (fun (pat, expr) ->
- fprintf fmt "%s| Pattern:\n" (String.make (indent + 2) '-');
- print_pattern (indent + 4) fmt pat;
- fprintf fmt "%s| Case expr:\n" (String.make (indent + 2) '-');
- print_expr (indent + 4) fmt expr)
- ((pat1, expr1) :: cases)
- | Match (value, (pat1, expr1), cases) ->
- fprintf fmt "%s| Match:\n" (String.make indent '-');
- fprintf fmt "%s| Value:\n" (String.make (indent + 2) '-');
- print_expr (indent + 4) fmt value;
- List.iter
- (fun (pat, expr) ->
- fprintf fmt "%s| Pattern:\n" (String.make (indent + 2) '-');
- print_pattern (indent + 4) fmt pat;
- fprintf fmt "%s| Case expr:\n" (String.make (indent + 2) '-');
- print_expr (indent + 4) fmt expr)
- ((pat1, expr1) :: cases)
- | Variable (Ident name) ->
- fprintf fmt "%s| Variable(%s)\n" (String.make indent '-') name
- | Unary_expr (op, expr) ->
- fprintf fmt "%s| Unary expr(\n" (String.make indent '-');
- print_unary_op indent fmt op;
- print_expr (indent + 2) fmt expr
- | Bin_expr (op, left, right) ->
- fprintf fmt "%s| Binary expr(\n" (String.make indent '-');
- print_bin_op indent fmt op;
- print_expr (indent + 2) fmt left;
- print_expr (indent + 2) fmt right
- | If_then_else (cond, then_body, else_body) ->
- fprintf fmt "%s| If Then Else(\n" (String.make indent '-');
- fprintf fmt "%sCONDITION\n" (String.make (indent + 2) ' ');
- print_expr (indent + 2) fmt cond;
- fprintf fmt "%sTHEN BRANCH\n" (String.make (indent + 2) ' ');
- print_expr (indent + 2) fmt then_body;
- fprintf fmt "%sELSE BRANCH\n" (String.make (indent + 2) ' ');
- (match else_body with
- | Some body -> print_expr (indent + 2) fmt body
- | None -> fprintf fmt "%s| No else body\n" (String.make (indent + 2) '-'))
- | Lambda (arg1, args, body) ->
- fprintf fmt "%s| Lambda:\n" (String.make indent '-');
- fprintf fmt "%sARGS\n" (String.make (indent + 2) ' ');
- List.iter (fun pat -> print_pattern (indent + 4) fmt pat) (arg1 :: args);
- fprintf fmt "%sBODY\n" (String.make (indent + 2) ' ');
- print_expr (indent + 4) fmt body
- | Apply (func, arg) ->
- fprintf fmt "%s| Apply:\n" (String.make indent '-');
- fprintf fmt "%sFUNCTION\n" (String.make (indent + 2) ' ');
- print_expr (indent + 2) fmt func;
- fprintf fmt "%sARGS\n" (String.make (indent + 2) ' ');
- print_expr (indent + 2) fmt arg
- | LetIn (rec_flag, let_bind, let_bind_list, inner_e) ->
- fprintf
- fmt
- "%s| %sLetIn=\n"
- (String.make indent '-')
- (match rec_flag with
- | Nonrec -> ""
- | Rec -> "Rec ");
- fprintf fmt "%sLet_binds\n" (String.make (indent + 2) ' ');
- List.iter (print_let_bind (indent + 2) fmt) (let_bind :: let_bind_list);
- fprintf fmt "%sINNER_EXPRESSION\n" (String.make (indent + 2) ' ');
- print_expr (indent + 2) fmt inner_e
- | Option e ->
- (match e with
- | None -> fprintf fmt "%s| Option: None\n" (String.make indent '-')
- | Some e ->
- fprintf fmt "%s| Option: Some\n" (String.make indent '-');
- print_expr (indent + 2) fmt e)
- | EConstraint (e, t) ->
- fprintf fmt "%s| EConstraint\n" (String.make indent ' ');
- fprintf fmt "%sExpr:\n" (String.make (indent + 2) ' ');
- print_expr (indent + 2) fmt e;
- fprintf fmt "%sType:\n" (String.make (indent + 2) ' ');
- fprintf fmt "%s| %a\n" (String.make (indent + 2) '-') pp_typ t
- | ActPatConstructor (Ident name, e) ->
- fprintf fmt "%s| EActPatConstructor\n" (String.make indent ' ');
- fprintf fmt "%s| %s\n" (String.make (indent + 2) ' ') name;
- fprintf fmt "%sExpr:\n" (String.make (indent + 2) ' ');
- print_expr (indent + 2) fmt e
-;;
-
-let print_statement indent fmt = function
- | Let (rec_flag, let_bind, let_bind_list) ->
- fprintf
- fmt
- "%s |%s Let:\n"
- (String.make indent '-')
- (match rec_flag with
- | Nonrec -> ""
- | Rec -> "Rec ");
- fprintf fmt "%s Let_binds\n" (String.make (indent + 2) ' ');
- List.iter (print_let_bind (indent + 2) fmt) (let_bind :: let_bind_list)
- | ActPat (Ident name, name_list, args, expr) ->
- fprintf fmt "%s| Active Pattern\n" (String.make indent '-');
- fprintf fmt "%s| %s\n" (String.make (indent + 2) ' ') name;
- List.iter
- (fun (Ident name) -> fprintf fmt "%s| %s\n" (String.make (indent + 2) ' ') name)
- name_list;
- fprintf fmt "%s| ARGS\n" (String.make indent '-');
- List.iter (fun pat -> print_pattern (indent + 2) fmt pat) args;
- fprintf fmt "%s| BODY\n" (String.make indent '-');
- print_expr (indent + 2) fmt expr
-;;
-
-let print_construction fmt = function
- | Expr e -> print_expr 0 fmt e
- | Statement s -> print_statement 0 fmt s
-;;
-
-let print_p_res fmt = function
- | Ok ast -> print_construction fmt ast
- | Error e -> fprintf fmt "%s\n" e
-;;
diff --git a/FSharpActivePatterns/lib/astPrinter.mli b/FSharpActivePatterns/lib/astPrinter.mli
deleted file mode 100644
index c2a769e9c..000000000
--- a/FSharpActivePatterns/lib/astPrinter.mli
+++ /dev/null
@@ -1,9 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-open Format
-
-val print_construction : formatter -> construction -> unit
-val print_p_res : formatter -> (construction, tag) result -> unit
diff --git a/FSharpActivePatterns/lib/dune b/FSharpActivePatterns/lib/dune
deleted file mode 100644
index 15e328e1a..000000000
--- a/FSharpActivePatterns/lib/dune
+++ /dev/null
@@ -1,20 +0,0 @@
-(library
- (name FSharpActivePatterns)
- (public_name FSharpActivePatterns)
- (modules
- Ast
- Parser
- AstPrinter
- PrettyPrinter
- KeywordChecker
- Inferencer
- TypedTree
- TypesPp
- Interpreter
- ExtractIdents
- REPLUtils)
- (libraries angstrom base)
- (preprocess
- (pps ppx_deriving_qcheck ppx_deriving.show))
- (instrumentation
- (backend bisect_ppx)))
diff --git a/FSharpActivePatterns/lib/extractIdents.ml b/FSharpActivePatterns/lib/extractIdents.ml
deleted file mode 100644
index 94a724e33..000000000
--- a/FSharpActivePatterns/lib/extractIdents.ml
+++ /dev/null
@@ -1,73 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-open Base
-
-module type R = sig
- type 'a t
- type error
-
- val return : 'a -> 'a t
- val fail : error -> 'a t
- val bound_error : error
-
- module Syntax : sig
- val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t
- end
-end
-
-module ExtractIdents (R : R) : sig
- type t
-
- val extract_names_from_pattern : pattern -> t R.t
- val extract_names_from_patterns : pattern list -> t R.t
- val extract_bind_names_from_let_binds : let_bind list -> t R.t
- val extract_bind_patterns_from_let_binds : let_bind list -> pattern list
- val elements : t -> string list
-end = struct
- include Stdlib.Set.Make (String)
- open R
- open R.Syntax
-
- let union_disjoint s1 s2 =
- let* s1 = s1 in
- let* s2 = s2 in
- if is_empty (inter s1 s2) then return (union s1 s2) else fail bound_error
- ;;
-
- let union_disjoint_many sets = List.fold ~init:(return empty) ~f:union_disjoint sets
-
- let rec extract_names_from_pattern =
- let extr = extract_names_from_pattern in
- function
- | PVar (Ident name) -> return (singleton name)
- | PList l -> union_disjoint_many (List.map l ~f:extr)
- | PCons (hd, tl) -> union_disjoint (extr hd) (extr tl)
- | PTuple (fst, snd, rest) ->
- union_disjoint_many (List.map ~f:extr (fst :: snd :: rest))
- | POption (Some p) -> extr p
- | PConstraint (p, _) -> extr p
- | POption None -> return empty
- | Wild -> return empty
- | PConst _ -> return empty
- | PActive (Ident name, _) -> return (singleton name)
- ;;
-
- let extract_names_from_patterns pats =
- union_disjoint_many (List.map ~f:extract_names_from_pattern pats)
- ;;
-
- let extract_bind_names_from_let_binds let_binds =
- union_disjoint_many
- (List.map let_binds ~f:(function Let_bind (pat, _, _) ->
- extract_names_from_pattern pat))
- ;;
-
- let extract_bind_patterns_from_let_binds let_binds =
- List.map let_binds ~f:(function Let_bind (pat, _, _) -> pat)
- ;;
-end
-
-module Make = ExtractIdents
diff --git a/FSharpActivePatterns/lib/extractIdents.mli b/FSharpActivePatterns/lib/extractIdents.mli
deleted file mode 100644
index c67bdeb79..000000000
--- a/FSharpActivePatterns/lib/extractIdents.mli
+++ /dev/null
@@ -1,28 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-
-module type R = sig
- type 'a t
- type error
-
- val return : 'a -> 'a t
- val fail : error -> 'a t
- val bound_error : error
-
- module Syntax : sig
- val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t
- end
-end
-
-module Make (R : R) : sig
- type t
-
- val extract_names_from_pattern : pattern -> t R.t
- val extract_names_from_patterns : pattern list -> t R.t
- val extract_bind_names_from_let_binds : let_bind list -> t R.t
- val extract_bind_patterns_from_let_binds : let_bind list -> pattern list
- val elements : t -> string list
-end
diff --git a/FSharpActivePatterns/lib/inferencer.ml b/FSharpActivePatterns/lib/inferencer.ml
deleted file mode 100644
index f4499906c..000000000
--- a/FSharpActivePatterns/lib/inferencer.ml
+++ /dev/null
@@ -1,892 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-open TypedTree
-open TypesPp
-open Format
-open Base
-
-module InferenceError = struct
- type t =
- [ `Occurs_check
- | `Undef_var of string
- | `Unification_failed of typ * typ
- | `Not_allowed_right_hand_side_let_rec
- | `Not_allowed_left_hand_side_let_rec
- | `Args_after_not_variable_let
- | `Bound_several_times
- | `Active_pattern_are_not_determined_by_input
- ]
-
- let bound_error = `Bound_several_times
-
- let pp_error fmt : t -> _ = function
- | `Occurs_check -> fprintf fmt "Occurs check failed"
- | `Undef_var s -> fprintf fmt "Undefined variable '%s'" s
- | `Unification_failed (fst, snd) ->
- fprintf fmt "unification failed on %a and %a\n" pp_typ fst pp_typ snd
- | `Not_allowed_right_hand_side_let_rec ->
- fprintf fmt "This kind of expression is not allowed as right-hand side of `let rec'"
- | `Not_allowed_left_hand_side_let_rec ->
- fprintf fmt "Only variables are allowed as left-hand side of `let rec'"
- | `Args_after_not_variable_let ->
- fprintf fmt "Arguments in let allowed only after variable"
- | `Bound_several_times -> fprintf fmt "Variable is bound several times"
- | `Active_pattern_are_not_determined_by_input ->
- fprintf fmt "Some active pattern are not determined by input"
- ;;
-end
-
-(* for treating result of type inference *)
-module R : sig
- type 'a t
- type error = InferenceError.t
-
- val bound_error : error
- val pp_error : formatter -> error -> unit
-
- (* val bind : 'a t -> f:('a -> 'b t) -> 'b t *)
- val return : 'a -> 'a t
- val fail : error -> 'a t
-
- include Base.Monad.Infix with type 'a t := 'a t
-
- module Syntax : sig
- val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t
- end
-
- module RList : sig
- val fold_left : 'a list -> init:'b t -> f:('b -> 'a -> 'b t) -> 'b t
- end
-
- val fresh : int t
- val run : 'a t -> int -> int * ('a, error) Result.t
-
- module RMap : sig
- val fold : ('a, 'b, 'c) Map.t -> init:'d t -> f:('a -> 'b -> 'd -> 'd t) -> 'd t
- end
-end = struct
- include InferenceError
-
- type error = InferenceError.t
-
- (* takes current state, runs smth, outputs new state and success / error *)
- type 'a t = int -> int * ('a, error) Result.t
-
- (* bind -- if applying new state to first arg is correct, then apply f to
- new argument and new state, else output error and state that caused it *)
- let ( >>= ) : 'a 'b. 'a t -> ('a -> 'b t) -> 'b t =
- fun m f st ->
- let last, r = m st in
- match r with
- | Result.Error x -> last, Error x
- | Ok a -> f a last
- ;;
-
- (* is called to cover result in fail or ok constructions *)
- let fail e st = st, Base.Result.fail e
- let return x last = last, Base.Result.return x
- let bind x ~f = x >>= f
-
- (* is called from x, function and state. if applying state to x is correct,
- then output applying f to x in constructor Ok, otherwise output error and
- state that caused it *)
- let ( >>| ) : 'a 'b. 'a t -> ('a -> 'b) -> 'b t =
- fun x f st ->
- match x st with
- | st, Ok x -> st, Ok (f x)
- | st, Result.Error e -> st, Result.Error e
- ;;
-
- module Syntax = struct
- let ( let* ) x f = bind x ~f
- end
-
- (* for applying f to all elements x of list xs with check that everything is
- correct. If it is, outputs accumulator of all applyings *)
- module RList = struct
- let fold_left xs ~init ~f =
- Base.List.fold_left xs ~init ~f:(fun acc x ->
- let open Syntax in
- let* acc = acc in
- f acc x)
- ;;
- end
-
- (* analogically to list. let* acc = acc is to extract value from type t *)
- module RMap = struct
- let fold map ~init ~f =
- Map.fold map ~init ~f:(fun ~key ~data acc ->
- let open Syntax in
- let* acc = acc in
- f key data acc)
- ;;
- end
-
- (* takes current state, returns state + 1 *)
- let fresh : int t = fun last -> last + 1, Result.Ok last
- let run m = m
-end
-
-type fresh = int
-
-(* module with all type methods *)
-module Type : sig
- type t = typ
-
- val occurs_in : fresh -> t -> bool
- val free_vars : t -> binder_set
-end = struct
- type t = typ
-
- (* check that v is not inside of second type.
- Runs during substitution to ensure that there are no cycles*)
- let rec occurs_in v = function
- | Primitive _ -> false
- | Type_var b -> b = v
- | Arrow (fst, snd) -> occurs_in v fst || occurs_in v snd
- | Type_list typ -> occurs_in v typ
- | Type_tuple (fst, snd, rest) -> List.exists (fst :: snd :: rest) ~f:(occurs_in v)
- | Choice map -> List.exists ~f:(occurs_in v) (choice_to_list map)
- | TOption t -> occurs_in v t
- | TActPat (_, typ) -> occurs_in v typ
- ;;
-
- (* collects all type variables *)
- let free_vars =
- let rec helper acc = function
- | Primitive _ -> acc
- | Type_var b -> VarSet.add b acc
- | Arrow (fst, snd) -> helper (helper acc fst) snd
- | Type_list typ -> helper acc typ
- | Type_tuple (fst, snd, rest) -> List.fold (fst :: snd :: rest) ~init:acc ~f:helper
- | Choice map -> List.fold (choice_to_list map) ~init:acc ~f:helper
- | TOption t -> helper acc t
- | TActPat (_, t) -> helper acc t
- in
- helper VarSet.empty
- ;;
-end
-
-(* module of substitution *)
-
-module Substitution : sig
- type t
-
- val empty : t
-
- (* val mapping : fresh -> typ -> (fresh * typ) R.t *)
- val singleton : fresh -> typ -> t R.t
-
- (* val find : t -> fresh -> typ option *)
- val remove : t -> fresh -> t
- val apply : t -> typ -> typ
- val unify : typ -> typ -> t R.t
- val compose : t -> t -> t R.t
- val compose_all : t list -> t R.t
- (* val pp : formatter -> t -> unit *)
-end = struct
- open R
- open R.Syntax
-
- (* t in this module is map of key fresh to value typ. last arg specifies
- keys as int values (see fresh def) *)
- type t = (fresh, typ, Int.comparator_witness) Map.t
-
- (* empty map *)
- let empty = Map.empty (module Int)
- (* let pp fmt s = Map.iteri s ~f:(fun ~key ~data -> fprintf fmt "%d: %a" key pp_typ data) *)
-
- (* perform mapping of fresh var to typ with occurs check, if correct,
- output new pair *)
- let mapping k v = if Type.occurs_in k v then fail `Occurs_check else return (k, v)
-
- (* perform mapping, if correct, create map w 1 element as described in type t *)
- let singleton k v =
- let* k, v = mapping k v in
- return (Map.singleton (module Int) k v)
- ;;
-
- (* aliases for Map actions *)
- let find = Map.find
- let remove = Map.remove
-
- (* search for input in given map, if there is no match, output
- input type, else output found typ value associated w this key.
- Basically narrow given type to conditions given in substitution *)
- let apply map =
- let rec helper = function
- | Type_var b as typ ->
- (match find map b with
- | None -> typ
- | Some x -> x)
- | Arrow (fst, snd) -> Arrow (helper fst, helper snd)
- | Type_list t -> Type_list (helper t)
- | Type_tuple (fst, snd, rest) ->
- Type_tuple (helper fst, helper snd, List.map rest ~f:helper)
- | Primitive t -> Primitive t
- | TOption t -> TOption (helper t)
- | TActPat (name, t) -> TActPat (name, helper t)
- | Choice map -> Choice (Map.map map ~f:helper)
- in
- helper
- ;;
-
- (* check that two types are compatible. in third case put new pair of type_var
- and type into context (map) *)
- let rec unify fst snd =
- match fst, snd with
- | Primitive fst, Primitive snd when String.equal fst snd -> return empty
- | Type_var f, Type_var s when Int.equal f s -> return empty
- | Type_var b, t | t, Type_var b -> singleton b t
- | Arrow (f1, s1), Arrow (f2, s2) ->
- let* subst1 = unify f1 f2 in
- let* subst2 = unify s1 s2 in
- compose subst1 subst2
- | Type_list t1, Type_list t2 -> unify t1 t2
- | TOption t1, TOption t2 -> unify t1 t2
- | Type_tuple (t1_1, t1_2, t1_rest), Type_tuple (t2_1, t2_2, t2_rest)
- when List.length t1_rest = List.length t2_rest ->
- let type_pairs = List.zip_exn (t1_1 :: t1_2 :: t1_rest) (t2_1 :: t2_2 :: t2_rest) in
- let* substitutions =
- List.fold type_pairs ~init:(return []) ~f:(fun acc (t1, t2) ->
- let* acc = acc in
- let* subst = unify t1 t2 in
- return (subst :: acc))
- in
- let substitution_result = compose_all substitutions in
- substitution_result
- | TActPat (name1, _), TActPat (name2, _) when not (phys_equal name1 name2) ->
- return empty
- | TActPat (name1, t1), TActPat (name2, t2) when not (phys_equal name1 name2) ->
- unify t1 t2
- | Choice map, TActPat (name, t) | TActPat (name, t), Choice map ->
- unify (Choice map) (Choice (Map.singleton (module String) name t))
- | Choice map1, Choice map2 ->
- Map.fold map1 ~init:(return empty) ~f:(fun ~key ~data subst ->
- let* subst = subst in
- let* new_subst =
- match Map.find map2 key with
- | Some t -> unify data t
- | None -> return empty
- in
- compose subst new_subst)
- | _ -> fail (`Unification_failed (fst, snd))
-
- (* if value associated w this key exists in map, try to unify them, otherwise
- get old substitution, form new singleton, update map so in contains new info *)
- and extend key value map =
- match find map key with
- | Some value2 ->
- let* map2 = unify value value2 in
- compose map map2
- | None ->
- let value = apply map value in
- let* map2 = singleton key value in
- RMap.fold map ~init:(return map2) ~f:(fun key value acc ->
- let value = apply map2 value in
- let* key, value = mapping key value in
- return (Map.update acc key ~f:(fun _ -> value)))
-
- (* compose two maps together *)
- and compose map1 map2 = RMap.fold map2 ~init:(return map1) ~f:extend
-
- (* compose list of maps together *)
- and compose_all maps = RList.fold_left maps ~init:(return empty) ~f:compose
-end
-
-(* module for scheme treatment *)
-module Scheme : sig
- type t = scheme
-
- (* val occurs_in : fresh -> t -> bool *)
- val apply : Substitution.t -> t -> t
- val free_vars : t -> binder_set
-
- (* val pp : formatter -> t -> unit *)
-end = struct
- type t = scheme
-
- (* take all vars that are not bound in typ *)
- let free_vars = function
- | Scheme (vars, t) -> VarSet.diff (Type.free_vars t) vars
- ;;
-
- (* take substitution and scheme, remove its free vars from substitution,
- form new scheme according to substitution (apply it to typ) *)
- let apply subst (Scheme (vars, t)) =
- let subst2 = VarSet.fold (fun key s -> Substitution.remove s key) vars subst in
- Scheme (vars, Substitution.apply subst2 t)
- ;;
-
- (* let pp = pp_scheme *)
-end
-
-module TypeEnv : sig
- type t
-
- val free_vars : t -> VarSet.t
- val extend : t -> string -> scheme -> t
- val extend_many : t -> (string * scheme) list -> t
- val apply : Substitution.t -> t -> t
- val default : t
- val find : t -> string -> scheme option
- val find_exn : t -> string -> scheme
- val find_typ_exn : t -> string -> typ
- val find_typ : t -> string -> typ option
- val remove : t -> string -> t
- val remove_many : t -> string list -> t
- val iteri : t -> f:(name:string -> typ:typ -> unit) -> unit
- (* val pp : formatter -> t -> unit *)
-end = struct
- open Base
-
- (* environment (context?) -- pairs of names and their types list *)
- type t = (string, scheme, String.comparator_witness) Map.t
-
- (* if pair (key, some old value) exists in map env, then replace old value
- with new, else add pair (key, value) into map *)
- let extend env key value = Map.update env key ~f:(fun _ -> value)
-
- let extend_many env list =
- List.fold list ~init:env ~f:(fun env (k, v) -> extend env k v)
- ;;
-
- let remove = Map.remove
- let remove_many t keys = List.fold ~init:t keys ~f:remove
-
- let default =
- Map.set
- (Map.empty (module String))
- ~key:"print_int"
- ~data:(Scheme (VarSet.empty, Arrow (int_typ, unit_typ)))
- ;;
-
- (* apply given substitution to all elements of environment *)
- let apply subst env = Map.map env ~f:(Scheme.apply subst)
- let find = Map.find
- let find_exn = Map.find_exn
-
- let find_typ env key =
- match find env key with
- | Some (Scheme (_, typ)) -> Some typ
- | None -> None
- ;;
-
- let find_typ_exn env key =
- match find_exn env key with
- | Scheme (_, typ) -> typ
- ;;
-
- let iteri env ~f =
- Map.iteri env ~f:(fun ~key ~data ->
- (function
- | Scheme (_, typ) -> f ~name:key ~typ)
- data)
- ;;
-
- (* collect all free vars from environment *)
- let free_vars : t -> VarSet.t =
- Map.fold ~init:VarSet.empty ~f:(fun ~key:_ ~data:s acc ->
- VarSet.union acc (Scheme.free_vars s))
- ;;
-end
-
-include R
-open R.Syntax
-module ExtractIdents = ExtractIdents.Make (R)
-open ExtractIdents
-
-let unify = Substitution.unify
-let make_fresh_var = fresh >>| fun n -> Type_var n
-
-(* replace all type vars with fresh ones *)
-let instantiate : scheme -> typ R.t =
- fun (Scheme (vars, t)) ->
- VarSet.fold
- (fun name typ ->
- let* typ = typ in
- let* fr_var = make_fresh_var in
- let* subst = Substitution.singleton name fr_var in
- return (Substitution.apply subst typ))
- vars
- (return t)
-;;
-
-(* take free vars of type t and environment, put difference between them
- in S constructor so all vars are context independent *)
-let generalize env typ =
- let free = VarSet.diff (Type.free_vars typ) (TypeEnv.free_vars env) in
- Scheme (free, typ)
-;;
-
-let rec find_args_type = function
- | Arrow (a, Arrow (b, rest)) -> Arrow (a, find_args_type (Arrow (b, rest)))
- | Arrow (a, _) -> a
- | t -> t
-;;
-
-let rec decompose_arrow typ =
- match typ with
- | Arrow (fst, snd) ->
- let args, final_return_type = decompose_arrow snd in
- fst :: args, final_return_type
- | _ -> [], typ
-;;
-
-let find_return_type typ =
- let _, return_t = decompose_arrow typ in
- return_t
-;;
-
-let infer_lt = function
- | Int_lt _ -> return int_typ
- | Bool_lt _ -> return bool_typ
- | String_lt _ -> return string_typ
- | Unit_lt -> return unit_typ
-;;
-
-let rec infer_pattern env ~shadow = function
- | Wild ->
- let* fresh_var = make_fresh_var in
- return (env, fresh_var)
- | PConst lt ->
- let* t = infer_lt lt in
- return (env, t)
- | PVar (Ident name) ->
- let* fresh = make_fresh_var in
- let scheme = Scheme (VarSet.empty, fresh) in
- let env, typ =
- if shadow
- then TypeEnv.extend env name scheme, fresh
- else (
- let typ = TypeEnv.find_typ env name in
- env, Option.value typ ~default:fresh)
- in
- return (env, typ)
- | POption None ->
- let* fresh_var = make_fresh_var in
- return (env, TOption fresh_var)
- | POption (Some p) ->
- let* env, typ = infer_pattern env ~shadow p in
- return (env, TOption typ)
- | PList [] ->
- let* fresh_var = make_fresh_var in
- return (env, Type_list fresh_var)
- | PList (hd :: tl) ->
- let* env, typ1 = infer_pattern env ~shadow hd in
- let* env, typ2 = infer_pattern env ~shadow (PList tl) in
- let* subst = Substitution.unify typ2 (Type_list typ1) in
- let env = TypeEnv.apply subst env in
- return (env, Substitution.apply subst typ2)
- | PCons (hd, tl) ->
- let* env, typ1 = infer_pattern env ~shadow hd in
- let* env, typ2 = infer_pattern env ~shadow tl in
- let* subst = Substitution.unify typ2 (Type_list typ1) in
- let env = TypeEnv.apply subst env in
- return (env, Substitution.apply subst typ2)
- | PTuple (fst, snd, rest) ->
- let* env, typ1 = infer_pattern env ~shadow fst in
- let* env, typ2 = infer_pattern env ~shadow snd in
- let* env, typs_rest =
- List.fold_right
- rest
- ~f:(fun p acc ->
- let* env, types = acc in
- let* env, typ = infer_pattern env ~shadow p in
- return (env, typ :: types))
- ~init:(return (env, []))
- in
- return (env, Type_tuple (typ1, typ2, typs_rest))
- | PConstraint (p, t) ->
- let* env, inferred_typ = infer_pattern env ~shadow p in
- let* subst = unify t inferred_typ in
- return (TypeEnv.apply subst env, Substitution.apply subst t)
- | PActive (Ident name, p) ->
- let* env, typ = infer_pattern env ~shadow p in
- let pat_typ =
- match TypeEnv.find_exn env name with
- | Scheme (_, typ) -> typ
- in
- let pat_return_typ = find_return_type pat_typ in
- let* subst = unify typ pat_return_typ in
- return (TypeEnv.apply subst env, Substitution.apply subst pat_typ)
-;;
-
-let infer_patterns env ~shadow patterns =
- List.fold_right
- patterns
- ~init:(return (env, []))
- ~f:(fun pat acc ->
- let* old_env, typs = acc in
- let* new_env, typ = infer_pattern old_env ~shadow pat in
- return (new_env, typ :: typs))
-;;
-
-let infer_match_pattern env ~shadow pattern match_type =
- let* env, pat_typ = infer_pattern env ~shadow pattern in
- let pat_input_typ = find_args_type pat_typ in
- let* subst = unify pat_input_typ match_type in
- let env = TypeEnv.apply subst env in
- let* pat_names = extract_names_from_pattern pattern >>| elements in
- let generalized_schemes =
- List.map pat_names ~f:(fun name ->
- let typ = TypeEnv.find_typ_exn env name in
- let env = TypeEnv.remove env name in
- let generalized_typ = generalize env typ in
- name, generalized_typ)
- in
- let env = TypeEnv.extend_many env generalized_schemes in
- return (env, subst)
-;;
-
-let extend_env_with_bind_names env let_binds =
- let bind_names = extract_bind_patterns_from_let_binds let_binds in
- let* env, _ = infer_patterns env ~shadow:true bind_names in
- return env
-;;
-
-let check_let_bind_correctness is_rec let_bind =
- match let_bind, is_rec with
- | Let_bind (PVar _, _, _), _ -> return let_bind
- | Let_bind _, Rec -> fail `Not_allowed_left_hand_side_let_rec
- | Let_bind (_, args, _), _ when List.length args <> 0 ->
- fail `Args_after_not_variable_let
- | _ -> return let_bind
-;;
-
-let unify_act_pat = function
- | TActPat (n1, t1), TActPat (n2, t2) ->
- Choice (choice_set_many (Map.empty (module String)) [ n1, t1; n2, t2 ])
- | TActPat (name, t), Choice map | Choice map, TActPat (name, t) ->
- Choice (Map.set map ~key:name ~data:t)
- | Choice map1, Choice map2 ->
- Choice (Map.fold ~init:map1 map2 ~f:(fun ~key ~data map1 -> Map.set map1 ~key ~data))
- | fst, _ -> fst
-;;
-
-let rec infer_expr env = function
- | Const lt ->
- let* t = infer_lt lt in
- return (Substitution.empty, t)
- | Variable (Ident varname) ->
- (match TypeEnv.find env varname with
- | Some s ->
- let* t = instantiate s in
- return (Substitution.empty, t)
- | None -> fail (`Undef_var varname))
- | Unary_expr (op, e) ->
- let* op_typ =
- match op with
- | Unary_minus -> return int_typ
- | Unary_not -> return bool_typ
- in
- let* e_subst, e_typ = infer_expr env e in
- let* subst = unify op_typ (Substitution.apply e_subst e_typ) in
- let* subst_result = Substitution.compose_all [ e_subst; subst ] in
- return (subst_result, Substitution.apply subst e_typ)
- | Bin_expr (op, e1, e2) ->
- let* subst1, typ1 = infer_expr env e1 in
- let* subst2, typ2 = infer_expr (TypeEnv.apply subst1 env) e2 in
- let* e1typ, e2typ, etyp =
- match op with
- | Logical_and | Logical_or -> return (bool_typ, bool_typ, bool_typ)
- | Binary_add
- | Binary_subtract
- | Binary_multiply
- | Binary_divide
- | Binary_and_bitwise
- | Binary_or_bitwise
- | Binary_xor_bitwise -> return (int_typ, int_typ, int_typ)
- | Binary_greater | Binary_greater_or_equal | Binary_less | Binary_less_or_equal ->
- return (int_typ, int_typ, bool_typ)
- | Binary_equal | Binary_unequal ->
- let* fresh_var = make_fresh_var in
- return (fresh_var, fresh_var, bool_typ)
- | Binary_cons ->
- let* fresh_var = make_fresh_var in
- return (fresh_var, Type_list fresh_var, Type_list fresh_var)
- in
- let* subst3 = Substitution.unify (Substitution.apply subst2 typ1) e1typ in
- let* subst4 = Substitution.unify (Substitution.apply subst3 typ2) e2typ in
- let* subst_res = Substitution.compose_all [ subst1; subst2; subst3; subst4 ] in
- return (subst_res, Substitution.apply subst_res etyp)
- | Option None ->
- let* fresh_typ = make_fresh_var in
- return (Substitution.empty, TOption fresh_typ)
- | Option (Some e) ->
- let* subst, typ = infer_expr env e in
- return (subst, TOption typ)
- | Tuple (fst, snd, rest) ->
- let* subst1, typ1 = infer_expr env fst in
- let* subst2, typ2 = infer_expr env snd in
- let* subst_rest, typs_rest =
- List.fold_right
- rest
- ~f:(fun e acc ->
- let* subst_acc, typs = acc in
- let* subst, typ = infer_expr env e in
- let* subst_acc = Substitution.compose subst_acc subst in
- return (subst_acc, typ :: typs))
- ~init:(return (Substitution.empty, []))
- in
- let* subst_result = Substitution.compose_all [ subst1; subst2; subst_rest ] in
- return (subst_result, Type_tuple (typ1, typ2, typs_rest))
- | List [] ->
- let* fresh_var = make_fresh_var in
- return (Substitution.empty, Type_list fresh_var)
- | List (hd :: tl) ->
- let* subst1, typ1 = infer_expr env hd in
- let typ1 = Substitution.apply subst1 typ1 in
- let* subst_unify, typ_unified =
- List.fold
- tl
- ~f:(fun acc e ->
- let* subst_acc, typ_acc = acc in
- let* subst, typ = infer_expr env e in
- let* subst_unify = unify typ_acc typ in
- let typ_acc = Substitution.apply subst_unify typ_acc in
- let* subst_acc = Substitution.compose_all [ subst; subst_acc; subst_unify ] in
- return (subst_acc, typ_acc))
- ~init:(return (subst1, typ1))
- in
- return (subst_unify, Type_list typ_unified)
- | If_then_else (c, th, Some el) ->
- let* subst1, typ1 = infer_expr env c in
- let* subst2, typ2 = infer_expr (TypeEnv.apply subst1 env) th in
- let* subst3, typ3 = infer_expr (TypeEnv.apply subst2 env) el in
- let* subst4 = unify typ1 bool_typ in
- let* subst5 = unify typ2 typ3 in
- let* subst_result =
- Substitution.compose_all [ subst1; subst2; subst3; subst4; subst5 ]
- in
- return (subst_result, Substitution.apply subst5 (unify_act_pat (typ2, typ3)))
- | If_then_else (c, th, None) ->
- let* subst1, typ1 = infer_expr env c in
- let* subst2, typ2 = infer_expr (TypeEnv.apply subst1 env) th in
- let* subst3 = unify typ1 bool_typ in
- let* subst_result = Substitution.compose_all [ subst1; subst2; subst3 ] in
- return (subst_result, Substitution.apply subst2 typ2)
- | Apply (f, arg) ->
- let* subst1, typ1 = infer_expr env f in
- let* subst2, typ2 = infer_expr (TypeEnv.apply subst1 env) arg in
- let typ1 = Substitution.apply subst2 typ1 in
- let* fresh_var = make_fresh_var in
- let* subst3 = unify typ1 (Arrow (typ2, fresh_var)) in
- let* subst_result = Substitution.compose_all [ subst1; subst2; subst3 ] in
- return (subst_result, Substitution.apply subst3 fresh_var)
- | Lambda (arg, args, e) ->
- let* env, arg_types = infer_patterns env ~shadow:true (arg :: args) in
- let* subst, e_type = infer_expr env e in
- return (subst, Substitution.apply subst (arrow_of_types arg_types e_type))
- | LetIn (Rec, let_bind, let_binds, e) ->
- let let_binds = let_bind :: let_binds in
- let* env = extend_env_with_bind_names env let_binds in
- let* env, subst1 = extend_env_with_let_binds env Rec let_binds in
- let* subst2, typ = infer_expr env e in
- let* subst_final = Substitution.compose subst1 subst2 in
- return (subst_final, typ)
- | LetIn (Nonrec, let_bind, let_binds, e) ->
- let* env, subst1 = extend_env_with_let_binds env Nonrec (let_bind :: let_binds) in
- let* subst2, typ = infer_expr env e in
- let* subst_final = Substitution.compose subst1 subst2 in
- return (subst_final, typ)
- | Function ((p1, e1), rest) ->
- let* match_t = make_fresh_var in
- let* return_t = make_fresh_var in
- infer_matching_expr
- env
- ((p1, e1) :: rest)
- Substitution.empty
- match_t
- return_t
- ~with_arg:true
- | Match (e, (p1, e1), rest) ->
- let* subst_init, match_t = infer_expr env e in
- let env = TypeEnv.apply subst_init env in
- let* return_t = make_fresh_var in
- infer_matching_expr env ((p1, e1) :: rest) subst_init match_t return_t ~with_arg:false
- | EConstraint (e, t) ->
- let* subst1, e_type = infer_expr env e in
- let* subst2 = unify e_type (Substitution.apply subst1 t) in
- let* subst_result = Substitution.compose subst1 subst2 in
- return (subst_result, Substitution.apply subst2 e_type)
- | ActPatConstructor (Ident name, body) ->
- let* subst1, body_type = infer_expr env body in
- let (Scheme (_, existing_type)) = TypeEnv.find_exn env name in
- let* subst = unify existing_type body_type in
- let* subst_final = Substitution.compose subst1 subst in
- return (subst_final, TActPat (name, body_type))
-
-and infer_matching_expr env cases subst_init match_t return_t ~with_arg =
- let* subst, return_t =
- List.fold
- cases
- ~init:(return (subst_init, return_t))
- ~f:(fun acc (pat, expr) ->
- let* subst1, return_t = acc in
- let* env, subst2 =
- if with_arg
- then
- let* env, pat = infer_pattern env ~shadow:true pat in
- let* subst2 = unify match_t pat in
- return (env, subst2)
- else infer_match_pattern env ~shadow:true pat match_t
- in
- let* subst12 = Substitution.compose subst1 subst2 in
- let env = TypeEnv.apply subst12 env in
- let* subst3, expr_typ = infer_expr env expr in
- let* subst4 = unify return_t expr_typ in
- let return_type = unify_act_pat (return_t, expr_typ) in
- let* subst = Substitution.compose_all [ subst12; subst3; subst4 ] in
- return (subst, Substitution.apply subst return_type))
- in
- let final_typ =
- if with_arg then Arrow (Substitution.apply subst match_t, return_t) else return_t
- in
- return (subst, final_typ)
-
-and extend_env_with_let_binds env is_rec let_binds =
- List.fold
- let_binds
- ~init:(return (env, Substitution.empty))
- ~f:(fun acc let_bind ->
- let* env, subst_acc = acc in
- let* subst, names_schemes_list = infer_let_bind env is_rec let_bind in
- let env = TypeEnv.extend_many env names_schemes_list in
- let env = TypeEnv.apply subst env in
- let* subst_acc = Substitution.compose subst_acc subst in
- return (env, subst_acc))
-
-and infer_let_bind env is_rec let_bind =
- let* (Let_bind (name, args, e)) = check_let_bind_correctness is_rec let_bind in
- let* env, args_types = infer_patterns env ~shadow:true args in
- let* subst1, rvalue_type = infer_expr env e in
- let bind_type = Substitution.apply subst1 (arrow_of_types args_types rvalue_type) in
- (* If let_bind is recursive, then name was already in environment *)
- let* env, name_type =
- match is_rec with
- | Nonrec -> infer_pattern env ~shadow:true name
- | Rec -> infer_pattern env ~shadow:false name
- in
- let* subst2 = unify (Substitution.apply subst1 name_type) bind_type in
- let* subst = Substitution.compose subst1 subst2 in
- let env = TypeEnv.apply subst env in
- let* names = extract_names_from_pattern name >>| elements in
- let* arg_names = extract_names_from_patterns args >>| elements in
- let names_types = List.map names ~f:(fun n -> n, TypeEnv.find_typ_exn env n) in
- let env = TypeEnv.remove_many env (List.concat [ names; arg_names ]) in
- let names_schemes_list =
- List.map names_types ~f:(fun (name, name_type) -> name, generalize env name_type)
- in
- return (subst, names_schemes_list)
-;;
-
-let add_ident env ident ~shadow =
- let* fresh = make_fresh_var in
- let scheme = Scheme (VarSet.empty, fresh) in
- let env, typ =
- if shadow
- then TypeEnv.extend env ident scheme, fresh
- else (
- let typ = TypeEnv.find_typ env ident in
- env, Option.value typ ~default:fresh)
- in
- return (env, typ)
-;;
-
-let reconstruct_arrow args return_type =
- List.fold_right args ~init:return_type ~f:(fun arg acc -> Arrow (arg, acc))
-;;
-
-let update_pat_types_with_expr_type arg_types names_with_types_list =
- List.map names_with_types_list ~f:(fun (name, return_type) ->
- let new_type = reconstruct_arrow arg_types return_type in
- name, new_type)
-;;
-
-let infer_statement env = function
- | Let (rec_flag, let_bind, let_binds) ->
- let let_binds = let_bind :: let_binds in
- let* env =
- match rec_flag with
- | Rec -> extend_env_with_bind_names env let_binds
- | Nonrec -> return env
- in
- let* env, _ = extend_env_with_let_binds env rec_flag let_binds in
- let* bind_names = extract_bind_names_from_let_binds let_binds >>| elements in
- let bind_names_with_types =
- List.fold
- bind_names
- ~init:(Map.empty (module String))
- ~f:(fun map name ->
- match TypeEnv.find_exn env name with
- | Scheme (_, typ) -> Map.set map ~key:name ~data:typ)
- in
- return (env, bind_names_with_types)
- | ActPat (fst, rest, args, body) ->
- (* input all idents and infer args, expr, find type of act pat definition *)
- let* env, _ =
- List.fold_right
- (fst :: rest)
- ~init:(return (env, []))
- ~f:(fun (Ident name) acc ->
- let* old_env, typs = acc in
- let* new_env, typ = add_ident old_env ~shadow:true name in
- return (new_env, typ :: typs))
- in
- let* env, args_types = infer_patterns env ~shadow:true args in
- let* subst1, expr_type = infer_expr env body in
- let env = TypeEnv.apply subst1 env in
- let apat_type = Substitution.apply subst1 (arrow_of_types args_types expr_type) in
- (* form (name, type) pairs for variants and change types so they content args *)
- let variant_names = List.map (fst :: rest) ~f:(function Ident str -> str) in
- let variants_with_types_list =
- List.map variant_names ~f:(fun name ->
- match TypeEnv.find_exn env name with
- | Scheme (_, typ) -> name, typ)
- in
- let arg_types, return_typ = decompose_arrow apat_type in
- (* check that all variants are determined in output *)
- let* _ =
- match return_typ with
- | Choice map
- when Map.length map = List.length variant_names
- && List.exists variant_names ~f:(fun name -> Map.mem map name) -> return ()
- | _ -> fail `Active_pattern_are_not_determined_by_input
- in
- let updated_variants_w_types_list =
- update_pat_types_with_expr_type arg_types variants_with_types_list
- in
- let env =
- List.fold updated_variants_w_types_list ~init:env ~f:(fun env (name, new_typ) ->
- let scheme = generalize env new_typ in
- TypeEnv.extend env name scheme)
- in
- (* delete args from context *)
- let* arg_names = extract_names_from_patterns args >>| elements in
- let env = TypeEnv.remove_many env arg_names in
- (* form result map for printing *)
- let result_name = "|" ^ String.concat ~sep:"|" variant_names ^ "|" in
- let new_res_map = Map.empty (module String) in
- let new_res_map = Map.set new_res_map ~key:result_name ~data:apat_type in
- let names_schemes_list =
- List.map updated_variants_w_types_list ~f:(fun (name, name_type) ->
- name, generalize env name_type)
- in
- let env = TypeEnv.extend_many env names_schemes_list in
- return (env, new_res_map)
-;;
-
-let infer_construction env = function
- | Expr exp ->
- let* _, typ = infer_expr env exp in
- return (env, Map.singleton (module String) "-" typ)
- | Statement s ->
- let* env, names_and_types = infer_statement env s in
- return (env, names_and_types)
-;;
-
-let infer c env state = run (infer_construction env c) state
diff --git a/FSharpActivePatterns/lib/inferencer.mli b/FSharpActivePatterns/lib/inferencer.mli
deleted file mode 100644
index be6f83f9d..000000000
--- a/FSharpActivePatterns/lib/inferencer.mli
+++ /dev/null
@@ -1,38 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-open TypedTree
-open Format
-
-module TypeEnv : sig
- type t
-
- val default : t
- val extend : t -> string -> scheme -> t
- val remove : t -> string -> t
- val iteri : t -> f:(name:string -> typ:typ -> unit) -> unit
-end
-
-type error =
- [ `Occurs_check
- | `Undef_var of string
- | `Unification_failed of typ * typ
- | `Not_allowed_right_hand_side_let_rec
- | `Not_allowed_left_hand_side_let_rec
- | `Args_after_not_variable_let
- | `Bound_several_times
- | `Active_pattern_are_not_determined_by_input
- ]
-
-val pp_error : formatter -> error -> unit
-
-val infer
- : construction
- -> TypeEnv.t
- -> int
- -> int
- * ( TypeEnv.t * (string, typ, Base.String.comparator_witness) Base.Map.t
- , error )
- result
diff --git a/FSharpActivePatterns/lib/interpreter.ml b/FSharpActivePatterns/lib/interpreter.ml
deleted file mode 100644
index 3b54fd9c9..000000000
--- a/FSharpActivePatterns/lib/interpreter.ml
+++ /dev/null
@@ -1,506 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-open Stdlib
-
-module EvalError = struct
- type error =
- [ `Division_by_zero
- | `Match_failure
- | `Type_mismatch
- | `Unbound_variable of string
- | `Args_after_not_variable_let
- | `Bound_several_times
- ]
-
- let pp_error fmt =
- let open Format in
- function
- | `Division_by_zero -> fprintf fmt "Division by zero\n"
- | `Match_failure -> fprintf fmt "Match failure\n"
- | `Type_mismatch ->
- fprintf fmt "Not possible scenario: type mismatch after type check\n"
- | `Unbound_variable name -> fprintf fmt "Unbound variable : %s\n" name
- | `Args_after_not_variable_let -> fprintf fmt "Args are allowed only after variable\n"
- | `Bound_several_times -> fprintf fmt "Variable is bound several times\n"
- ;;
-
- let bound_error : error = `Bound_several_times
-end
-
-module R : sig
- type 'a t
- type error = EvalError.error
-
- val pp_error : Format.formatter -> error -> unit
- val bound_error : error
- val return : 'a -> 'a t
- val fail : error -> 'a t
-
- include Base.Monad.Infix with type 'a t := 'a t
-
- module Syntax : sig
- val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t
- end
-
- val ( <|> ) : 'a t -> 'a t -> 'a t
- val run : 'a t -> ('a, error) Result.t
-end = struct
- open Base
- include Result
- include EvalError
-
- type 'a t = ('a, error) Result.t
-
- let ( <|> ) x y =
- match x with
- | Ok x -> Ok x
- | Error _ -> y
- ;;
-
- module Syntax = struct
- let ( let* ) = ( >>= )
- end
-
- let run c = c
-end
-
-module ValueEnv : sig
- type t
-
- type value =
- | VUnit
- | VInt of int
- | VString of string
- | VBool of bool
- | VTuple of value * value * value list
- | VList of value list
- | VFun of pattern * pattern list * expr * t
- | VFunction of case * case list * t
- | VOption of value option
- | VActPatCase of string * value
- | Print_int
-
- val find_err : t -> string -> value R.t
- val extend : t -> string -> value -> t
- val update_exn : t -> string -> f:(value -> value) -> t
- val find : t -> string -> value option
- val find_exn : t -> string -> value
- val pp_value : Format.formatter -> value -> unit
-
- (* val pp_env : Format.formatter -> t -> unit *)
- val set_many : t -> t -> t
- val default : t
-end = struct
- open Base
-
- (* overwrite values of map1 with values of map2 *)
- let set_many map1 map2 =
- Map.fold ~init:map1 ~f:(fun ~key ~data map1 -> Map.set map1 ~key ~data) map2
- ;;
-
- type value =
- | VUnit
- | VInt of int
- | VString of string
- | VBool of bool
- | VTuple of value * value * value list
- | VList of value list
- | VFun of pattern * pattern list * expr * t
- | VFunction of case * case list * t
- | VOption of value option
- | VActPatCase of string * value
- | Print_int
-
- and t = (string, value, Base.String.comparator_witness) Base.Map.t
-
- let rec pp_value fmt =
- let open Stdlib.Format in
- function
- | VUnit -> fprintf fmt "() "
- | VInt i -> fprintf fmt "%d " i
- | VString s -> fprintf fmt "%S " s
- | VBool b -> fprintf fmt "%a " pp_print_bool b
- | VTuple (fst, snd, rest) ->
- fprintf
- fmt
- "(%a) "
- (pp_print_list pp_value ~pp_sep:(fun fmt () -> fprintf fmt ", "))
- (fst :: snd :: rest)
- | VList l ->
- fprintf
- fmt
- "[%a] "
- (pp_print_list pp_value ~pp_sep:(fun fmt () -> fprintf fmt "; "))
- l
- | VFun _ | Print_int -> fprintf fmt " "
- | VFunction _ -> fprintf fmt " "
- | VOption (Some v) -> fprintf fmt "Some %a " pp_value v
- | VOption None -> fprintf fmt "None "
- | VActPatCase (name, v) -> fprintf fmt "%s (%a)" name pp_value v
- ;;
-
- let extend mp key data = Map.set mp ~key ~data
-
- let update_exn env k ~f =
- let v = Map.find_exn env k in
- extend env k (f v)
- ;;
-
- let find_err env name =
- let open R in
- match Map.find env name with
- | Some v -> return v
- | None ->
- let x = fail (`Unbound_variable name) in
- x
- ;;
-
- let default = Map.set (Map.empty (module String)) ~key:"print_int" ~data:Print_int
- let find = Map.find
- let find_exn = Map.find_exn
-
- (* let pp_env fmt t =
- Map.iteri t ~f:(fun ~key ~data ->
- Stdlib.Format.fprintf fmt "%s : %a\n" key pp_value data)
- ;; *)
-end
-
-include R
-open R.Syntax
-open ValueEnv
-module ExtractIdents = ExtractIdents.Make (R)
-open ExtractIdents
-
-let check_act_pat_correctness env name =
- match ValueEnv.find env name with
- | Some _ -> return name
- | None -> fail (`Unbound_variable name)
-;;
-
-let rec eval_binequal =
- let eval_binequal_list l1 l2 =
- Base.List.fold2_exn
- ~init:(return (VBool true))
- ~f:(fun acc left right ->
- let* acc = acc in
- let* eq_res = eval_binequal (left, right) in
- match acc, eq_res with
- | VBool b1, VBool b2 -> return (VBool (b1 && b2))
- | _ -> fail `Type_mismatch)
- l1
- l2
- in
- function
- | VInt i1, VInt i2 -> return (VBool (i1 = i2))
- | VString s1, VString s2 -> return (VBool (s1 = s2))
- | VBool b1, VBool b2 -> return (VBool (b1 = b2))
- | VUnit, VUnit -> return (VBool true)
- | VList l1, VList l2 when List.length l1 = List.length l2 -> eval_binequal_list l1 l2
- | VTuple (fst1, snd1, rest1), VTuple (fst2, snd2, rest2)
- when List.length rest1 = List.length rest2 ->
- eval_binequal_list (fst1 :: snd1 :: rest1) (fst2 :: snd2 :: rest2)
- | _ -> fail `Type_mismatch
-;;
-
-let eval_binexpr op v1 v2 =
- match op, v1, v2 with
- | Binary_equal, v1, v2 -> eval_binequal (v1, v2)
- | Binary_unequal, v1, v2 ->
- let* b = eval_binequal (v1, v2) in
- (match b with
- | VBool b -> return (VBool (not b))
- | _ -> fail `Type_mismatch)
- | Binary_less, VInt v1, VInt v2 -> return (VBool (v1 < v2))
- | Binary_less_or_equal, VInt v1, VInt v2 -> return (VBool (v1 <= v2))
- | Binary_greater, VInt v1, VInt v2 -> return (VBool (v1 > v2))
- | Binary_greater_or_equal, VInt v1, VInt v2 -> return (VBool (v1 >= v2))
- | Binary_add, VInt v1, VInt v2 -> return (VInt (v1 + v2))
- | Binary_subtract, VInt v1, VInt v2 -> return (VInt (v1 - v2))
- | Binary_multiply, VInt v1, VInt v2 -> return (VInt (v1 * v2))
- | Binary_divide, VInt v1, VInt v2 -> return (VInt (v1 / v2))
- | Logical_or, VBool v1, VBool v2 -> return (VBool (v1 || v2))
- | Logical_and, VBool v1, VBool v2 -> return (VBool (v1 && v2))
- | Binary_or_bitwise, VInt v1, VInt v2 -> return (VInt (v1 lor v2))
- | Binary_xor_bitwise, VInt v1, VInt v2 -> return (VInt (v1 lxor v2))
- | Binary_and_bitwise, VInt v1, VInt v2 -> return (VInt (v1 land v2))
- | Binary_cons, v, VList vl -> return (VList (v :: vl))
- | _ -> fail `Type_mismatch
-;;
-
-let rec match_pattern env =
- let match_pattern_list env pl vl =
- Base.List.fold2_exn
- ~init:(return env)
- ~f:(fun acc pat value ->
- let* acc = acc in
- match_pattern acc (pat, value))
- pl
- vl
- in
- function
- | Wild, _ -> return env
- | PList pl, VList vl when List.length pl = List.length vl ->
- match_pattern_list env pl vl
- | PCons (hd, tl), VList (vhd :: vtl) ->
- match_pattern_list env [ hd; tl ] [ vhd; VList vtl ]
- | PTuple (pfst, psnd, prest), VTuple (vfst, vsnd, vrest) ->
- match_pattern_list env (pfst :: psnd :: prest) (vfst :: vsnd :: vrest)
- | PConst (Int_lt p), VInt v when p = v -> return env
- | PConst (Bool_lt p), VBool v when p = v -> return env
- | PConst (String_lt p), VString v when p = v -> return env
- | PConst Unit_lt, VUnit -> return env
- | PVar (Ident name), v -> return (ValueEnv.extend env name v)
- | POption (Some p), VOption (Some v) -> match_pattern env (p, v)
- | POption None, VOption None -> return env
- | PConstraint (p, _), v -> match_pattern env (p, v)
- | PActive (Ident name, p), v ->
- (* find func that contains variant in case *)
- let act_pat_def = ValueEnv.find env name in
- (match act_pat_def with
- | Some (VFun (arg, args, body, f_env)) ->
- (* match arg of func and match hat, if correct, eval func into value *)
- let* f_env = match_pattern f_env (arg, v) in
- let* value_after_applying =
- match args with
- | [] ->
- let env = ValueEnv.set_many env f_env in
- eval_expr env body
- | arg1 :: args -> return (VFun (arg1, args, body, f_env))
- in
- (* match pattern in case (p) and value *)
- (match value_after_applying with
- | VActPatCase (name_evaluated, value) when name_evaluated = name ->
- match_pattern env (p, value)
- | _ -> fail `Type_mismatch)
- | _ -> fail `Type_mismatch)
- | _ -> fail `Match_failure
-
-and eval_expr env = function
- | Const c ->
- (match c with
- | Unit_lt -> return VUnit
- | Int_lt i -> return (VInt i)
- | String_lt s -> return (VString s)
- | Bool_lt b -> return (VBool b))
- | Tuple (fst, snd, rest) ->
- let* fst_value = eval_expr env fst in
- let* snd_value = eval_expr env snd in
- let* rest_values = eval_expr_fold env rest in
- return (VTuple (fst_value, snd_value, rest_values))
- | List l ->
- let* l_values = eval_expr_fold env l in
- return (VList l_values)
- | Variable (Ident n) -> find_err env n
- | Unary_expr (op, e) ->
- let* v = eval_expr env e in
- (match op, v with
- | Unary_minus, VInt i -> return (VInt (-i))
- | Unary_not, VBool b -> return (VBool (not b))
- | _ -> fail `Type_mismatch)
- | Bin_expr (op, e1, e2) ->
- let* v1 = eval_expr env e1 in
- let* v2 = eval_expr env e2 in
- eval_binexpr op v1 v2
- | If_then_else (c, t, e) ->
- let* c_value = eval_expr env c in
- (match c_value with
- | VBool true -> eval_expr env t
- | VBool false ->
- (match e with
- | None -> return VUnit
- | Some e -> eval_expr env e)
- | _ -> fail `Type_mismatch)
- | Lambda (arg, args, body) -> return (VFun (arg, args, body, env))
- | Apply (f, applying_arg) ->
- let* f_value = eval_expr env f in
- let* applying_arg_value = eval_expr env applying_arg in
- (match f_value, applying_arg_value with
- | VFun (arg, args, body, f_env), _ ->
- let* f_env = match_pattern f_env (arg, applying_arg_value) in
- (match args with
- | [] ->
- let env = ValueEnv.set_many env f_env in
- let* v = eval_expr env body in
- return v
- | arg1 :: args -> return (VFun (arg1, args, body, f_env)))
- | VFunction (c, cl, f_env), _ -> eval_match f_env applying_arg_value (c :: cl)
- | Print_int, VInt i ->
- Format.(fprintf std_formatter "%d\n" i);
- return VUnit
- | _ -> fail `Type_mismatch)
- | Match (e, c, cl) ->
- let* v = eval_expr env e in
- eval_match env v (c :: cl)
- | Function (c, cl) -> return (VFunction (c, cl, env))
- | LetIn (rec_flag, let_bind, let_binds, e) ->
- let* env = extend_env_with_let_binds env rec_flag (let_bind :: let_binds) in
- let* value = eval_expr env e in
- return value
- | Option None -> return (VOption None)
- | Option (Some e) ->
- let* value = eval_expr env e in
- return (VOption (Some value))
- | EConstraint (e, _) -> eval_expr env e
- | ActPatConstructor (Ident name, e) ->
- let* value = eval_expr env e in
- let* name = check_act_pat_correctness env name in
- return (VActPatCase (name, value))
-
-and eval_expr_fold env l =
- Base.List.fold_right
- ~init:(return [])
- ~f:(fun e acc ->
- let* acc = acc in
- let* e_value = eval_expr env e in
- return (e_value :: acc))
- l
-
-and eval_match env v = function
- | [] -> fail `Match_failure
- | (pat, expr) :: tl ->
- (let* ext_env = match_pattern env (pat, v) in
- eval_expr ext_env expr)
- <|> eval_match env v tl
-
-(* Add name with it's value of let_bind to value environment.
- If name is variable, then returns new env with Some name, else returns new env with None*)
-and extend_env_with_let_bind env = function
- | Let_bind (name, args, body) ->
- (match name, args with
- | PVar (Ident ident), arg1 :: args ->
- let value = VFun (arg1, args, body, env) in
- let* env = match_pattern env (name, value) in
- return (Some ident, env)
- | _, _ :: _ -> fail `Args_after_not_variable_let
- | PVar (Ident ident), [] ->
- let* value = eval_expr env body in
- let* env = match_pattern env (name, value) in
- return (Some ident, env)
- | _, [] ->
- (* If name is not variable, then let is not recursive (checked in type check)*)
- let* value = eval_expr env body in
- let* env = match_pattern env (name, value) in
- return (None, env))
-
-and extend_env_with_let_binds env rec_flag let_binds =
- let* names, env =
- Base.List.fold
- ~init:(return ([], env))
- ~f:(fun acc let_bind ->
- let* names, env = acc in
- let* name, env = extend_env_with_let_bind env let_bind in
- match name with
- | Some name -> return (name :: names, env)
- | None -> return (names, env))
- let_binds
- in
- let env =
- match rec_flag with
- | Rec ->
- Base.List.fold
- ~init:env
- ~f:(fun env name ->
- ValueEnv.update_exn env name ~f:(function
- | VFun (arg, args, body, _) -> VFun (arg, args, body, env)
- | other -> other))
- names
- | Nonrec -> env
- in
- return env
-;;
-
-let eval_statement env =
- let open Base in
- function
- | Let (rec_flag, let_bind, let_binds) ->
- let let_binds = let_bind :: let_binds in
- let* env = extend_env_with_let_binds env rec_flag let_binds in
- let* bind_names = extract_bind_names_from_let_binds let_binds >>| elements in
- let bind_names_with_values =
- List.fold
- bind_names
- ~init:(Map.empty (module String))
- ~f:(fun map name ->
- let value = ValueEnv.find_exn env name in
- Map.set map ~key:name ~data:value)
- in
- return (env, bind_names_with_values)
- | ActPat (fst, rest, args, expr) ->
- let name_list = fst :: rest in
- let ident_name_list = List.map name_list ~f:(fun (Ident s) -> s) in
- let* value =
- match args with
- | arg :: args -> return (VFun (arg, args, expr, env))
- | [] -> eval_expr env expr
- in
- let pat_name = "|" ^ String.concat ~sep:"|" ident_name_list ^ "|" in
- let* env = match_pattern env (PVar (Ident pat_name), value) in
- let* env =
- List.fold_right name_list ~init:(return env) ~f:(fun fst acc_env ->
- let* acc = acc_env in
- let* new_env = match_pattern acc (PVar fst, value) in
- return new_env)
- in
- let env =
- Base.List.fold
- ~init:env
- ~f:(fun env name ->
- ValueEnv.update_exn env name ~f:(function
- | VFun (arg, args, body, _) -> VFun (arg, args, body, env)
- | other -> other))
- ident_name_list
- in
- let pat_name_in_list = [ pat_name ] in
- let patterns_names_with_values =
- List.fold
- pat_name_in_list
- ~init:(Map.empty (module String))
- ~f:(fun map name ->
- let value = ValueEnv.find_exn env name in
- Map.set map ~key:name ~data:value)
- in
- return (env, patterns_names_with_values)
-;;
-
-let eval_construction env = function
- | Expr e ->
- let* value = eval_expr env e in
- return (env, Base.Map.singleton (module Base.String) "-" value)
- | Statement s -> eval_statement env s
-;;
-
-let eval env c = run (eval_construction env c)
-
-type global_error =
- [ error
- | Inferencer.error
- ]
-
-let pp_global_error fmt (e : global_error) =
- match e with
- | #error as e -> pp_error fmt e
- | #Inferencer.error as e -> Inferencer.pp_error fmt e
-;;
-
-let run_interpreter type_env value_env state c =
- let open Base in
- let new_state, infer_result = Inferencer.infer c type_env state in
- match infer_result with
- | Error (#Inferencer.error as type_err) -> new_state, Result.fail type_err
- | Ok (new_type_env, names_and_types) ->
- (match eval value_env c with
- | Error (#error as eval_err) -> new_state, Result.fail eval_err
- | Ok (new_value_env, names_and_values) ->
- let names_with_types_and_values =
- Map.fold
- names_and_types
- ~init:(Map.empty (module String))
- ~f:(fun ~key ~data map ->
- let value = Map.find_exn names_and_values key in
- Map.set map ~key ~data:(data, value))
- in
- new_state, Result.return (new_type_env, new_value_env, names_with_types_and_values))
-;;
diff --git a/FSharpActivePatterns/lib/interpreter.mli b/FSharpActivePatterns/lib/interpreter.mli
deleted file mode 100644
index e5ea553bb..000000000
--- a/FSharpActivePatterns/lib/interpreter.mli
+++ /dev/null
@@ -1,44 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-
-module ValueEnv : sig
- type t
- type value
-
- val default : t
- val pp_value : Format.formatter -> value -> unit
-end
-
-type error =
- [ `Division_by_zero
- | `Match_failure
- | `Type_mismatch
- | `Unbound_variable of string
- | `Args_after_not_variable_let
- | `Bound_several_times
- ]
-
-type global_error =
- [ error
- | Inferencer.error
- ]
-
-val pp_global_error : Format.formatter -> global_error -> unit
-
-val run_interpreter
- : Inferencer.TypeEnv.t
- -> ValueEnv.t
- -> int
- -> construction
- -> int
- * ( Inferencer.TypeEnv.t
- * ValueEnv.t
- * ( string
- , TypedTree.typ * ValueEnv.value
- , Base.String.comparator_witness )
- Base.Map.t
- , global_error )
- result
diff --git a/FSharpActivePatterns/lib/keywordChecker.ml b/FSharpActivePatterns/lib/keywordChecker.ml
deleted file mode 100644
index ff3687d1f..000000000
--- a/FSharpActivePatterns/lib/keywordChecker.ml
+++ /dev/null
@@ -1,27 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-let is_keyword = function
- | "if"
- | "then"
- | "else"
- | "let"
- | "in"
- | "not"
- | "true"
- | "false"
- | "fun"
- | "match"
- | "with"
- | "and"
- | "Some"
- | "None"
- | "function"
- | "->"
- | "|"
- | ":"
- | "::"
- | "_" -> true
- | _ -> false
-;;
diff --git a/FSharpActivePatterns/lib/keywordChecker.mli b/FSharpActivePatterns/lib/keywordChecker.mli
deleted file mode 100644
index 63931a206..000000000
--- a/FSharpActivePatterns/lib/keywordChecker.mli
+++ /dev/null
@@ -1,5 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-val is_keyword : string -> bool
diff --git a/FSharpActivePatterns/lib/parser.ml b/FSharpActivePatterns/lib/parser.ml
deleted file mode 100644
index a50110b51..000000000
--- a/FSharpActivePatterns/lib/parser.ml
+++ /dev/null
@@ -1,461 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Angstrom
-open Ast
-open Base
-open KeywordChecker
-open TypedTree
-
-(* TECHNICAL FUNCTIONS *)
-
-let is_ws = function
- | ' ' -> true
- | '\n' -> true
- | '\t' -> true
- | _ -> false
-;;
-
-let skip_ws = skip_while is_ws
-
-let peek_sep1 =
- peek_char
- >>= fun c ->
- match c with
- | None -> return None
- | Some c ->
- (match c with
- | '(' | ')' | ']' | ';' | ':' | ',' -> return (Some c)
- | _ -> if is_ws c then return (Some c) else fail "need a delimiter")
-;;
-
-let skip_ws_sep1 = peek_sep1 *> skip_ws
-
-let chainl1 e op =
- let rec go acc = lift2 (fun f x -> f acc x) op e >>= go <|> return acc in
- e >>= go
-;;
-
-let rec chainr1 e op =
- let* left = e in
- (let* f = op in
- let* right = chainr1 e op in
- return (f left right))
- <|> return left
-;;
-
-let rec unary_chain op e =
- op >>= (fun unexpr -> unary_chain op e >>= fun expr -> return (unexpr expr)) <|> e
-;;
-
-(* SIMPLE PARSERS *)
-let expr_const_factory parser = parser >>| fun lit -> Const lit
-let pat_const_factory parser = parser >>| fun lit -> PConst lit
-
-let p_int =
- skip_ws
- *> let* sign = string "+" <|> string "-" <|> string "" in
- let* number = take_while1 Char.is_digit in
- return (Int_lt (Int.of_string (sign ^ number)))
-;;
-
-let p_int_expr = expr_const_factory p_int
-let p_int_pat = pat_const_factory p_int
-
-let p_bool =
- skip_ws *> string "true"
- <|> skip_ws *> string "false"
- >>| fun s -> Bool_lt (Bool.of_string s)
-;;
-
-let p_bool_expr = expr_const_factory p_bool
-let p_bool_pat = pat_const_factory p_bool
-
-let p_escaped_char =
- char '\\'
- *> (any_char
- >>= function
- | '"' -> return '"'
- | '\\' -> return '\\'
- | 'n' -> return '\n'
- | 't' -> return '\t'
- | 'r' -> return '\r'
- | other -> fail (Printf.sprintf "Unknown escape sequence: \\%c" other))
-;;
-
-let p_regular_char = satisfy (fun c -> Char.(c <> '"' && c <> '\\'))
-
-let p_string =
- let+ s = skip_ws *> char '"' *> many (p_regular_char <|> p_escaped_char) <* char '"' in
- String_lt (String.of_char_list s)
-;;
-
-let p_string_expr = expr_const_factory p_string
-let p_string_pat = pat_const_factory p_string
-
-let p_inf_oper =
- let* oper =
- skip_ws
- *> take_while1 (function
- | '+'
- | '-'
- | '<'
- | '>'
- | '*'
- | '|'
- | '!'
- | '$'
- | '%'
- | '&'
- | '.'
- | '/'
- | ':'
- | '='
- | '?'
- | '@'
- | '^'
- | '~' -> true
- | _ -> false)
- in
- if is_keyword oper
- then fail "keywords are not allowed as variable names"
- else return (Ident oper)
-;;
-
-let p_name p_fst_letter =
- let* name =
- skip_ws
- *> lift2
- ( ^ )
- p_fst_letter
- (take_while (function
- | 'a' .. 'z' | 'A' .. 'Z' | '_' | '0' .. '9' -> true
- | _ -> false))
- in
- if is_keyword name
- then fail "keywords are not allowed as variable names"
- else return name
-;;
-
-let p_varname =
- p_name
- (take_while1 (function
- | 'a' .. 'z' | '_' -> true
- | _ -> false))
-;;
-
-let p_act_pat_name =
- p_name
- (take_while1 (function
- | 'A' .. 'Z' -> true
- | _ -> false))
-;;
-
-let p_ident =
- let* varname = p_varname in
- return (Ident varname)
-;;
-
-let p_act_pat_ident =
- let* name = p_act_pat_name in
- return (Ident name)
-;;
-
-let p_type = skip_ws *> char ':' *> skip_ws *> p_varname >>| fun s -> Primitive s
-let p_var_expr = p_ident >>| fun ident -> Variable ident
-let p_var_pat = p_ident >>| fun ident -> PVar ident
-
-let p_semicolon_list p_elem =
- skip_ws
- *> string "["
- *> skip_ws
- *> let+ list =
- fix (fun p_semi_list ->
- choice
- [ (let* hd = p_elem <* skip_ws <* string ";" in
- let* tl = p_semi_list in
- return (hd :: tl))
- ; (let* hd = p_elem <* skip_ws <* string "]" in
- return [ hd ])
- ; skip_ws *> string "]" *> return []
- ])
- in
- list
-;;
-
-let p_semicolon_list_expr p_expr = p_semicolon_list p_expr >>| fun l -> List l
-let p_semicolon_list_pat p_pat = p_semicolon_list p_pat >>| fun l -> PList l
-let p_unit = skip_ws *> string "(" *> skip_ws *> string ")" *> return Unit_lt
-let p_unit_expr = expr_const_factory p_unit
-let p_unit_pat = pat_const_factory p_unit
-
-(* EXPR PARSERS *)
-let p_parens p = skip_ws *> char '(' *> skip_ws *> p <* skip_ws <* char ')'
-let make_binexpr op expr1 expr2 = Bin_expr (op, expr1, expr2) [@@inline always]
-let make_unexpr op expr = Unary_expr (op, expr) [@@inline always]
-let make_tuple_expr e1 e2 rest = Tuple (e1, e2, rest) [@@inline always]
-let make_tuple_pat p1 p2 rest = PTuple (p1, p2, rest)
-let p_binexpr binop_str binop = skip_ws *> string binop_str *> return (make_binexpr binop)
-let p_unexpr unop_str unop = skip_ws *> string unop_str *> return (make_unexpr unop)
-let p_not = p_unexpr "not" Unary_not
-let unminus = p_unexpr "-" Unary_minus
-let add = p_binexpr "+" Binary_add
-let sub = p_binexpr "-" Binary_subtract
-let mul = p_binexpr "*" Binary_multiply
-let div = p_binexpr "/" Binary_divide
-let equal = p_binexpr "=" Binary_equal
-let unequal = p_binexpr "<>" Binary_unequal
-let less = p_binexpr "<" Binary_less
-let less_or_equal = p_binexpr "<=" Binary_less_or_equal
-let greater = p_binexpr ">" Binary_greater
-let greater_or_equal = p_binexpr ">=" Binary_greater_or_equal
-let log_or = p_binexpr "||" Logical_or
-let log_and = p_binexpr "&&" Logical_and
-let bitwise_or = p_binexpr "|||" Binary_or_bitwise
-let bitwise_and = p_binexpr "&&&" Binary_and_bitwise
-let bitwise_xor = p_binexpr "^^^" Binary_xor_bitwise
-let cons = p_binexpr "::" Binary_cons
-
-let p_cons_list_pat p_pat =
- chainr1 p_pat (skip_ws *> string "::" *> return (fun l r -> PCons (l, r)))
-;;
-
-let p_tuple make p =
- let tuple =
- let* fst = p <* skip_ws <* string "," in
- let* snd = p in
- let* rest = many (skip_ws *> string "," *> p) in
- return (make fst snd rest)
- in
- p_parens tuple <|> tuple
-;;
-
-let p_tuple_pat p_pat = p_tuple make_tuple_pat p_pat
-
-let p_if p_expr =
- lift3
- (fun cond th el -> If_then_else (cond, th, el))
- (skip_ws *> string "if" *> peek_sep1 *> p_expr)
- (skip_ws *> string "then" *> peek_sep1 *> p_expr)
- (skip_ws
- *> string "else"
- *> peek_sep1
- *> (p_expr <* peek_sep1 >>= fun e -> return (Some e))
- <|> return None)
-;;
-
-let p_option p make_option =
- skip_ws *> string "None" *> peek_sep1 *> return (make_option None)
- <|> let+ inner = skip_ws *> string "Some" *> peek_sep1 *> p in
- make_option (Some inner)
-;;
-
-let make_option_expr expr = Option expr
-let make_option_pat pat = POption pat
-let p_wild_pat = skip_ws *> string "_" *> return Wild
-
-let p_pat_const =
- choice [ p_int_pat; p_bool_pat; p_unit_pat; p_string_pat; p_var_pat; p_wild_pat ]
-;;
-
-let p_constraint_pat p_pat =
- let* pat = p_pat in
- let* typ = p_type in
- return (PConstraint (pat, typ))
-;;
-
-let p_act_pat_case p_pat =
- let* case = p_act_pat_ident in
- let* pat =
- peek_sep1 *> (p_pat <* peek_sep1)
- <|> (p_parens p_pat <* peek_sep1)
- <|> return (PConst Unit_lt)
- in
- return (PActive (case, pat))
-;;
-
-let p_pat =
- skip_ws
- *> fix (fun self ->
- let atom = choice [ p_pat_const; p_parens self; p_parens (p_constraint_pat self) ] in
- let semicolon_list = p_semicolon_list_pat (self <|> atom) <|> atom in
- let opt = p_option semicolon_list make_option_pat <|> semicolon_list in
- let cons = p_cons_list_pat opt in
- let tuple = p_tuple_pat cons <|> cons in
- let active = p_act_pat_case tuple <|> tuple in
- active)
-;;
-
-let p_let_bind p_expr =
- let* name = p_pat <|> (p_parens p_inf_oper >>| fun oper -> PVar oper) in
- let* args = many p_pat in
- let* body = skip_ws *> string "=" *> p_expr in
- return (Let_bind (name, args, body))
-;;
-
-let p_letin p_expr =
- skip_ws
- *> string "let"
- *> skip_ws_sep1
- *>
- let* rec_flag = string "rec" *> peek_sep1 *> return Rec <|> return Nonrec in
- let* let_bind1 = p_let_bind p_expr in
- let* let_binds = many (skip_ws *> string "and" *> peek_sep1 *> p_let_bind p_expr) in
- let* in_expr = skip_ws *> string "in" *> peek_sep1 *> p_expr in
- return (LetIn (rec_flag, let_bind1, let_binds, in_expr))
-;;
-
-let p_let p_expr =
- skip_ws
- *> string "let"
- *> skip_ws_sep1
- *>
- let* rec_flag = string "rec" *> peek_sep1 *> return Rec <|> return Nonrec in
- let* let_bind1 = p_let_bind p_expr in
- let* let_binds = many (skip_ws *> string "and" *> peek_sep1 *> p_let_bind p_expr) in
- return (Let (rec_flag, let_bind1, let_binds))
-;;
-
-let p_apply p_expr =
- chainl1
- (p_parens p_expr <|> (p_expr <* peek_sep1))
- (return (fun expr1 expr2 -> Apply (expr1, expr2)))
-;;
-
-let p_lambda p_expr =
- skip_ws
- *> string "fun"
- *> peek_sep1
- *>
- let* arg1 = p_pat in
- let* args = many p_pat <* skip_ws <* string "->" in
- let* body = p_expr in
- return (Lambda (arg1, args, body))
-;;
-
-let p_case p_expr =
- let* pat = skip_ws *> string "|" *> p_pat <* skip_ws <* string "->" in
- let* expr = p_expr in
- return (pat, expr)
-;;
-
-let p_first_case p_expr =
- let* pat = skip_ws *> (string "|" *> p_pat <|> p_pat) <* skip_ws <* string "->" in
- let* expr = p_expr in
- return (pat, expr)
-;;
-
-let p_match p_expr =
- let* value = skip_ws *> string "match" *> p_expr <* skip_ws <* string "with" in
- let* pat1, expr1 = p_first_case p_expr in
- let* cases = many (p_case p_expr) in
- return (Match (value, (pat1, expr1), cases))
-;;
-
-let p_function p_expr =
- skip_ws
- *> string "function"
- *>
- let* pat1, expr1 = p_first_case p_expr in
- let* cases = many (p_case p_expr) in
- return (Function ((pat1, expr1), cases))
-;;
-
-let p_inf_oper_expr p_expr =
- skip_ws
- *> chainl1
- p_expr
- (p_inf_oper
- >>= fun op ->
- return (fun expr1 expr2 -> Apply (Apply (Variable op, expr1), expr2)))
-;;
-
-let p_constraint_expr p_expr =
- let* expr = p_expr in
- let* typ = p_type in
- return (EConstraint (expr, typ))
-;;
-
-let p_act_pat p_expr =
- skip_ws
- *> string "let"
- *> skip_ws_sep1
- *>
- let* fst_name =
- skip_ws *> string "(" *> skip_ws *> string "|" *> skip_ws *> p_act_pat_ident
- in
- let* names =
- many (skip_ws *> string "|" *> p_act_pat_ident)
- <* skip_ws
- <* string "|"
- <* skip_ws
- <* string ")"
- in
- let* args = many p_pat in
- let* expr = skip_ws *> string "=" *> skip_ws *> p_expr in
- return (ActPat (fst_name, names, args, expr))
-;;
-
-let p_act_pat_constructor p_expr =
- skip_ws
- *>
- let* name = p_act_pat_ident in
- let* expr =
- peek_sep1 *> (p_expr <* peek_sep1)
- <|> (p_parens p_expr <* peek_sep1)
- <|> return (Const Unit_lt)
- in
- return (ActPatConstructor (name, expr))
-;;
-
-let p_expr =
- skip_ws
- *> fix (fun p_expr ->
- let atom =
- choice
- [ p_var_expr
- ; p_int_expr
- ; p_string_expr
- ; p_unit_expr
- ; p_bool_expr
- ; p_parens p_expr
- ; p_semicolon_list_expr p_expr
- ; p_parens (p_constraint_expr p_expr)
- ]
- in
- let if_expr = p_if (p_expr <|> atom) <|> atom in
- let letin_expr = p_letin (p_expr <|> if_expr) <|> if_expr in
- let option = p_option letin_expr make_option_expr <|> letin_expr in
- let apply = p_apply option <|> option in
- let unary = choice [ unary_chain p_not apply; unary_chain unminus apply ] in
- let factor = chainl1 unary (mul <|> div) in
- let term = chainl1 factor (add <|> sub) in
- let cons_op = chainr1 term cons in
- let comp_eq = chainl1 cons_op (equal <|> unequal) in
- let comp_less = chainl1 comp_eq (less_or_equal <|> less) in
- let comp_gr = chainl1 comp_less (greater_or_equal <|> greater) in
- let bit_xor = chainl1 comp_gr bitwise_xor in
- let bit_and = chainl1 bit_xor bitwise_and in
- let bit_or = chainl1 bit_and bitwise_or in
- let comp_and = chainl1 bit_or log_and in
- let comp_or = chainl1 comp_and log_or in
- let inf_oper = p_inf_oper_expr comp_or <|> comp_or in
- let tuple = p_tuple make_tuple_expr inf_oper <|> inf_oper in
- let p_function = p_function (p_expr <|> tuple) <|> tuple in
- let ematch = p_match (p_expr <|> p_function) <|> p_function in
- let efun = p_lambda (p_expr <|> ematch) <|> ematch in
- let apat_c = p_act_pat_constructor efun <|> efun in
- apat_c)
-;;
-
-let p_statement = p_act_pat p_expr <|> p_let p_expr
-
-let p_construction =
- p_expr >>= (fun e -> return (Expr e)) <|> (p_statement >>= fun s -> return (Statement s))
-;;
-
-(* MAIN PARSE FUNCTION *)
-let parse (str : string) =
- parse_string ~consume:All (skip_ws *> p_construction <* skip_ws) str
-;;
diff --git a/FSharpActivePatterns/lib/parser.mli b/FSharpActivePatterns/lib/parser.mli
deleted file mode 100644
index 6d0484176..000000000
--- a/FSharpActivePatterns/lib/parser.mli
+++ /dev/null
@@ -1,7 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-
-val parse : string -> (construction, string) result
diff --git a/FSharpActivePatterns/lib/prettyPrinter.ml b/FSharpActivePatterns/lib/prettyPrinter.ml
deleted file mode 100644
index 1af856045..000000000
--- a/FSharpActivePatterns/lib/prettyPrinter.ml
+++ /dev/null
@@ -1,168 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-open Format
-open TypesPp
-
-let pp_bin_op fmt = function
- | Binary_equal -> fprintf fmt "= "
- | Binary_unequal -> fprintf fmt "<> "
- | Binary_less -> fprintf fmt "< "
- | Binary_less_or_equal -> fprintf fmt "<= "
- | Binary_greater -> fprintf fmt "> "
- | Binary_greater_or_equal -> fprintf fmt ">= "
- | Binary_add -> fprintf fmt "+ "
- | Binary_subtract -> fprintf fmt "- "
- | Binary_multiply -> fprintf fmt "* "
- | Logical_or -> fprintf fmt "|| "
- | Logical_and -> fprintf fmt "&& "
- | Binary_divide -> fprintf fmt "/ "
- | Binary_or_bitwise -> fprintf fmt "||| "
- | Binary_xor_bitwise -> fprintf fmt "^^^ "
- | Binary_and_bitwise -> fprintf fmt "&&& "
- | Binary_cons -> fprintf fmt "::"
-;;
-
-let pp_unary_op fmt = function
- | Unary_minus -> fprintf fmt "-"
- | Unary_not -> fprintf fmt "not "
-;;
-
-let pp_rec_flag fmt = function
- | Rec -> fprintf fmt "rec"
- | Nonrec -> ()
-;;
-
-let rec pp_pattern fmt = function
- | Wild -> fprintf fmt "_ "
- | PList l ->
- fprintf fmt "[";
- pp_print_list ~pp_sep:(fun fmt () -> fprintf fmt "; ") pp_pattern fmt l;
- fprintf fmt "]"
- | PCons (l, r) -> fprintf fmt "(%a) :: (%a) " pp_pattern l pp_pattern r
- | PTuple (p1, p2, rest) ->
- fprintf fmt "(";
- pp_print_list
- ~pp_sep:(fun fmt () -> fprintf fmt ", ")
- pp_pattern
- fmt
- (p1 :: p2 :: rest);
- fprintf fmt ")"
- | PConst literal -> fprintf fmt "%a " pp_expr (Const literal)
- | PVar (Ident name) -> fprintf fmt "%s " name
- | POption p ->
- (match p with
- | None -> fprintf fmt "None "
- | Some p -> fprintf fmt "Some (%a) " pp_pattern p)
- | PConstraint (p, t) -> fprintf fmt "(%a : %a) " pp_pattern p pp_typ t
- | PActive (Ident name, p) -> fprintf fmt "%s %a" name pp_pattern p
-
-and pp_expr fmt expr =
- match expr with
- | Const (Int_lt i) -> fprintf fmt "%d " i
- | Const (Bool_lt b) -> fprintf fmt "%b " b
- | Const (String_lt s) -> fprintf fmt "%S" s
- | Const Unit_lt -> fprintf fmt "() "
- | List l ->
- fprintf fmt "[";
- pp_print_list ~pp_sep:(fun fmt () -> fprintf fmt "; ") pp_expr fmt l;
- fprintf fmt "]"
- | Tuple (e1, e2, rest) ->
- fprintf fmt "(";
- pp_print_list
- ~pp_sep:(fun fmt () -> fprintf fmt ", ")
- pp_parens_expr
- fmt
- (e1 :: e2 :: rest);
- fprintf fmt ")"
- | Function ((pat1, expr1), cases) ->
- fprintf fmt "function ";
- List.iter
- (fun (pat, expr) -> fprintf fmt "| %a -> (%a) \n" pp_pattern pat pp_expr expr)
- ((pat1, expr1) :: cases)
- | Match (value, (pat1, expr1), cases) ->
- fprintf fmt "match (%a) with \n" pp_expr value;
- List.iter
- (fun (pat, expr) -> fprintf fmt "| %a -> (%a) \n" pp_pattern pat pp_expr expr)
- ((pat1, expr1) :: cases)
- | Variable (Ident name) -> fprintf fmt "%s " name
- | Unary_expr (op, expr) -> fprintf fmt "%a (%a)" pp_unary_op op pp_expr expr
- | Bin_expr (op, left, right) ->
- fprintf fmt "(%a) %a (%a)" pp_expr left pp_bin_op op pp_expr right
- | If_then_else (cond, then_body, else_body) ->
- fprintf fmt "if (%a) then (%a) " pp_expr cond pp_expr then_body;
- (match else_body with
- | Some body -> fprintf fmt "else %a " pp_expr body
- | None -> ())
- | Lambda (arg1, args, body) ->
- fprintf fmt "fun ";
- List.iter (fun pat -> fprintf fmt "(%a) " pp_pattern pat) (arg1 :: args);
- fprintf fmt "-> %a " pp_expr body
- | Apply (Apply (Variable (Ident op), left), right)
- when String.for_all (fun c -> String.contains "!$%&*+-./:<=>?@^|~" c) op ->
- fprintf fmt "(%a) %s (%a)" pp_expr left op pp_expr right
- | Apply (func, arg) -> fprintf fmt "(%a) %a" pp_expr func pp_expr arg
- | LetIn (rec_flag, let_bind, let_bind_list, in_expr) ->
- fprintf fmt "let %a " pp_rec_flag rec_flag;
- pp_print_list
- ~pp_sep:(fun fmt () -> fprintf fmt "\n\nand ")
- pp_let_bind
- fmt
- (let_bind :: let_bind_list);
- fprintf fmt "in\n";
- fprintf fmt "%a " pp_expr in_expr
- | Option e ->
- (match e with
- | None -> fprintf fmt "None "
- | Some e -> fprintf fmt "Some (%a)" pp_expr e)
- | EConstraint (e, t) -> fprintf fmt "(%a : %a) " pp_expr e pp_typ t
- | ActPatConstructor (Ident name, e) ->
- fprintf fmt " %s " name;
- fprintf fmt "(%a)" pp_expr e
-
-and pp_args fmt args =
- let open Format in
- pp_print_list
- ~pp_sep:pp_print_space
- (fun fmt arg -> fprintf fmt "%a" pp_pattern arg)
- fmt
- args
-
-and pp_let_bind fmt = function
- | Let_bind (name, args, body) ->
- fprintf fmt "%a %a = %a " pp_pattern name pp_args args pp_expr body
-
-and pp_parens_expr fmt expr = fprintf fmt "(%a)" pp_expr expr
-
-let pp_statement fmt = function
- | Let (rec_flag, let_bind, let_bind_list) ->
- fprintf fmt "let %a " pp_rec_flag rec_flag;
- pp_print_list
- ~pp_sep:(fun fmt () -> fprintf fmt "\n\nand ")
- pp_let_bind
- fmt
- (let_bind :: let_bind_list)
- | ActPat (Ident name, names, args, expr) ->
- fprintf fmt "let (|%s|" name;
- pp_print_list
- ~pp_sep:(fun fmt () -> fprintf fmt "|")
- (fun fmt (Ident name) -> fprintf fmt "%s" name)
- fmt
- names;
- fprintf fmt "|) ";
- pp_print_list ~pp_sep:(fun fmt () -> fprintf fmt " ") pp_pattern fmt args;
- fprintf fmt " =\n";
- pp_expr fmt expr
-;;
-
-let pp_construction fmt = function
- | Expr e -> fprintf fmt "%a\n" pp_expr e
- | Statement s -> fprintf fmt "%a\n" pp_statement s
-;;
-
-let pp_p_res fmt = function
- | Some c -> pp_construction fmt c
- | None -> fprintf fmt "Error occured\n"
-;;
diff --git a/FSharpActivePatterns/lib/prettyPrinter.mli b/FSharpActivePatterns/lib/prettyPrinter.mli
deleted file mode 100644
index 428b94b3d..000000000
--- a/FSharpActivePatterns/lib/prettyPrinter.mli
+++ /dev/null
@@ -1,9 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open Ast
-open Format
-
-val pp_construction : formatter -> construction -> unit
-val pp_p_res : formatter -> construction option -> unit
diff --git a/FSharpActivePatterns/lib/tests/ast_printer.ml b/FSharpActivePatterns/lib/tests/ast_printer.ml
deleted file mode 100644
index b713bc9ad..000000000
--- a/FSharpActivePatterns/lib/tests/ast_printer.ml
+++ /dev/null
@@ -1,279 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-let%expect_test "print Ast factorial" =
- let open FSharpActivePatterns.Ast in
- let open FSharpActivePatterns.AstPrinter in
- let open Format in
- let factorial =
- Lambda
- ( PConst (Int_lt 4)
- , []
- , If_then_else
- ( Bin_expr
- ( Logical_or
- , Bin_expr (Binary_equal, Variable (Ident "n"), Const (Int_lt 0))
- , Bin_expr (Binary_equal, Variable (Ident "n"), Const (Int_lt 1)) )
- , Const (Int_lt 1)
- , Some
- (Bin_expr
- ( Binary_multiply
- , Variable (Ident "n")
- , Apply
- ( Variable (Ident "factorial")
- , Bin_expr (Binary_subtract, Variable (Ident "n"), Const (Int_lt 1))
- ) )) ) )
- in
- let program =
- [ Statement (Let (Nonrec, Let_bind (PVar (Ident "a"), [], Const (Int_lt 10)), []))
- ; Expr factorial
- ; Expr (Apply (factorial, Variable (Ident "a")))
- ]
- in
- List.iter (print_construction std_formatter) program;
- [%expect
- {|
- | Let:
- Let_binds
- --| Let_bind:
- NAME:
- ------| PVar(a)
- ARGS:
- BODY:
- ----| Const(Int: 10)
- | Lambda:
- ARGS
- ----| PConst:
- ------Int: 4
- BODY
- ----| If Then Else(
- CONDITION
- ------| Binary expr(
- ------| Logical Or
- --------| Binary expr(
- --------| Binary Equal
- ----------| Variable(n)
- ----------| Const(Int: 0)
- --------| Binary expr(
- --------| Binary Equal
- ----------| Variable(n)
- ----------| Const(Int: 1)
- THEN BRANCH
- ------| Const(Int: 1)
- ELSE BRANCH
- ------| Binary expr(
- ------| Binary Multiply
- --------| Variable(n)
- --------| Apply:
- FUNCTION
- ----------| Variable(factorial)
- ARGS
- ----------| Binary expr(
- ----------| Binary Subtract
- ------------| Variable(n)
- ------------| Const(Int: 1)
- | Apply:
- FUNCTION
- --| Lambda:
- ARGS
- ------| PConst:
- --------Int: 4
- BODY
- ------| If Then Else(
- CONDITION
- --------| Binary expr(
- --------| Logical Or
- ----------| Binary expr(
- ----------| Binary Equal
- ------------| Variable(n)
- ------------| Const(Int: 0)
- ----------| Binary expr(
- ----------| Binary Equal
- ------------| Variable(n)
- ------------| Const(Int: 1)
- THEN BRANCH
- --------| Const(Int: 1)
- ELSE BRANCH
- --------| Binary expr(
- --------| Binary Multiply
- ----------| Variable(n)
- ----------| Apply:
- FUNCTION
- ------------| Variable(factorial)
- ARGS
- ------------| Binary expr(
- ------------| Binary Subtract
- --------------| Variable(n)
- --------------| Const(Int: 1)
- ARGS
- --| Variable(a) |}]
-;;
-
-let%expect_test "print Ast double func" =
- let open FSharpActivePatterns.Ast in
- let open FSharpActivePatterns.AstPrinter in
- let open Format in
- let ident = Ident "n" in
- let pat = PConst (Int_lt 4) in
- let args = [] in
- let binary_expr = Bin_expr (Binary_multiply, Const (Int_lt 2), Variable ident) in
- let double = Lambda (pat, args, binary_expr) in
- print_construction std_formatter @@ Expr double;
- [%expect
- {|
- | Lambda:
- ARGS
- ----| PConst:
- ------Int: 4
- BODY
- ----| Binary expr(
- ----| Binary Multiply
- ------| Const(Int: 2)
- ------| Variable(n)|}]
-;;
-
-let%expect_test "print Ast tuple of binary operators" =
- let open FSharpActivePatterns.Ast in
- let open FSharpActivePatterns.AstPrinter in
- let open Format in
- let first = Const (Int_lt 3) in
- let second = Const (Int_lt 10) in
- let operators =
- [ Binary_unequal
- ; Binary_less
- ; Binary_less_or_equal
- ; Binary_greater
- ; Binary_greater_or_equal
- ; Binary_add
- ; Logical_and
- ; Binary_divide
- ; Binary_or_bitwise
- ; Binary_xor_bitwise
- ; Binary_and_bitwise
- ]
- in
- let print_binary_constr operator =
- print_construction std_formatter @@ Expr (Bin_expr (operator, first, second))
- in
- List.iter print_binary_constr operators;
- [%expect
- {|
- | Binary expr(
- | Binary Unequal
- --| Const(Int: 3)
- --| Const(Int: 10)
- | Binary expr(
- | Binary Less
- --| Const(Int: 3)
- --| Const(Int: 10)
- | Binary expr(
- | Binary Less Or Equal
- --| Const(Int: 3)
- --| Const(Int: 10)
- | Binary expr(
- | Binary Greater
- --| Const(Int: 3)
- --| Const(Int: 10)
- | Binary expr(
- | Binary Greater Or Equal
- --| Const(Int: 3)
- --| Const(Int: 10)
- | Binary expr(
- | Binary Add
- --| Const(Int: 3)
- --| Const(Int: 10)
- | Binary expr(
- | Logical And
- --| Const(Int: 3)
- --| Const(Int: 10)
- | Binary expr(
- | Binary Divide
- --| Const(Int: 3)
- --| Const(Int: 10)
- | Binary expr(
- | Binary Or Bitwise
- --| Const(Int: 3)
- --| Const(Int: 10)
- | Binary expr(
- | Binary Xor Bitwise
- --| Const(Int: 3)
- --| Const(Int: 10)
- | Binary expr(
- | Binary And Bitwise
- --| Const(Int: 3)
- --| Const(Int: 10) |}]
-;;
-
-let%expect_test "print Ast of LetIn" =
- let open FSharpActivePatterns.Ast in
- let open FSharpActivePatterns.AstPrinter in
- let open Format in
- let sum =
- Expr
- (LetIn
- ( Nonrec
- , Let_bind (PVar (Ident "x"), [], Const (Int_lt 5))
- , []
- , Bin_expr (Binary_add, Variable (Ident "x"), Const (Int_lt 5)) ))
- in
- print_construction std_formatter sum;
- [%expect
- {|
- | LetIn=
- Let_binds
- --| Let_bind:
- NAME:
- ------| PVar(x)
- ARGS:
- BODY:
- ----| Const(Int: 5)
- INNER_EXPRESSION
- --| Binary expr(
- --| Binary Add
- ----| Variable(x)
- ----| Const(Int: 5) |}]
-;;
-
-let%expect_test "print Ast of match_expr" =
- let open FSharpActivePatterns.Ast in
- let open FSharpActivePatterns.AstPrinter in
- let open Format in
- let patterns =
- [ PConst (Int_lt 5)
- ; PConst (String_lt " bar foo")
- ; PList [ Wild; PVar (Ident "xs") ]
- ]
- in
- let pattern_values = List.map (fun p -> p, Const (Int_lt 4)) patterns in
- let match_expr =
- Match (Variable (Ident "x"), (PConst (Int_lt 4), Const (Int_lt 4)), pattern_values)
- in
- print_construction std_formatter (Expr match_expr);
- [%expect
- {|
- | Match:
- --| Value:
- ----| Variable(x)
- --| Pattern:
- ----| PConst:
- ------Int: 4
- --| Case expr:
- ----| Const(Int: 4)
- --| Pattern:
- ----| PConst:
- ------Int: 5
- --| Case expr:
- ----| Const(Int: 4)
- --| Pattern:
- ----| PConst:
- ------String: " bar foo"
- --| Case expr:
- ----| Const(Int: 4)
- --| Pattern:
- ----| PList:
- ------| Wild
- ------| PVar(xs)
- --| Case expr:
- ----| Const(Int: 4) |}]
-;;
diff --git a/FSharpActivePatterns/lib/tests/ast_printer.mli b/FSharpActivePatterns/lib/tests/ast_printer.mli
deleted file mode 100644
index 98fe2e874..000000000
--- a/FSharpActivePatterns/lib/tests/ast_printer.mli
+++ /dev/null
@@ -1,3 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
diff --git a/FSharpActivePatterns/lib/tests/dune b/FSharpActivePatterns/lib/tests/dune
deleted file mode 100644
index e03244be9..000000000
--- a/FSharpActivePatterns/lib/tests/dune
+++ /dev/null
@@ -1,14 +0,0 @@
-(library
- (name tests)
- (inline_tests)
- (modules Ast_printer Parser Qcheck_utils)
- (libraries FSharpActivePatterns qcheck-core qcheck-core.runner)
- (preprocess
- (pps ppx_expect ppx_inline_test ppx_deriving.show))
- (instrumentation
- (backend bisect_ppx)))
-
-(executable
- (name run_qcheck)
- (modules run_qcheck)
- (libraries tests FSharpActivePatterns qcheck-core.runner))
diff --git a/FSharpActivePatterns/lib/tests/parser.ml b/FSharpActivePatterns/lib/tests/parser.ml
deleted file mode 100644
index d7c173b00..000000000
--- a/FSharpActivePatterns/lib/tests/parser.ml
+++ /dev/null
@@ -1,345 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-let%expect_test "binary subtract" =
- let input = {| a - 3|} in
- FSharpActivePatterns.AstPrinter.print_p_res
- Format.std_formatter
- (FSharpActivePatterns.Parser.parse input);
- [%expect
- {|
- | Binary expr(
- | Binary Subtract
- --| Variable(a)
- --| Const(Int: 3) |}]
-;;
-
-let%expect_test "function apply of letIn" =
- let input = {| f let x = false in true || x|} in
- FSharpActivePatterns.AstPrinter.print_p_res
- Format.std_formatter
- (FSharpActivePatterns.Parser.parse input);
- [%expect
- {|
- | Apply:
- FUNCTION
- --| Variable(f)
- ARGS
- --| LetIn=
- Let_binds
- ----| Let_bind:
- NAME:
- --------| PVar(x)
- ARGS:
- BODY:
- ------| Const(Bool: false)
- INNER_EXPRESSION
- ----| Binary expr(
- ----| Logical Or
- ------| Const(Bool: true)
- ------| Variable(x) |}]
-;;
-
-let%expect_test "arithmetic with unary operations and variables" =
- let input = {| - a - - b + 4|} in
- FSharpActivePatterns.AstPrinter.print_p_res
- Format.std_formatter
- (FSharpActivePatterns.Parser.parse input);
- [%expect
- {|
- | Binary expr(
- | Binary Add
- --| Binary expr(
- --| Binary Subtract
- ----| Unary expr(
- ----| Unary minus
- ------| Variable(a)
- ----| Unary expr(
- ----| Unary minus
- ------| Variable(b)
- --| Const(Int: 4) |}]
-;;
-
-let%expect_test "sum of function applying" =
- let input = {| f 4 + g 3|} in
- FSharpActivePatterns.AstPrinter.print_p_res
- Format.std_formatter
- (FSharpActivePatterns.Parser.parse input);
- [%expect
- {|
- | Binary expr(
- | Binary Add
- --| Apply:
- FUNCTION
- ----| Variable(f)
- ARGS
- ----| Const(Int: 4)
- --| Apply:
- FUNCTION
- ----| Variable(g)
- ARGS
- ----| Const(Int: 3) |}]
-;;
-
-let%expect_test "order of logical expressions and function applying" =
- let input = {| let x = true in not x || true && f 12|} in
- FSharpActivePatterns.AstPrinter.print_p_res
- Format.std_formatter
- (FSharpActivePatterns.Parser.parse input);
- [%expect
- {|
- | LetIn=
- Let_binds
- --| Let_bind:
- NAME:
- ------| PVar(x)
- ARGS:
- BODY:
- ----| Const(Bool: true)
- INNER_EXPRESSION
- --| Binary expr(
- --| Logical Or
- ----| Unary expr(
- ----| Unary negative
- ------| Variable(x)
- ----| Binary expr(
- ----| Logical And
- ------| Const(Bool: true)
- ------| Apply:
- FUNCTION
- --------| Variable(f)
- ARGS
- --------| Const(Int: 12) |}]
-;;
-
-let%expect_test "FSharpActivePatterns.Parser.parse logical expression" =
- let input = {| (3 + 5) >= 8 || true && (5 <> 4) |} in
- FSharpActivePatterns.AstPrinter.print_p_res
- Format.std_formatter
- (FSharpActivePatterns.Parser.parse input);
- [%expect
- {|
- | Binary expr(
- | Logical Or
- --| Binary expr(
- --| Binary Greater Or Equal
- ----| Binary expr(
- ----| Binary Add
- ------| Const(Int: 3)
- ------| Const(Int: 5)
- ----| Const(Int: 8)
- --| Binary expr(
- --| Logical And
- ----| Const(Bool: true)
- ----| Binary expr(
- ----| Binary Unequal
- ------| Const(Int: 5)
- ------| Const(Int: 4) |}]
-;;
-
-let%expect_test "FSharpActivePatterns.Parser.parse integer expression" =
- let input = " (3 + 5) - (12 / 7)" in
- FSharpActivePatterns.AstPrinter.print_p_res
- Format.std_formatter
- (FSharpActivePatterns.Parser.parse input);
- [%expect
- {|
- | Binary expr(
- | Binary Subtract
- --| Binary expr(
- --| Binary Add
- ----| Const(Int: 3)
- ----| Const(Int: 5)
- --| Binary expr(
- --| Binary Divide
- ----| Const(Int: 12)
- ----| Const(Int: 7) |}]
-;;
-
-let%expect_test "FSharpActivePatterns.Parser.parse_unary_chain" =
- let input = "not not ( not true && false || 3 > 5)" in
- let result = FSharpActivePatterns.Parser.parse input in
- FSharpActivePatterns.AstPrinter.print_p_res Format.std_formatter result;
- [%expect
- {|
- | Unary expr(
- | Unary negative
- --| Unary expr(
- --| Unary negative
- ----| Binary expr(
- ----| Logical Or
- ------| Binary expr(
- ------| Logical And
- --------| Unary expr(
- --------| Unary negative
- ----------| Const(Bool: true)
- --------| Const(Bool: false)
- ------| Binary expr(
- ------| Binary Greater
- --------| Const(Int: 3)
- --------| Const(Int: 5) |}]
-;;
-
-let%expect_test "FSharpActivePatterns.Parser.parse if with comparison" =
- let input = "if 3 > 2 && false then 5 + 7 else 12" in
- FSharpActivePatterns.AstPrinter.print_p_res
- Format.std_formatter
- (FSharpActivePatterns.Parser.parse input);
- [%expect
- {|
- | If Then Else(
- CONDITION
- --| Binary expr(
- --| Logical And
- ----| Binary expr(
- ----| Binary Greater
- ------| Const(Int: 3)
- ------| Const(Int: 2)
- ----| Const(Bool: false)
- THEN BRANCH
- --| Binary expr(
- --| Binary Add
- ----| Const(Int: 5)
- ----| Const(Int: 7)
- ELSE BRANCH
- --| Const(Int: 12) |}]
-;;
-
-let%expect_test "sum with if" =
- let input = "a + if 3 > 2 then 2 else 1" in
- FSharpActivePatterns.AstPrinter.print_p_res
- Format.std_formatter
- (FSharpActivePatterns.Parser.parse input);
- [%expect
- {|
- | Binary expr(
- | Binary Add
- --| Variable(a)
- --| If Then Else(
- CONDITION
- ----| Binary expr(
- ----| Binary Greater
- ------| Const(Int: 3)
- ------| Const(Int: 2)
- THEN BRANCH
- ----| Const(Int: 2)
- ELSE BRANCH
- ----| Const(Int: 1) |}]
-;;
-
-let%expect_test "inner expressions with LetIn and If" =
- let input =
- "if let x = true in let y = false in x || y then 3 else if 5 > 3 then 2 else 1"
- in
- FSharpActivePatterns.AstPrinter.print_p_res
- Format.std_formatter
- (FSharpActivePatterns.Parser.parse input);
- [%expect
- {|
- | If Then Else(
- CONDITION
- --| LetIn=
- Let_binds
- ----| Let_bind:
- NAME:
- --------| PVar(x)
- ARGS:
- BODY:
- ------| Const(Bool: true)
- INNER_EXPRESSION
- ----| LetIn=
- Let_binds
- ------| Let_bind:
- NAME:
- ----------| PVar(y)
- ARGS:
- BODY:
- --------| Const(Bool: false)
- INNER_EXPRESSION
- ------| Binary expr(
- ------| Logical Or
- --------| Variable(x)
- --------| Variable(y)
- THEN BRANCH
- --| Const(Int: 3)
- ELSE BRANCH
- --| If Then Else(
- CONDITION
- ----| Binary expr(
- ----| Binary Greater
- ------| Const(Int: 5)
- ------| Const(Int: 3)
- THEN BRANCH
- ----| Const(Int: 2)
- ELSE BRANCH
- ----| Const(Int: 1) |}]
-;;
-
-let%expect_test "factorial" =
- let input = "let factorial n = if n = 0 then 1 else factorial (n - 1) in factorial b" in
- FSharpActivePatterns.AstPrinter.print_p_res
- Format.std_formatter
- (FSharpActivePatterns.Parser.parse input);
- [%expect
- {|
- | LetIn=
- Let_binds
- --| Let_bind:
- NAME:
- ------| PVar(factorial)
- ARGS:
- ----| PVar(n)
- BODY:
- ----| If Then Else(
- CONDITION
- ------| Binary expr(
- ------| Binary Equal
- --------| Variable(n)
- --------| Const(Int: 0)
- THEN BRANCH
- ------| Const(Int: 1)
- ELSE BRANCH
- ------| Apply:
- FUNCTION
- --------| Variable(factorial)
- ARGS
- --------| Binary expr(
- --------| Binary Subtract
- ----------| Variable(n)
- ----------| Const(Int: 1)
- INNER_EXPRESSION
- --| Apply:
- FUNCTION
- ----| Variable(factorial)
- ARGS
- ----| Variable(b) |}]
-;;
-
-let%expect_test "fail in ITE with incorrect else expression" =
- let input = "if true then 1 else 2c" in
- FSharpActivePatterns.AstPrinter.print_p_res
- Format.std_formatter
- (FSharpActivePatterns.Parser.parse input);
- [%expect {| : end_of_input |}]
-;;
-
-let%expect_test "call if with parentheses" =
- let input = "(if(false)then(a) else(b))c" in
- FSharpActivePatterns.AstPrinter.print_p_res
- Format.std_formatter
- (FSharpActivePatterns.Parser.parse input);
- [%expect
- {|
- | Apply:
- FUNCTION
- --| If Then Else(
- CONDITION
- ----| Const(Bool: false)
- THEN BRANCH
- ----| Variable(a)
- ELSE BRANCH
- ----| Variable(b)
- ARGS
- --| Variable(c) |}]
-;;
diff --git a/FSharpActivePatterns/lib/tests/parser.mli b/FSharpActivePatterns/lib/tests/parser.mli
deleted file mode 100644
index 98fe2e874..000000000
--- a/FSharpActivePatterns/lib/tests/parser.mli
+++ /dev/null
@@ -1,3 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
diff --git a/FSharpActivePatterns/lib/tests/qcheck_utils.ml b/FSharpActivePatterns/lib/tests/qcheck_utils.ml
deleted file mode 100644
index 4ea2c879a..000000000
--- a/FSharpActivePatterns/lib/tests/qcheck_utils.ml
+++ /dev/null
@@ -1,193 +0,0 @@
-[@@@ocaml.text "/*"]
-
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-[@@@ocaml.text "/*"]
-
-open FSharpActivePatterns.Ast
-open FSharpActivePatterns.AstPrinter
-open FSharpActivePatterns.Parser
-open FSharpActivePatterns.PrettyPrinter
-
-let bin_e op e1 e2 = Bin_expr (op, e1, e2)
-
-let shrink_lt =
- let open QCheck.Iter in
- function
- | Int_lt x -> QCheck.Shrink.int x >|= fun a' -> Int_lt a'
- | Bool_lt _ -> empty
- | Unit_lt -> empty
- | String_lt x -> QCheck.Shrink.string x >|= fun a' -> String_lt a'
-;;
-
-let exprs_from_let_binds let_binds =
- List.map
- (function
- | Let_bind (_, _, e) -> e)
- let_binds
-;;
-
-let rec shrink_let_bind =
- let open QCheck.Iter in
- function
- | Let_bind (name, args, e) ->
- shrink_expr e
- >|= (fun a' -> Let_bind (name, args, a'))
- <+> (QCheck.Shrink.list args >|= fun a' -> Let_bind (name, a', e))
- <+> (shrink_pattern name >|= fun a' -> Let_bind (a', args, e))
-
-and shrink_expr =
- let open QCheck.Iter in
- function
- | Const lt -> shrink_lt lt >|= fun a' -> Const a'
- | Tuple (e1, e2, rest) ->
- of_list [ e1; e2 ]
- <+> (shrink_expr e1 >|= fun a' -> Tuple (a', e2, rest))
- <+> (shrink_expr e2 >|= fun a' -> Tuple (e1, a', rest))
- <+> (QCheck.Shrink.list ~shrink:shrink_expr rest >|= fun a' -> Tuple (e1, e2, a'))
- | List l -> QCheck.Shrink.list ~shrink:shrink_expr l >|= fun l' -> List l'
- | Bin_expr (op, e1, e2) ->
- of_list [ e1; e2 ]
- <+> (shrink_expr e1 >|= fun a' -> bin_e op a' e2)
- <+> (shrink_expr e2 >|= fun a' -> bin_e op e1 a')
- | Unary_expr (op, e) -> return e <+> (shrink_expr e >|= fun e' -> Unary_expr (op, e'))
- | If_then_else (i, t, Some e) ->
- of_list [ i; t; e; If_then_else (i, e, None) ]
- <+> (shrink_expr i >|= fun a' -> If_then_else (a', t, Some e))
- <+> (shrink_expr t >|= fun a' -> If_then_else (i, a', Some e))
- | If_then_else (i, t, None) ->
- of_list [ i; t ]
- <+> (shrink_expr i >|= fun a' -> If_then_else (a', t, None))
- <+> (shrink_expr t >|= fun a' -> If_then_else (i, a', None))
- | LetIn (rec_flag, let_bind, let_bind_list, inner_e) ->
- of_list (inner_e :: exprs_from_let_binds (let_bind :: let_bind_list))
- <+> (shrink_let_bind let_bind
- >|= fun a' -> LetIn (rec_flag, a', let_bind_list, inner_e))
- <+> (QCheck.Shrink.list ~shrink:shrink_let_bind let_bind_list
- >|= fun a' -> LetIn (rec_flag, let_bind, a', inner_e))
- <+> (shrink_expr inner_e >|= fun a' -> LetIn (rec_flag, let_bind, let_bind_list, a'))
- | Apply (f, arg) ->
- of_list [ f; arg ]
- <+> (shrink_expr f >|= fun a' -> Apply (a', arg))
- <+> (shrink_expr arg >|= fun a' -> Apply (f, a'))
- | Lambda (pat, pat_list, body) ->
- shrink_expr body
- >|= (fun body' -> Lambda (pat, pat_list, body'))
- <+> (QCheck.Shrink.list ~shrink:shrink_pattern pat_list
- >|= fun a' -> Lambda (pat, a', body))
- | Function ((pat1, expr1), cases) ->
- of_list (expr1 :: List.map snd cases)
- <+> (shrink_pattern pat1 >|= fun a' -> Function ((a', expr1), cases))
- <+> (shrink_expr expr1 >|= fun a' -> Function ((pat1, a'), cases))
- <+> (QCheck.Shrink.list
- ~shrink:(fun (p, e) ->
- (let* p_shr = shrink_pattern p in
- return (p_shr, e))
- <+>
- let* e_shr = shrink_expr e in
- return (p, e_shr))
- cases
- >|= fun a' -> Function ((pat1, expr1), a'))
- | Match (value, (pat1, expr1), cases) ->
- of_list (value :: expr1 :: List.map snd cases)
- <+> (shrink_expr value >|= fun a' -> Match (a', (pat1, expr1), cases))
- <+> (shrink_pattern pat1 >|= fun a' -> Match (value, (a', expr1), cases))
- <+> (shrink_expr expr1 >|= fun a' -> Match (value, (pat1, a'), cases))
- <+> (QCheck.Shrink.list
- ~shrink:(fun (p, e) ->
- (let* p_shr = shrink_pattern p in
- return (p_shr, e))
- <+>
- let* e_shr = shrink_expr e in
- return (p, e_shr))
- cases
- >|= fun a' -> Match (value, (pat1, expr1), a'))
- | Option (Some e) ->
- of_list [ e; Option None ] <+> (shrink_expr e >|= fun a' -> Option (Some a'))
- | Option None -> empty
- | Variable _ -> empty
- | EConstraint (e, t) -> return e <+> shrink_expr e >|= fun a' -> EConstraint (a', t)
- | ActPatConstructor (ident, expr) ->
- shrink_expr expr >|= fun expr' -> ActPatConstructor (ident, expr')
-
-and shrink_pattern =
- let open QCheck.Iter in
- function
- | PList l -> QCheck.Shrink.list ~shrink:shrink_pattern l >|= fun l' -> PList l'
- | PCons (l, r) ->
- shrink_pattern l
- >|= (fun l' -> PCons (l', r))
- <+> (shrink_pattern r >|= fun r' -> PCons (l, r'))
- | PTuple (p1, p2, rest) ->
- of_list [ p1; p2 ]
- <+> (shrink_pattern p1 >|= fun p1' -> PTuple (p1', p2, rest))
- <+> (shrink_pattern p2 >|= fun p2' -> PTuple (p1, p2', rest))
- <+> (QCheck.Shrink.list ~shrink:shrink_pattern rest
- >|= fun rest' -> PTuple (p1, p2, rest'))
- | PConst lt -> shrink_lt lt >|= fun lt' -> PConst lt'
- | POption (Some p) -> return p
- | POption None -> empty
- | Wild -> empty
- | PVar _ -> empty
- | PConstraint (p, _) -> return p
- | PActive (ident, pattern) ->
- shrink_pattern pattern >|= fun pattern' -> PActive (ident, pattern')
-;;
-
-let shrink_statement =
- let open QCheck.Iter in
- function
- | Let (rec_flag, let_bind, let_bind_list) ->
- shrink_let_bind let_bind
- >|= (fun a' -> Let (rec_flag, a', let_bind_list))
- <+> (QCheck.Shrink.list ~shrink:shrink_let_bind let_bind_list
- >|= fun a' -> Let (rec_flag, let_bind, a'))
- <+>
- (match let_bind_list with
- | [] -> empty
- | hd :: _ -> return (Let (rec_flag, hd, [])))
- | ActPat (name, names, args, expr) ->
- shrink_expr expr
- >|= (fun expr' -> ActPat (name, names, args, expr'))
- <+> (QCheck.Shrink.list ~shrink:shrink_pattern args
- >|= fun args' -> ActPat (name, names, args', expr))
- <+> (QCheck.Shrink.list names >|= fun names' -> ActPat (name, names', args, expr))
-;;
-
-let shrink_construction =
- let open QCheck.Iter in
- function
- | Expr e -> shrink_expr e >|= fun a' -> Expr a'
- | Statement s ->
- shrink_statement s
- >|= (fun a' -> Statement a')
- <+>
- (match s with
- | Let (_, let_bind, let_binds) ->
- of_list (exprs_from_let_binds (let_bind :: let_binds)) >|= fun a' -> Expr a'
- | ActPat (_, _, _, expr) -> shrink_expr expr >|= fun e' -> Expr e')
-;;
-
-let arbitrary_construction =
- QCheck.make
- gen_construction
- ~print:
- (let open Format in
- asprintf "%a" (fun fmt c ->
- let pp = print_construction in
- fprintf fmt "Generated:\n%a" pp c;
- match parse (Format.asprintf "%a\n" pp c) with
- | Ok parsed -> fprintf fmt "Parsed:\n%a" pp parsed
- | Error e -> fprintf fmt "Parsing error:\n%s\n" e))
- ~shrink:shrink_construction
-;;
-
-let run n =
- QCheck_base_runner.run_tests
- [ QCheck.(
- Test.make arbitrary_construction ~count:n (fun c ->
- Ok c = parse (Format.asprintf "%a\n" pp_construction c)))
- ]
-;;
diff --git a/FSharpActivePatterns/lib/tests/qcheck_utils.mli b/FSharpActivePatterns/lib/tests/qcheck_utils.mli
deleted file mode 100644
index bc2e1b7aa..000000000
--- a/FSharpActivePatterns/lib/tests/qcheck_utils.mli
+++ /dev/null
@@ -1,5 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-val run : int -> int
diff --git a/FSharpActivePatterns/lib/tests/run_qcheck.ml b/FSharpActivePatterns/lib/tests/run_qcheck.ml
deleted file mode 100644
index 441c3ced5..000000000
--- a/FSharpActivePatterns/lib/tests/run_qcheck.ml
+++ /dev/null
@@ -1,30 +0,0 @@
-[@@@ocaml.text "/*"]
-
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-[@@@ocaml.text "/*"]
-
-open Tests.Qcheck_utils
-
-(* let generate n =
- List.iter
- Format.(fprintf std_formatter "%a\n" print_construction)
- (QCheck.Gen.generate ~n gen_construction)
- ;; *)
-
-let run_tests n =
- let _ = run n in
- ()
-;;
-
-let () =
- Arg.parse
- [ "-seed", Arg.Int QCheck_base_runner.set_seed, " Set seed"
- ; "-stop", Arg.Unit (fun _ -> exit 0), " Exit"
- ; "-gen", Arg.Int run_tests, " Number of runs"
- ]
- (fun _ -> assert false)
- "help"
-;;
diff --git a/FSharpActivePatterns/lib/typedTree.ml b/FSharpActivePatterns/lib/typedTree.ml
deleted file mode 100644
index cb70142f8..000000000
--- a/FSharpActivePatterns/lib/typedTree.ml
+++ /dev/null
@@ -1,53 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-type binder = int [@@deriving show { with_path = false }, qcheck]
-
-type typ =
- | Primitive of (string[@gen gen_primitive])
- | Type_var of binder
- | Arrow of typ * typ
- | Type_list of typ
- | Type_tuple of typ * typ * typ list
- | TOption of typ
- | TActPat of string * typ (** [Even(int)] *)
- | Choice of (string, typ, Base.String.comparator_witness) Base.Map.t
- (** [Choice] *)
-(* Map of Name/typ is Choice of , Name/typ is equiavalent to TActPat *)
-
-let choice_to_list ch =
- Base.List.map (Base.Map.to_alist ch) ~f:(fun (name, typ) -> TActPat (name, typ))
-;;
-
-let choice_set_many map list =
- Base.List.fold ~init:map list ~f:(fun map (name, typ) ->
- Base.Map.set map ~key:name ~data:typ)
-;;
-
-let gen_typ_primitive =
- QCheck.Gen.(oneofl [ "string"; "int"; "unit"; "bool" ] >|= fun t -> Primitive t)
-;;
-
-let arrow_of_types first_types last_type =
- let open Base in
- List.fold_right first_types ~init:last_type ~f:(fun left right -> Arrow (left, right))
-;;
-
-module VarSet = struct
- include Stdlib.Set.Make (Int)
-
- let pp fmt s =
- Format.fprintf fmt "[ ";
- iter (Format.fprintf fmt "%d; ") s;
- Format.fprintf fmt "]"
- ;;
-end
-
-type binder_set = VarSet.t [@@deriving show { with_path = false }]
-type scheme = Scheme of binder_set * typ
-
-let int_typ = Primitive "int"
-let bool_typ = Primitive "bool"
-let string_typ = Primitive "string"
-let unit_typ = Primitive "unit"
diff --git a/FSharpActivePatterns/lib/typedTree.mli b/FSharpActivePatterns/lib/typedTree.mli
deleted file mode 100644
index 791a8c647..000000000
--- a/FSharpActivePatterns/lib/typedTree.mli
+++ /dev/null
@@ -1,40 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-type binder = int
-
-type typ =
- | Primitive of string
- | Type_var of binder
- | Arrow of typ * typ
- | Type_list of typ
- | Type_tuple of typ * typ * typ list
- | TOption of typ
- | TActPat of string * typ (** [Even(int)] *)
- | Choice of (string, typ, Base.String.comparator_witness) Base.Map.t
- (** [Choice] *)
-(* Map of Name/typ is Choice of , Name/typ is equiavalent to TActPat *)
-
-val gen_typ_primitive : typ QCheck.Gen.t
-val arrow_of_types : typ list -> typ -> typ
-val choice_to_list : (string, typ, 'a) Base.Map.t -> typ list
-
-val choice_set_many
- : (string, typ, 'a) Base.Map.t
- -> (string * typ) list
- -> (string, typ, 'a) Base.Map.t
-
-module VarSet : sig
- include module type of Stdlib.Set.Make (Int)
-
- val pp : Format.formatter -> t -> unit
-end
-
-type binder_set = VarSet.t
-type scheme = Scheme of binder_set * typ
-
-val int_typ : typ
-val bool_typ : typ
-val string_typ : typ
-val unit_typ : typ
diff --git a/FSharpActivePatterns/lib/typesPp.ml b/FSharpActivePatterns/lib/typesPp.ml
deleted file mode 100644
index 67a9628c9..000000000
--- a/FSharpActivePatterns/lib/typesPp.ml
+++ /dev/null
@@ -1,35 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open TypedTree
-open Format
-
-let rec pp_typ fmt = function
- | Primitive s -> fprintf fmt "%s" s
- | Type_var var -> fprintf fmt "'%d" var
- | Arrow (fst, snd) ->
- (match fst with
- | Arrow _ -> fprintf fmt "(%a) -> %a" pp_typ fst pp_typ snd
- | _ -> fprintf fmt "%a -> %a" pp_typ fst pp_typ snd)
- | Type_list typ -> fprintf fmt "%a list" pp_typ typ
- | Type_tuple (first, second, rest) ->
- Format.pp_print_list
- ~pp_sep:(fun fmt () -> fprintf fmt " * ")
- (fun fmt typ ->
- match typ with
- | Arrow _ -> fprintf fmt "(%a)" pp_typ typ
- | _ -> pp_typ fmt typ)
- fmt
- (first :: second :: rest)
- | TOption t ->
- (match t with
- | Type_tuple _ | Arrow _ -> fprintf fmt "(%a) option" pp_typ t
- | t -> fprintf fmt "%a option" pp_typ t)
- | TActPat (name, t) -> fprintf fmt "%s (%a)" name pp_typ t
- | Choice map ->
- fprintf fmt "Choice<";
- (pp_print_list ~pp_sep:(fun fmt () -> fprintf fmt ", ") pp_typ fmt)
- (choice_to_list map);
- fprintf fmt ">"
-;;
diff --git a/FSharpActivePatterns/lib/typesPp.mli b/FSharpActivePatterns/lib/typesPp.mli
deleted file mode 100644
index 3b4a29818..000000000
--- a/FSharpActivePatterns/lib/typesPp.mli
+++ /dev/null
@@ -1,8 +0,0 @@
-(** Copyright 2024-2025, Ksenia Kotelnikova , Gleb Nasretdinov *)
-
-(** SPDX-License-Identifier: LGPL-3.0-or-later *)
-
-open TypedTree
-open Format
-
-val pp_typ : formatter -> typ -> unit
diff --git a/FSharpActivePatterns/tests/activePatterns.t b/FSharpActivePatterns/tests/activePatterns.t
deleted file mode 100644
index d70dba74f..000000000
--- a/FSharpActivePatterns/tests/activePatterns.t
+++ /dev/null
@@ -1,9 +0,0 @@
- $ ../bin/REPL.exe -fromfile activepatterns/choices.fs
- 200
- val - : unit = ()
- val |A|B|C|D| : int * int -> Choice =
-
- $ ../bin/REPL.exe -fromfile activepatterns/simple.fs
- 1
- val - : unit = ()
- val |MinusTwo|Not| : int -> Choice =
diff --git a/FSharpActivePatterns/tests/activepatterns/choices.fs b/FSharpActivePatterns/tests/activepatterns/choices.fs
deleted file mode 100644
index 954411ae7..000000000
--- a/FSharpActivePatterns/tests/activepatterns/choices.fs
+++ /dev/null
@@ -1,9 +0,0 @@
-let (|A|B|C|D|) (a,b) =
- if a > 0 then (if b > 0 then A a else B a ) else (if b > 0 then C b else D)
-
-let res = match (-3, 2) with
- | A x -> x
- | B x -> x * 10
- | C b -> b * 100
- | D -> 1
- in print_int res
diff --git a/FSharpActivePatterns/tests/activepatterns/simple.fs b/FSharpActivePatterns/tests/activepatterns/simple.fs
deleted file mode 100644
index 2808a607c..000000000
--- a/FSharpActivePatterns/tests/activepatterns/simple.fs
+++ /dev/null
@@ -1,8 +0,0 @@
-let (|MinusTwo|Not|) v =
- if v+2 = 0 then MinusTwo (v+10)
- else Not (v)
-
-let res = match 1 with
- | MinusTwo val -> val
- | Not val -> val
- in print_int res
diff --git a/FSharpActivePatterns/tests/dune b/FSharpActivePatterns/tests/dune
deleted file mode 100644
index bbdab9d51..000000000
--- a/FSharpActivePatterns/tests/dune
+++ /dev/null
@@ -1,39 +0,0 @@
-(cram
- (applies_to qcheck)
- (deps ../lib/tests/run_qcheck.exe))
-
-(cram
- (applies_to interpret_manytests)
- (deps
- ../bin/REPL.exe
- manytests/do_not_type/001.ml
- manytests/do_not_type/002if.ml
- manytests/do_not_type/003occurs.ml
- manytests/do_not_type/004let_poly.ml
- manytests/do_not_type/015tuples.ml
- manytests/do_not_type/099.ml
- manytests/typed/001fac.ml
- manytests/typed/002fac.ml
- manytests/typed/003fib.ml
- manytests/typed/004manyargs.ml
- manytests/typed/005fix.ml
- manytests/typed/006partial.ml
- manytests/typed/006partial2.ml
- manytests/typed/006partial3.ml
- manytests/typed/007order.ml
- manytests/typed/008ascription.ml
- manytests/typed/009let_poly.ml
- manytests/typed/010sukharev.ml
- manytests/typed/015tuples.ml
- manytests/typed/016lists.ml))
-
-(cram
- (applies_to activePatterns)
- (deps ../bin/REPL.exe activepatterns/choices.fs activepatterns/simple.fs))
-
-(cram
- (applies_to interpret)
- (deps
- ../bin/REPL.exe
- interpreter_tests/rev_list.fs
- interpreter_tests/fmap.fs))
diff --git a/FSharpActivePatterns/tests/interpret.t b/FSharpActivePatterns/tests/interpret.t
deleted file mode 100644
index 59150baf5..000000000
--- a/FSharpActivePatterns/tests/interpret.t
+++ /dev/null
@@ -1,8 +0,0 @@
- $ ../bin/REPL.exe -fromfile interpreter_tests/rev_list.fs
- val - : int list = [3 ; 2 ; 1 ]
- val rev_list : '13 list -> '13 list =
-
- $ ../bin/REPL.exe -fromfile interpreter_tests/fmap.fs
- val a : int option = None
- val b : int option = Some 24
- val fmap : ('3 -> '6) -> '3 option -> '6 option =
diff --git a/FSharpActivePatterns/tests/interpret_manytests.t b/FSharpActivePatterns/tests/interpret_manytests.t
deleted file mode 100644
index 5a81086a1..000000000
--- a/FSharpActivePatterns/tests/interpret_manytests.t
+++ /dev/null
@@ -1,113 +0,0 @@
- $ ../bin/REPL.exe -fromfile manytests/do_not_type/001.ml
- Error occured: Undefined variable 'fac'
- $ ../bin/REPL.exe -fromfile manytests/do_not_type/002if.ml
- Error occured: unification failed on int and bool
-
- $ ../bin/REPL.exe -fromfile manytests/do_not_type/003occurs.ml
- Error occured: Occurs check failed
- $ ../bin/REPL.exe -fromfile manytests/do_not_type/004let_poly.ml
- Error occured: unification failed on bool and int
-
- $ ../bin/REPL.exe -fromfile manytests/do_not_type/015tuples.ml
- Error occured: Only variables are allowed as left-hand side of `let rec'
- $ ../bin/REPL.exe -fromfile manytests/do_not_type/099.ml
- Error occured: Only variables are allowed as left-hand side of `let rec'
- $ ../bin/REPL.exe -fromfile manytests/typed/001fac.ml
- 24
- val fac : int -> int =
- val main : int = 0
- $ ../bin/REPL.exe -fromfile manytests/typed/002fac.ml
- 24
- val fac_cps : int -> (int -> '7) -> '7 =
- val main : int = 0
- $ ../bin/REPL.exe -fromfile manytests/typed/003fib.ml
- 3
- 3
- val fib : int -> int =
- val fib_acc : int -> int -> int -> int =
- val main : int = 0
- $ ../bin/REPL.exe -fromfile manytests/typed/004manyargs.ml
- 1111111111
- 1
- 10
- 100
- val main : int = 0
- val test10 : int -> int -> int -> int -> int -> int -> int -> int -> int -> int -> int =
- val test3 : int -> int -> int -> int =
- val wrap : '0 -> '0 =
- $ ../bin/REPL.exe -fromfile manytests/typed/005fix.ml
- 720
- val fac : (int -> int) -> int -> int =
- val fix : (('1 -> '5) -> '1 -> '5) -> '1 -> '5 =
- val main : int = 0
- $ ../bin/REPL.exe -fromfile manytests/typed/006partial.ml
- 1122
- val foo : int -> int =
- val main : int = 0
- $ ../bin/REPL.exe -fromfile manytests/typed/006partial2.ml
- 1
- 2
- 3
- 7
- val foo : int -> int -> int -> int =
- val main : int = 0
- $ ../bin/REPL.exe -fromfile manytests/typed/006partial3.ml
- 4
- 8
- 9
- val foo : int -> int -> int -> unit =
- val main : int = 0
- $ ../bin/REPL.exe -fromfile manytests/typed/007order.ml
- 1
- 2
- 4
- -1
- 103
- -555555
- 10000
- val _start : unit -> unit -> int -> unit -> int -> int -> unit -> int -> int -> int =
- val main : unit = ()
- $ ../bin/REPL.exe -fromfile manytests/typed/008ascription.ml
- 8
- val addi : ('0 -> bool -> int) -> ('0 -> bool) -> '0 -> int =
- val main : int = 0
- $ ../bin/REPL.exe -fromfile manytests/typed/009let_poly.ml
- val temp : int * bool = (1 , true )
- $ ../bin/REPL.exe -fromfile manytests/typed/010sukharev.ml
- val _1 : int -> int -> int * '1 -> bool =