Avoid dependency on BindingsMap from IR (#7055)

This commit is contained in:
Jaroslav Tulach 2023-06-19 10:28:31 +02:00 committed by GitHub
parent 7d0461cb6e
commit 5f572d0680
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 36 additions and 4256 deletions

View File

@ -257,7 +257,6 @@ lazy val enso = (project in file("."))
`syntax-definition`,
`syntax-rust-definition`,
`text-buffer`,
graph,
logger,
pkg,
cli,
@ -360,17 +359,7 @@ val akka =
// === Cats ===================================================================
val catsVersion = "2.9.0"
val kittensVersion = "3.0.0"
val cats = {
Seq(
"org.typelevel" %% "cats-core" % catsVersion,
"org.typelevel" %% "cats-effect" % catsVersion,
"org.typelevel" %% "cats-free" % catsVersion,
"org.typelevel" %% "cats-macros" % catsVersion,
"org.typelevel" %% "kittens" % kittensVersion
)
}
val catsVersion = "2.9.0"
// === Circe ==================================================================
@ -424,17 +413,6 @@ val jmh = Seq(
"org.openjdk.jmh" % "jmh-generator-annprocess" % jmhVersion % Benchmark
)
// === Monocle ================================================================
val monocleVersion = "2.1.0"
val monocle = {
Seq(
"com.github.julien-truffaut" %% "monocle-core" % monocleVersion,
"com.github.julien-truffaut" %% "monocle-macro" % monocleVersion,
"com.github.julien-truffaut" %% "monocle-law" % monocleVersion % "test"
)
}
// === Scala Compiler =========================================================
val scalaCompiler = Seq(
@ -506,15 +484,7 @@ lazy val logger = (project in file("lib/scala/logger"))
)
lazy val `syntax-definition` =
(project in file("lib/scala/syntax/definition"))
.dependsOn(logger)
.settings(
scalacOptions ++= Seq("-Ypatmat-exhaust-depth", "off"),
libraryDependencies ++= monocle ++ scalaCompiler ++ Seq(
"org.typelevel" %% "cats-core" % catsVersion,
"org.typelevel" %% "kittens" % kittensVersion
)
)
project in file("lib/scala/syntax/definition")
lazy val syntax = (project in file("lib/scala/syntax/specialization"))
.dependsOn(`syntax-definition`)
@ -648,30 +618,6 @@ lazy val `syntax-rust-definition` = project
frgaalJavaCompilerSetting
)
lazy val graph = (project in file("lib/scala/graph/"))
.dependsOn(logger)
.configs(Test)
.settings(
frgaalJavaCompilerSetting,
version := "0.1",
resolvers ++= (
Resolver.sonatypeOssRepos("releases") ++
Resolver.sonatypeOssRepos("snapshots")
),
scalacOptions += "-Ymacro-annotations",
libraryDependencies ++= scalaCompiler ++ Seq(
"com.chuusai" %% "shapeless" % shapelessVersion,
"io.estatico" %% "newtype" % newtypeVersion,
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
"org.scalacheck" %% "scalacheck" % scalacheckVersion % Test,
"com.github.julien-truffaut" %% "monocle-core" % monocleVersion,
"org.apache.commons" % "commons-lang3" % commonsLangVersion
),
addCompilerPlugin(
"org.typelevel" %% "kind-projector" % kindProjectorVersion cross CrossVersion.full
)
)
lazy val pkg = (project in file("lib/scala/pkg"))
.settings(
Compile / run / mainClass := Some("org.enso.pkg.Main"),

View File

@ -46,16 +46,6 @@ The license information can be found along with the copyright notices.
Copyright notices related to this dependency can be found in the directory `com.fasterxml.jackson.module.jackson-module-scala_2.13-2.15.2`.
'monocle-core_2.13', licensed under the MIT, is distributed with the engine.
The license information can be found along with the copyright notices.
Copyright notices related to this dependency can be found in the directory `com.github.julien-truffaut.monocle-core_2.13-2.1.0`.
'monocle-macro_2.13', licensed under the MIT, is distributed with the engine.
The license information can be found along with the copyright notices.
Copyright notices related to this dependency can be found in the directory `com.github.julien-truffaut.monocle-macro_2.13-2.1.0`.
'error_prone_annotations', licensed under the Apache 2.0, is distributed with the engine.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `com.google.errorprone.error_prone_annotations-2.18.0`.
@ -261,11 +251,6 @@ The license information can be found along with the copyright notices.
Copyright notices related to this dependency can be found in the directory `io.circe.circe-yaml_2.13-0.14.2`.
'java-diff-utils', licensed under the The Apache Software License, Version 2.0, is distributed with the engine.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `io.github.java-diff-utils.java-diff-utils-4.12`.
'directory-watcher', licensed under the Apache-2.0, is distributed with the engine.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `io.methvin.directory-watcher-0.9.10`.
@ -276,11 +261,6 @@ The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `io.spray.spray-json_2.13-1.3.6`.
'jna', licensed under the Apache-2.0, is distributed with the engine.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `net.java.dev.jna.jna-5.13.0`.
'jna', licensed under the Apache License v2.0, is distributed with the engine.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `net.java.dev.jna.jna-5.5.0`.
@ -331,11 +311,6 @@ The license file can be found at `licenses/Eclipse_Distribution_License_(New_BSD
Copyright notices related to this dependency can be found in the directory `org.eclipse.jgit.org.eclipse.jgit-6.3.0.202209071007-r`.
'jline', licensed under the The BSD License, is distributed with the engine.
The license file can be found at `licenses/BSD-3-Clause`.
Copyright notices related to this dependency can be found in the directory `org.jline.jline-3.22.0`.
'jline', licensed under the The BSD License, is distributed with the engine.
The license file can be found at `licenses/BSD-3-Clause`.
Copyright notices related to this dependency can be found in the directory `org.jline.jline-3.23.0`.
@ -376,11 +351,6 @@ The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `org.scala-lang.modules.scala-parser-combinators_2.13-1.1.2`.
'scala-compiler', licensed under the Apache-2.0, is distributed with the engine.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `org.scala-lang.scala-compiler-2.13.11`.
'scala-library', licensed under the Apache-2.0, is distributed with the engine.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `org.scala-lang.scala-library-2.13.11`.
@ -396,41 +366,21 @@ The license file can be found at `licenses/MIT`.
Copyright notices related to this dependency can be found in the directory `org.slf4j.slf4j-api-1.7.36`.
'alleycats-core_2.13', licensed under the MIT, is distributed with the engine.
The license file can be found at `licenses/MIT`.
Copyright notices related to this dependency can be found in the directory `org.typelevel.alleycats-core_2.13-2.8.0`.
'cats-core_2.13', licensed under the MIT, is distributed with the engine.
The license file can be found at `licenses/MIT`.
Copyright notices related to this dependency can be found in the directory `org.typelevel.cats-core_2.13-2.9.0`.
'cats-free_2.13', licensed under the MIT, is distributed with the engine.
The license information can be found along with the copyright notices.
Copyright notices related to this dependency can be found in the directory `org.typelevel.cats-free_2.13-2.1.1`.
'cats-kernel_2.13', licensed under the MIT, is distributed with the engine.
The license file can be found at `licenses/MIT`.
Copyright notices related to this dependency can be found in the directory `org.typelevel.cats-kernel_2.13-2.9.0`.
'cats-macros_2.13', licensed under the MIT, is distributed with the engine.
The license information can be found along with the copyright notices.
Copyright notices related to this dependency can be found in the directory `org.typelevel.cats-macros_2.13-2.1.1`.
'jawn-parser_2.13', licensed under the MIT, is distributed with the engine.
The license information can be found along with the copyright notices.
Copyright notices related to this dependency can be found in the directory `org.typelevel.jawn-parser_2.13-1.4.0`.
'kittens_2.13', licensed under the Apache-2.0, is distributed with the engine.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `org.typelevel.kittens_2.13-3.0.0`.
'sqlite-jdbc', licensed under the The Apache Software License, Version 2.0, is distributed with the engine.
The license information can be found along with the copyright notices.
Copyright notices related to this dependency can be found in the directory `org.xerial.sqlite-jdbc-3.42.0.0`.

View File

@ -1,20 +0,0 @@
The MIT License (MIT)
Copyright (c) 2014 Julien Truffaut
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.

View File

@ -1,20 +0,0 @@
The MIT License (MIT)
Copyright (c) 2014 Julien Truffaut
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.

View File

@ -1 +0,0 @@
Copyright (C) 2009 - 2017 java-diff-utils

View File

@ -1,7 +0,0 @@
Copyright (c) 2007 Timothy Wall, All Rights Reserved
Copyright (c) 2007 Wayne Meissner, All Rights Reserved
Copyright (c) 2017 Matthias Bläsing, All Rights Reserved
Copyright (c) 2022 Carlos Ballesteros, All Rights Reserved

View File

@ -1,3 +0,0 @@
Copyright (C) 2009-2018 the original author(s).
Copyright (c) 2000-2005 Dieter Wimberger

View File

@ -1,3 +0,0 @@
Copyright 2002-2017 LAMP/EPFL and Lightbend, Inc.
Copyright EPFL and Lightbend, Inc.

View File

@ -1,4 +0,0 @@
Copyright (c) 2015 Typelevel
See org.typelevel.cats-core_2.13-2.2.0-M3 for notices related to this module.

View File

@ -1,255 +0,0 @@
Cats Copyright (c) 2015 Cats Contributors.
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.
------
Code in Cats is derived in part from Scalaz. The Scalaz license follows:
Copyright (c) 2009-2014 Tony Morris, Runar Bjarnason, Tom Adams,
Kristian Domagala, Brad Clow, Ricky Clarkson, Paul Chiusano, Trygve
Laugstøl, Nick Partridge, Jason Zaugg. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------
Code in Cats is derived in part from the Scala standard library. The Scala license follows:
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -1,2 +0,0 @@
See org.typelevel.cats-core_2.13-2.2.0-M3 for notices related to this module.

View File

@ -1,255 +0,0 @@
Cats Copyright (c) 2015 Cats Contributors.
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.
------
Code in Cats is derived in part from Scalaz. The Scalaz license follows:
Copyright (c) 2009-2014 Tony Morris, Runar Bjarnason, Tom Adams,
Kristian Domagala, Brad Clow, Ricky Clarkson, Paul Chiusano, Trygve
Laugstøl, Nick Partridge, Jason Zaugg. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------
Code in Cats is derived in part from the Scala standard library. The Scala license follows:
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -1,2 +0,0 @@
See org.typelevel.cats-core_2.13-2.2.0-M3 for notices related to this module.

View File

@ -1,3 +0,0 @@
Copyright (c) 2015 Miles Sabin
Copyright (c) 2016 Miles Sabin

View File

@ -4,7 +4,6 @@ import org.enso.interpreter.Constants
import org.enso.compiler.core.IR.{Expression, IdentifiedLocation}
import org.enso.compiler.core.ir.MetadataStorage.MetadataPair
import org.enso.compiler.core.ir.{DiagnosticStorage, MetadataStorage}
import org.enso.compiler.data.BindingsMap
import org.enso.compiler.exception.CompilerError
import org.enso.compiler.pass.IRPass
import org.enso.interpreter.epb.EpbParser
@ -7549,7 +7548,7 @@ object IR {
*
* @param err the original error.
*/
case class ResolverError(err: BindingsMap.ResolutionError)
case class ResolverError(private val explain: ExplainResolution)
extends Reason {
/** Provides a human-readable explanation of the error.
@ -7557,30 +7556,11 @@ object IR {
* @return a human-readable message.
*/
override def explain(originalName: IR.Name): String =
err match {
case BindingsMap.ResolutionAmbiguous(candidates) =>
val firstLine =
s"The name ${originalName.name} is ambiguous. Possible candidates are:"
val lines = candidates.map {
case BindingsMap.ResolvedConstructor(
definitionType,
cons
) =>
s" Constructor ${cons.name} defined in module ${definitionType.module.getName};"
case BindingsMap.ResolvedModule(module) =>
s" The module ${module.getName};"
case BindingsMap.ResolvedPolyglotSymbol(_, symbol) =>
s" The imported polyglot symbol ${symbol.name};"
case BindingsMap.ResolvedMethod(module, symbol) =>
s" The method ${symbol.name} defined in module ${module.getName}"
case BindingsMap.ResolvedType(module, typ) =>
s" Type ${typ.name} defined in module ${module.getName}"
}
(firstLine :: lines).mkString("\n")
case BindingsMap.ResolutionNotFound =>
s"The name `${originalName.name}` could not be found"
}
this.explain.explain(originalName)
}
trait ExplainResolution {
def explain(originalName: IR.Name): String
}
case class MissingLibraryImportInFQNError(namespace: String)

View File

@ -941,18 +941,42 @@ object BindingsMap {
/** A representation of an error during name resolution.
*/
sealed trait ResolutionError
sealed trait ResolutionError extends IR.Error.Resolution.ExplainResolution
/** A representation of a resolution error due to symbol ambiguity.
*
* @param candidates all the possible resolutions for the name.
*/
case class ResolutionAmbiguous(candidates: List[ResolvedName])
extends ResolutionError
extends ResolutionError {
override def explain(originalName: IR.Name): String = {
val firstLine =
s"The name ${originalName.name} is ambiguous. Possible candidates are:"
val lines = candidates.map {
case BindingsMap.ResolvedConstructor(
definitionType,
cons
) =>
s" Constructor ${cons.name} defined in module ${definitionType.module.getName};"
case BindingsMap.ResolvedModule(module) =>
s" The module ${module.getName};"
case BindingsMap.ResolvedPolyglotSymbol(_, symbol) =>
s" The imported polyglot symbol ${symbol.name};"
case BindingsMap.ResolvedMethod(module, symbol) =>
s" The method ${symbol.name} defined in module ${module.getName}"
case BindingsMap.ResolvedType(module, typ) =>
s" Type ${typ.name} defined in module ${module.getName}"
}
(firstLine :: lines).mkString("\n")
}
}
/** A resolution error due to the symbol not being found.
*/
case object ResolutionNotFound extends ResolutionError
case object ResolutionNotFound extends ResolutionError {
override def explain(originalName: IR.Name): String =
s"The name `${originalName.name}` could not be found"
}
/** A metadata-friendly storage for resolutions */
case class Resolution(target: ResolvedName) extends IRPass.Metadata {

View File

@ -1,4 +0,0 @@
# Graph
This is a flexible and high-performance graph library that encodes the graphs in
a fashion amenable to incredibly rapid serialisation.

View File

@ -1 +0,0 @@
package org.enso.graph.definition;

View File

@ -1,860 +0,0 @@
package org.enso.graph
import shapeless.ops.hlist._
import shapeless.ops.{hlist, nat}
import shapeless.{::, HList, HNil, IsDistinctConstraint, Nat}
import scala.annotation.unused
import scala.collection.mutable
// Don't use AnyType here, as it gets boxed sometimes.
import io.estatico.newtype.macros.newtype
// Type-level literals (_0, _1, ...)
import shapeless.nat._
/* TODO [AA, WD] The following are features that we want for this graph:
* - `unsafeRemoveComponent` functionality.
* - Storage should keep a free-list and re-use space in the underlying buffers
* as much as possible in `addComponent`.
* - Basic equality testing (that should be overridden as needed).
* - An ability to define fields that store complex data such as `String`.
* - Add a `Default` typeclass, and ensure that all component fields are
* instances of it. Fields should then be initialised using it.
*/
/** This file contains the implementation of an incredibly generic graph.
*
* There are a few key notes that should be kept in mind when analysing this
* solution:
* - This is a _highly_ generic graph structure, which provides the plumbing
* for building your own graph structures.
* - It only provides an _unsafe_ API. As a result, this graph should never be
* used directly by client code. Instead, it should be used to implement a
* custom graph structure that provides a safe API.
*/
// ============================================================================
// === HList Generic Utilities ================================================
// ============================================================================
// ================
// === HListSum ===
// ================
/** Sums a [[HList]] that contains only [[Nat]].
*
* @tparam L the [[HList]] to sum
*/
trait HListSum[L <: HList] {
type Out <: Nat
}
object HListSum {
type Aux[L <: HList, X] = HListSum[L] { type Out = X }
def apply[L <: HList](implicit ev: HListSum[L]): Aux[L, ev.Out] = ev
implicit val onNil: HListSum.Aux[HNil, _0] =
new HListSum[HNil] { type Out = _0 }
implicit def onCons[H <: Nat, T <: HList, TS <: Nat](implicit
@unused rest: HListSum.Aux[T, TS],
all: nat.Sum[H, TS]
): HListSum.Aux[H :: T, all.Out] =
new HListSum[H :: T] { type Out = all.Out }
}
// =======================
// === HListOfNatToVec ===
// =======================
/** Converts an [[HList]] of [[Nat]] to a vector containing those same numbers
* as integers.
*
* @tparam L the [[HList]] to convert
*/
trait HListOfNatToVec[L <: HList] {
val out: Vector[Int]
}
object HListOfNatToVec {
implicit def onNil: HListOfNatToVec[HNil] =
new HListOfNatToVec[HNil] { val out = Vector[Int]() }
implicit def onCons[Head <: Nat, Tail <: HList](implicit
tail: HListOfNatToVec[Tail],
head: nat.ToInt[Head]
): HListOfNatToVec[Head :: Tail] = new HListOfNatToVec[Head :: Tail] {
val out = head() +: tail.out
}
}
// ======================
// === HListTakeUntil ===
// ======================
/** Takes members from an [[HList]] until it reaches a specified member [[T]].
*
* The sentinel member [[T]] is not included in the result list. For example,
* the following code will result in the list `A :: HNil`:
*
* {{{
* type MyList = A :: B :: C :: HNil
* type Sentinel = B
*
* type HListTakeUntil[Sentinel, MyList]
* }}}
*
* If the sentinel [[T]] is not found in [[Items]], the entire list is
* returned.
*
* @tparam T the sentinel member
* @tparam Items the list to take members from
*/
trait HListTakeUntil[T, Items <: HList] {
type Out <: HList
}
object HListTakeUntil extends HListTakeUntilDefaults {
type Aux[T, Items <: HList, X] = HListTakeUntil[T, Items] { type Out = X }
def apply[T, Items <: HList](implicit
ev: HListTakeUntil[T, Items]
): Aux[T, Items, ev.Out] = ev
implicit def onNil[T]: HListTakeUntil.Aux[T, HNil, HNil] =
new HListTakeUntil[T, HNil] { type Out = HNil }
implicit def onConsFound[Head, Tail <: HList]
: HListTakeUntil.Aux[Head, Head :: Tail, HNil] =
new HListTakeUntil[Head, Head :: Tail] { type Out = HNil }
}
trait HListTakeUntilDefaults {
implicit def onConsNotFound[T, Head, Tail <: HList, Tail2 <: HList](implicit
@unused ev1: HListTakeUntil.Aux[T, Tail, Tail2]
): HListTakeUntil.Aux[T, Head :: Tail, Head :: Tail2] =
new HListTakeUntil[T, Head :: Tail] { type Out = Head :: Tail2 }
}
// ============================================================================
// === Graph-specific utilities ===============================================
// ============================================================================
// =============
// === Sized ===
// =============
/** An abstraction for sized objects.
*
* Every sized object is aware of the size it occupies (specified as a number
* of [[Int]]) at compile time.
*
* @tparam T the [[Sized]] type
*/
trait Sized[T] {
type Out <: Nat
}
object Sized {
type Aux[T, X] = Sized[T] { type Out = X }
def apply[T](implicit ev: Sized[T]): Aux[T, ev.Out] = ev
implicit def instance[
ListOfItems <: HList,
ListOfSizes <: HList,
TotalSize <: Nat
](implicit
@unused ev1: MapSized.Aux[ListOfItems, ListOfSizes],
@unused ev2: HListSum.Aux[ListOfSizes, TotalSize]
): Sized.Aux[ListOfItems, TotalSize] =
new Sized[ListOfItems] { type Out = TotalSize }
}
/** A utility for accessing a the Size of a [[Sized]] object as an [[Int]]. */
trait KnownSize[T] extends Sized[T] {
val asInt: Int
}
object KnownSize {
implicit def instance[T, Size <: Nat](implicit
@unused ev: Sized.Aux[T, Size],
sizeEv: nat.ToInt[Size]
): KnownSize[T] = new KnownSize[T] { val asInt: Int = sizeEv() }
}
// ================
// === MapSized ===
// ================
/** Extracts the sizes of all types in a list of types. All of these types must
* be `Sized`.
*
* @tparam L the list of elements to extract sizes from
*/
trait MapSized[L <: HList] {
type Out <: HList
}
object MapSized {
type Aux[L <: HList, X] = MapSized[L] { type Out = X }
def apply[L <: HList](implicit ev: MapSized[L]): Aux[L, ev.Out] = ev
implicit val onNil: MapSized.Aux[HNil, HNil] =
new MapSized[HNil] { type Out = HNil }
implicit def onCons[H, T <: HList, TS <: HList, HSize <: Nat](implicit
@unused rest: MapSized.Aux[T, TS],
@unused headSize: Sized.Aux[H, HSize]
): MapSized.Aux[H :: T, HSize :: TS] =
new MapSized[H :: T] { type Out = HSize :: TS }
}
// =================
// === SizeUntil ===
// =================
/** Computes the size of the types in a HList up to some sentinel [[Elem]].
*
* When summing the sizes in the list, the sentinel element [[Elem]] is not
* included in the sum.
*
* @tparam Elem the type of the element to stop computing at
* @tparam Items the list of types to compute over
*/
trait SizeUntil[Elem, Items <: HList] {
type Out <: Nat
val asInt: Int
}
object SizeUntil {
type Aux[Elem, Items <: HList, X] = SizeUntil[Elem, Items] { type Out = X }
def apply[Elem, Items <: HList](implicit
ev: SizeUntil[Elem, Items]
): Aux[Elem, Items, ev.Out] = ev
implicit def instance[
Elem,
Items <: HList,
PriorElems <: HList,
PriorFieldSizes <: HList,
PriorFieldsSize <: Nat
](implicit
@unused ev1: HListTakeUntil.Aux[Elem, Items, PriorElems],
@unused ev2: MapSized.Aux[PriorElems, PriorFieldSizes],
@unused ev3: HListSum.Aux[PriorFieldSizes, PriorFieldsSize],
sizeAsInt: nat.ToInt[PriorFieldsSize]
): SizeUntil.Aux[Elem, Items, PriorFieldsSize] =
new SizeUntil[Elem, Items] {
type Out = PriorFieldsSize
val asInt = sizeAsInt()
}
}
/** Produces a [[HList]] of pairs of `(Type, Map[Type])` from a [[HList]] of
* types.
*
* The map it produces is a scala [[mutable.Map]]. Additionally, it has a
* constraint that no type may appear twice in the input list.
*
* @tparam Items the list to start from
*/
trait MapsOf[Items <: HList] {
type Out <: HList
val instance: Out
}
object MapsOf {
type Aux[Items <: HList, X] = MapsOf[Items] { type Out = X }
def apply[Items <: HList](implicit
ev: MapsOf[Items]
): MapsOf.Aux[Items, ev.Out] = ev
implicit def onNil: MapsOf.Aux[HNil, HNil] =
new MapsOf[HNil] {
type Out = HNil
val instance = HNil
}
implicit def onCons[Head, Tail <: HList](implicit
ev: MapsOf[Tail],
@unused distinct: IsDistinctConstraint[Head :: Tail]
): MapsOf.Aux[Head :: Tail, mutable.Map[Int, Head] :: ev.Out] =
new MapsOf[Head :: Tail] {
type Out = mutable.Map[Int, Head] :: ev.Out
val instance = mutable.Map[Int, Head]() :: ev.instance
}
def getOpaqueData[T, Opaques <: HList](
list: Opaques
)(implicit
ev: Selector[Opaques, mutable.Map[Int, T]]
): mutable.Map[Int, T] = {
list.select[mutable.Map[Int, T]]
}
}
/** A representation of the index of a variant case within the variant field.
*
* A variant node field is one that may take on many different forms under the
* umbrella of a single field. The prototypical example of this is `Shape`,
* which can be anything from `Empty` to `TypeDef`. We use the following
* terminology to describe variant fields:
* - "The variant" refers to the umbrella type (`Shape` in the example above).
* - "Branch" revers to the particular variant _element_ which the variant is
* taking on at any given time.
*
* @tparam F the variant field type
* @tparam V the variant branch type
*/
trait VariantIndexed[F <: Graph.Component.Field, V <: F] {
val ix: Int
}
// ============================================================================
// === Graph ==================================================================
// ============================================================================
/** A generic graph implementation.
*
* The type [[Graph]] should not be used directly by programs that use this
* library. Instead, it should be used to implement custom graph instances by
* extending the [[Graph]] trait.
*/
trait Graph
object Graph {
// ==========================
// === Smart Constructors ===
// ==========================
def apply[G <: Graph: GraphInfo](): GraphData[G] = new GraphData[G]()
// =================
// === Component ===
// =================
/** A graph component is a type of thing that can be stored in the graph.
*
* Components can be arbitrary, such as nodes, edges, groups, and so on. They
* are defined entirely by the users, and this is done by extending the
* [[Component]] trait. Please see the tests for examples of how this can be
* done.
*/
trait Component
object Component {
// === Ref ===
/** A generic reference to a graph component.
*
* For example, the `Node` type could be defined as follows, where `Nodes`
* is the appropriate component in the graph.
*
* {{{
* type Node = Ref[MyGraph, Nodes]
* }}}
*/
@newtype
final case class Ref[G <: Graph, C <: Component](ix: Int)
/** Type refinement for component references.
*
* Type refinement is used to add additional information to a [[Component]]
* to encode properties into the graph structure. This information can be
* type information, but can also be used to tag graph components with
* arbitrary properties.
*
* For example, a node with information that its shape is `App` can be
* encoded having the following type `Refined[Shape, App, Node]`.
*/
@newtype
final case class Refined[F <: Component.Field, Spec, T](wrapped: T)
object Refined {
implicit def unwrap[F <: Component.Field, S <: F, T](
t: Refined[F, S, T]
): T = { t.wrapped }
def wrap[F <: Component.Field, S <: F, T](t: T): Refined[F, S, T] =
Refined(t)
}
// === List ===
/** Defines the set of components in a graph by assigning a type to the
* `Out` parameter when implementing the trait.
*
* This is used to encode the graph structure at the type level. An example
* is as follows:
*
* {{{
* implicit def components = new Component.List[MyGraph] {
* type Out = Nodes :: Edges :: HNil
* }
* }}}
*
* @tparam G the graph for which the components are defined.
*/
// TODO [AA] Use a type level map/filter to make this more robust. The props
// should be checked at compile time even if a thing isn't used.
trait List[G <: Graph] {
type Out <: HList
}
object List {
type Aux[G <: Graph, X] = List[G] { type Out = X }
}
// === Field ===
/** A field is a portion of a [[Component]].
*
* They are used to attribute data to components, and store data within a
* component.
*
* An example would be a component `Node`, that consists of fields such as
* `ParentLink` and `Shape`.
*/
trait Field
object Field {
/** Defines the set of fields for a given kind of component.
*
* An example is as follows:
*
* {{{
* implicit def nodeFields = new Component.Field.List[MyGraph, Nodes] {
* type Out = Node.Shape :: Node.ParentLink :: HNil
* }
* }}}
*
* @tparam G the graph to which the component type [[C]] belongs
* @tparam C the component type to which the fields in the list belong
*/
// TODO [AA] Use a type level map/filter to make this more robust. Props
// should be checked at compile time even if a thing isn't used.
trait List[G <: Graph, C <: Component] { type Out <: HList }
object List {
type Aux[G <: Graph, C <: Component, X] = List[G, C] { type Out = X }
}
}
// === Storage ===
/** Specialized storage for component data.
*
* We intentionally do not use [[scala.collection.mutable.ArrayBuffer]] as
* it cannot be specialised for primitive types. [[Array]], on the other
* hand, can be.
*/
final class Storage(@unused elemSize: Int) {
var length: Int = 0
var array: Array[Int] = new Array[Int](length)
// TODO: Assert that elem size = elemSize
def push(elem: Array[Int]): Unit = {
this.array = this.array ++ elem
this.length += 1
}
}
// === VariantMatcher ===
/** A utility for generating unapply and match methods for a [[Component]]
* that contains a sum type.
*
* It is used internally by the [[org.enso.graph.definition.Macro.field]]
* macro to autogenerate matchers for variant fields.
*/
case class VariantMatcher[T <: Component.Field, V](ix: Int) {
def unapply[G <: Graph, C <: Component](
arg: Component.Ref[G, C]
)(implicit
graph: GraphData[G],
ev: HasComponentField[G, C, T]
): Option[Component.Refined[T, V, Component.Ref[G, C]]] = {
val variantIndexByteOffset = 0
if (
graph.unsafeReadFieldByIndex[C, T](
arg.ix,
variantIndexByteOffset
) == ix
)
Some(Component.Refined[T, V, Component.Ref[G, C]](arg))
else None
}
}
}
// =================
// === GraphData ===
// =================
/** [[GraphData]] is the underlying storage representation used by the
* [[Graph]].
*
* It contains the raw data for all the graph components and their fields.
*
* @param info information about the graph's underlying structure
* @tparam G the graph type that the data is for
*/
final class GraphData[G <: Graph]()(implicit val info: GraphInfo[G]) {
var components: Array[Component.Storage] =
this.componentSizes.map(size => new Component.Storage(size)).toArray
/** Gets a reference to the graph component at the specified index.
*
* No bounds checking is done on the provided index.
*
* @param index the index of the component to access
* @param ev evidence that the graph [[G]] has a component [[C]]
* @tparam C the type of the component to access
* @return a reference to the component at `index`
*/
def componentRefFromIndex[C <: Component](index: Int)(implicit
@unused ev: HasComponent[G, C]
): Graph.Component.Ref[G, C] = {
Graph.Component.Ref(index)
}
/** Sets a variant node field to the specified case.
*
* @param component the component to set the field in
* @param info evidence that the component [[C]] has field [[F]] in [[G]]
* @param indexed evidence that [[V]] is an indexed field in the variant
* [[F]]
* @tparam C the component type
* @tparam F the field type
* @tparam V the variant branch type
*/
def unsafeSetVariantCase[C <: Component, F <: Component.Field, V <: F](
component: Component.Ref[G, C]
)(implicit
info: HasComponentField[G, C, F],
indexed: VariantIndexed[F, V]
): Unit = {
unsafeWriteField[C, F](component, indexed.ix)
}
/** Reads the data for a specified field [[F]] in a component [[C]] from the
* graph for the component instance [[component]].
*
* @param component the component instance to read from
* @param info evidence that component [[C]] has field [[F]] in [[G]]
* @tparam C the component type
* @tparam F the field type
* @return the raw field data from [[component]] specified by [[F]]
*/
def unsafeGetFieldData[C <: Component, F <: Component.Field](
component: Component.Ref[G, C]
)(implicit info: HasComponentField[G, C, F]): (Array[Int], Int) = {
unsafeGetFieldDataByIndex[C, F](component.ix, info.fieldOffset)
}
/** Reads the data for a specified field [[F]] in a component [[C]] from the
* graph for the component instance represented by [[componentIx]].
*
* No bounds checking is performed on any of the provided indices.
*
* @param componentIx the index representing the component to read from
* @param fieldIx the index of the field [[F]] in the component [[C]]
* @param info evidence that component [[C]] has field [[F]] in [[G]]
* @tparam C the component type
* @tparam F the field type
* @return the raw field data from [[component]] specified by [[F]]
*/
def unsafeGetFieldDataByIndex[C <: Component, F <: Component.Field](
componentIx: Int,
fieldIx: Int
)(implicit info: HasComponentField[G, C, F]): (Array[Int], Int) = {
val arr = components(info.componentIndex).array
val idx = info.componentSize * componentIx + info.fieldOffset + fieldIx
(arr, idx)
}
/** Reads the spcified field [[F]] from [[component]].
*
* @param component the component instance to read from
* @param ev evidence that component [[C]] has field [[F]] in [[G]]
* @tparam C the component type
* @tparam F the field type
* @return the value of field [[F]] in [[component]]
*/
def unsafeReadField[C <: Component, F <: Component.Field](
component: Component.Ref[G, C]
)(implicit ev: HasComponentField[G, C, F]): Int = {
unsafeReadFieldByIndex[C, F](component.ix, ev.fieldOffset)
}
/** Reads the spcified field [[F]] from the instance of [[C]] at
* [[componentIx]].
*
* No bounds checking is performed on any of the provided indices.
*
* @param componentIx the index representing the component [[C]]
* @param fieldIx the index of the field [[F]] in the component [[C]]
* @param ev evidence that component [[C]] has field [[F]] in [[G]]
* @tparam C the component type
* @tparam F the field type
* @return the value of field [[F]] in [[component]]
*/
def unsafeReadFieldByIndex[C <: Component, F <: Component.Field](
componentIx: Int,
fieldIx: Int
)(implicit ev: HasComponentField[G, C, F]): Int = {
val (arr, idx) = unsafeGetFieldDataByIndex(componentIx, fieldIx)
arr(idx)
}
/** Writes the value of field [[F]] in [[component]] to be [[value]].
*
* @param component the instance of [[C]] to write to
* @param value the value to write to the field [[F]]
* @param ev evidence that component [[C]] has field [[F]] in [[G]]
* @tparam C the component type
* @tparam F the field type
*/
def unsafeWriteField[C <: Component, F <: Component.Field](
component: Component.Ref[G, C],
value: Int
)(implicit
ev: HasComponentField[G, C, F]
): Unit = {
unsafeWriteFieldByIndex[C, F](component.ix, ev.fieldOffset, value)
}
/** Sets the field at [[fieldIx]] in the instance of [[C]] represented by
* [[componentIx]] to have the value [[value]].
*
* No bounds checking is performed on any of the provided indices.
*
* @param componentIx the index representing an instance of [[C]]
* @param fieldIx the index of the field [[F]] in [[C]]
* @param value the value to set [[F]] to
* @param ev evidence that component [[C]] has field [[F]] in [[G]]
* @tparam C the component type
* @tparam F the field type
*/
def unsafeWriteFieldByIndex[C <: Component, F <: Component.Field](
componentIx: Int,
fieldIx: Int,
value: Int
)(implicit ev: HasComponentField[G, C, F]): Unit = {
val (arr, idx) = unsafeGetFieldDataByIndex(componentIx, fieldIx)
arr(idx) = value
}
/** Adds a new instance of component [[C]] to the graph.
*
* @param info evidence that the graph [[G]] has component [[C]]
* @tparam C the component type
* @return a reference to the new component [[C]]
*/
def addComponent[C <: Component]()(implicit
info: HasComponent[G, C]
): Component.Ref[G, C] = {
val compClsIx = info.componentIndex
val compIx = components(compClsIx).length
val data = new Array[Int](info.componentSize)
components(compClsIx).push(data)
Component.Ref(compIx)
}
}
object GraphData {
/** Gets the [[GraphInfo]] from the [[GraphData]] instance.
*
* @param g the graph data
* @tparam G the graph type
* @return the graph info for [[G]]
*/
implicit def getInfo[G <: Graph](g: GraphData[G]): GraphInfo[G] = g.info
}
// ====================
// === TypeFamilies ===
// ====================
// === GraphInfo ===
/** Information about the number and sizes of components stored in the graph.
*
* @tparam G the graph for which this metadata exists
*/
trait GraphInfo[G <: Graph] {
val componentCount: Int
val componentSizes: Vector[Int]
}
object GraphInfo {
implicit def instance[
G <: Graph,
ComponentList <: HList,
ComponentSizeList >: HList,
ComponentListLength <: Nat
](implicit
@unused ev1: Component.List.Aux[G, ComponentList],
@unused ev2: hlist.Length.Aux[ComponentList, ComponentListLength],
componentSizesEv: ComponentListToSizes[G, ComponentList],
len: nat.ToInt[ComponentListLength]
): GraphInfo[G] = new GraphInfo[G] {
val componentCount = len()
val componentSizes = componentSizesEv.sizes
}
}
// === HasComponent ===
/** Encodes that a given graph [[G]] has a component with given type [[C]].
*
* @tparam G the graph type
* @tparam C the component type
*/
trait HasComponent[G <: Graph, C <: Component] {
val componentIndex: Int
val componentSize: Int
}
object HasComponent {
implicit def instance[
G <: Graph,
C <: Component,
ComponentList <: HList,
PrevComponentList <: HList,
ComponentIndex <: Nat,
FieldList <: HList
](implicit
@unused ev1: Component.List.Aux[G, ComponentList],
@unused ev2: Component.Field.List.Aux[G, C, FieldList],
@unused ev3: HListTakeUntil.Aux[C, ComponentList, PrevComponentList],
@unused ev4: hlist.Length.Aux[PrevComponentList, ComponentIndex],
componentIndexEv: nat.ToInt[ComponentIndex],
componentSizeEv: KnownSize[FieldList],
@unused listContainsComponent: Selector[ComponentList, C]
): HasComponent[G, C] = new HasComponent[G, C] {
val componentIndex = componentIndexEv()
val componentSize = componentSizeEv.asInt
}
}
// === HasComponentField ===
/** Encodes that a graph [[G]] has field [[F]] in component [[C]].
*
* @tparam G the graph type
* @tparam C the component type in [[G]]
* @tparam F the field type in [[C]]
*/
trait HasComponentField[G <: Graph, C <: Component, F <: Component.Field] {
val componentIndex: Int
val componentSize: Int
val fieldOffset: Int
}
object HasComponentField {
implicit def instance[
G <: Graph,
C <: Component,
F <: Component.Field,
FieldList <: HList
](implicit
@unused ev1: Component.Field.List.Aux[G, C, FieldList],
evx: HasComponent[G, C],
fieldOffsetEv: SizeUntil[F, FieldList],
@unused containsField: Selector[FieldList, F]
): HasComponentField[G, C, F] = new HasComponentField[G, C, F] {
val componentIndex = evx.componentIndex
val componentSize = evx.componentSize
val fieldOffset = fieldOffsetEv.asInt
}
}
// === ComponentListToSizes ===
/** Obtains the sizes of all the components from the graph's list of
* components.
*
* @tparam G the graph
* @tparam ComponentList the list of components
*/
trait ComponentListToSizes[G <: Graph, ComponentList <: HList] {
val sizes: Vector[Int]
}
object ComponentListToSizes {
implicit def onNil[G <: Graph]: ComponentListToSizes[G, HNil] =
new ComponentListToSizes[G, HNil] { val sizes = Vector[Int]() }
implicit def onCons[G <: Graph, C <: Component, Tail <: HList](implicit
tail: ComponentListToSizes[G, Tail],
info: HasComponent[G, C]
): ComponentListToSizes[G, C :: Tail] =
new ComponentListToSizes[G, C :: Tail] {
val sizes = info.componentSize +: tail.sizes
}
}
/** Allows casting between variant cases without actually mutating the
* underlying structure.
*
* This is a very unsafe operation and should be used with care.
*
* @param component the component to cast the variant field in
* @param ev evidence that component [[C]] has field [[G]] in graph [[G]]
* @tparam G the graph type
* @tparam C the component type
* @tparam F the field type
*/
implicit class VariantCast[
G <: Graph,
C <: Component,
F <: Component.Field
](val component: Component.Ref[G, C])(implicit
ev: HasComponentField[G, C, F],
graph: GraphData[G]
) {
/** Checks if [[component]] is in the variant case denoted by the type
* [[V]].
*
* @param variantIndexed information that [[F]] is indeed a variant, with
* [[V]] as a valid case
* @tparam V the type of the variant case in question
* @return `true` if [[component]] is of the form denoted by [[V]], `false`
* otherwise
*/
def is[V <: F](implicit
variantIndexed: VariantIndexed[F, V]
): Boolean = {
graph.unsafeReadField[C, F](component) == variantIndexed.ix
}
/** Casts the variant field [[F]] to behave as the variant branch [[V]].
*
* It should be noted that this is purely a superficial cast, and does not
* affect the underlying graph. This means that [[C]] will still pattern
* match as if it was its original variant branch.
*
* @param variantIndexed information that [[F]] is indeed a variant, with
* [[V]] as a valid case
* @tparam V the type of the variant case in question
* @return the component [[component]] refined to be the variant branch
* [[V]]
*/
def unsafeAs[V <: F](implicit
@unused variantIndexed: VariantIndexed[F, V]
): Component.Refined[F, V, Component.Ref[G, C]] = {
Component.Refined[F, V, Component.Ref[G, C]](component)
}
/** Performs a checked cast of [[component]] to the variant state denoted
* by [[V]].
*
* @param variantIndexed information that [[F]] is indeed a variant, with
* [[V]] as a valid case
* @tparam V the type of the variant case in question
* @return [[Some]] if [[component]] is a [[V]], otherwise [[None]]
*/
def as[V <: F](implicit
variantIndexed: VariantIndexed[F, V]
): Option[Component.Refined[F, V, Component.Ref[G, C]]] = {
if (is[V]) {
Some(unsafeAs[V])
} else {
None
}
}
// TODO [AA] Add a utility to automatically refine variant branches
}
}

View File

@ -1,40 +0,0 @@
package org.enso.graph
import org.enso.graph.{Graph => PrimGraph}
import org.enso.graph.definition.Macro.component
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import shapeless.test.illTyped
class ComponentMacroTest extends AnyFlatSpec with Matchers {
"The `@component` macro" should "define correct components" in {
"@component case class Edges() { type Edge[G <: Graph] }" should compile
}
"The `@component` macro" should "not rely on the name of the graph type" in {
"@component case class Nodes() { type Node[G <: PrimGraph] }" should compile
}
"The `@component` macro child type" should "be accessible" in {
"@component case class Nodes() { type Node[G <: Graph] }\n type Test = Node[Graph]" should compile
}
"The `@component` child type" must "not allow more than one type parameter" in {
illTyped(
"@component case class Nodes() { type Node[G <: Graph, C] }",
"Your contained type must only have one type parameter."
)
}
"The `@component` macro" should "only allow application to case classes" in {
illTyped(
"@component object Test",
"You must provide a class definition to the @component macro."
)
illTyped(
"@component class Foo()",
"@component must be applied to a case class."
)
}
}

View File

@ -1,105 +0,0 @@
package org.enso.graph
import org.enso.graph.definition.Macro.{component, field, opaque}
import org.enso.graph.{Graph => PrimGraph}
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import shapeless.test.illTyped
class FieldMacroTest extends AnyFlatSpec with Matchers {
val subject = "The `@field` macro"
// === Components for Tests =================================================
@component case class Nodes() { type Node[G <: Graph] }
@component case class Edges() { type Edge[G <: Graph] }
@opaque case class Backref[G <: PrimGraph](opaque: Vector[Int])
@opaque case class Str[G <: PrimGraph](opaque: String)
// === Tests ================================================================
subject should "not explicitly depend on the graph type name" in {
"@field case class Shape[G <: PrimGraph](source: Node[G], target: Node[G])" should compile
}
subject should "work with returning the raw storage type" in {
"@field case class Location[G <: PrimGraph](line: Int, column: Int)" should compile
}
subject should "support opaque types using marker trait" in {
"@field case class Backref[G <: PrimGraph](references: OpaqueData[Vector[Int], BackrefStorage])" should compile
}
subject should "work for single fields" in {
"@field case class Shape[G <: Graph](source: Node[G], target: Node[G])" should compile
}
"The `@field` macro" should "work for variant fields" in {
"@field object Shape {\n type G = PrimGraph\n case class Nul()\n case class App(fn: Edge[G], arg: Edge[G])}" should compile
}
"Access to companion objects for fields" should "work as expected" in {
"@field object Shape {\n type G = Graph\n case class Nul()\n case class App[G <: Graph](fn: Edge[G], argTest: Edge[G])}\nval test = Shape.Nul.any" should compile
}
subject should "work properly with opaque types in variants" in {
"@field object Shape {\n" +
" type G = PrimGraph\n" +
" case class Nul()\n" +
" case class Name(str: OpaqueData[String, StrStorage], linkEdge: Edge[G])\n" +
"}" should compile
}
subject should "not allow application to non case classes" in {
illTyped(
"@field class Shape",
"@field must be applied to a case class or object."
)
}
subject should "not allow application to invalid constructs" in {
illTyped(
"@field type foo",
"The @field macro only operates on case classes."
)
}
subject should "error on variants without branches" in {
illTyped(
"@field object Shape{\n type G = Graph}",
"A variant must contain at least one case."
)
}
subject should "error on variants that do not define `type G`" in {
illTyped(
"@field object Shape{\n case class Nul()}",
"You must define a type named `G` in your variant that defines the graph type name."
)
}
subject should "error if a field defines a subfield with a name clash" in {
illTyped(
"@field case class Location[G <: PrimGraph](location: Int)",
"You cannot define a subfield name that clashes with the field name."
)
}
subject should "error if a variant defines a subfield with a name clash" in {
illTyped(
"@field object Shape { type G = PrimGraph\n case class Foo(shape: Edge[G])}",
"You cannot define a variant subfield that clashes with either the variant or case name."
)
illTyped(
"@field object Shape { type G = PrimGraph\n case class Foo(foo: Edge[G])}",
"You cannot define a variant subfield that clashes with either the variant or case name."
)
}
subject should "error if a variant case name clashes with the variant name" in {
illTyped(
"@field object Shape { type G = PrimGraph\n case class Shape(foo: Edge[G])}",
"A variant case cannot share its name with the variant."
)
}
}

View File

@ -1,117 +0,0 @@
package org.enso.graph
import org.enso.graph.{Graph => PrimGraph}
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import org.enso.graph.GraphTestDefinition._
/** This file contains tests for the graph library. */
class GraphTest extends AnyFlatSpec with Matchers {
// ==========================================================================
// === Example Graph Usage ==================================================
// ==========================================================================
import GraphImpl._
import GraphImpl.Node.ParentLink._
import GraphImpl.Node.Location._
import GraphImpl.Edge.Shape._
implicit val graph: PrimGraph.GraphData[Graph] = PrimGraph[Graph]();
implicit val stringStorage: StrStorage = StrStorage()
implicit val backrefStorage: BackrefStorage = BackrefStorage()
val n1: Node[Graph] = graph.addNode()
val n2: Node[Graph] = graph.addNode()
val n3: Node[Graph] = graph.addNode()
val e1: Edge[Graph] = graph.addEdge()
e1.source = n1
e1.target = n2
n1.parent = e1
n2.parent = e1
n3.parent = e1
// Change `n1` to be `App`
graph.unsafeSetVariantCase[
Nodes,
GraphImpl.Node.Shape,
GraphImpl.Node.Shape.App
](n1)
// Change `n2` to be `Name`
graph.unsafeSetVariantCase[
Nodes,
GraphImpl.Node.Shape,
GraphImpl.Node.Shape.Name
](n2)
// Change `n3` to be `Nul`
graph.unsafeSetVariantCase[
Nodes,
GraphImpl.Node.Shape,
GraphImpl.Node.Shape.Nul
](n3)
// ==========================================================================
// === Tests ================================================================
// ==========================================================================
"Component fields" should "be able to be accessed by their types" in {
n1.line = 10
n1.column = 5
n1.line shouldEqual 10
n1.column shouldEqual 5
n1.location = Node.LocationVal[Graph](1, 2)
n1.line shouldEqual 1
n1.column shouldEqual 2
}
"Opaque types" should "be accessed successfully" in {
val nameStr = "TestName"
val n2Refined = n2 match {
case GraphImpl.Node.Shape.Name.any(n2) => n2
}
n2Refined.str = nameStr
n2Refined.str shouldEqual nameStr
}
"Matching on variants" should "work properly" in {
val typeResult = n1 match {
case GraphImpl.Node.Shape.Nul.any(n @ _) => "Null"
case GraphImpl.Node.Shape.App.any(n1 @ _) => "App1"
}
typeResult shouldEqual "App1"
}
"Matching on variants" should "refine the variant type" in {
val refinedResult = n1 match {
case GraphImpl.Node.Shape.App.any(n1) => n1.fn
}
refinedResult shouldEqual 0
}
"Component fields" can "be accessed properly" in {
e1.source shouldEqual n1
e1.target shouldEqual n2
}
"The graph" should "be mutable" in {
val e2: Edge[Graph] = graph.addEdge()
e2.source = n1
e2.target = n2
e2.source shouldEqual n1
e2.source = n3
e2.source shouldEqual n3
}
}

View File

@ -1,648 +0,0 @@
package org.enso.graph
import org.enso.graph.Graph.Component
import org.enso.graph.Graph.Component.Field
import org.enso.graph.definition.Macro.{component, field, opaque}
import org.enso.graph.{Graph => PrimGraph}
import shapeless.{::, HNil}
import scala.annotation.nowarn
/** This file provides a small graph implementation for testing purposes.
*
* It creates a small graph implementation that tests both the various features
* of the library and of the library's macros. The commented out code has been
* left _intentionally_ to demonstrate the expansion of the macros here, and to
* aid in debugging said macros.
*/
object GraphTestDefinition {
@nowarn("cat=unused-params&msg=ev")
object GraphImpl {
// ========================================================================
// === Example Graph Implementation =======================================
// ========================================================================
case class Graph() extends PrimGraph
implicit def components: Component.List[Graph] {
type Out = Nodes :: Edges :: HNil
} =
new PrimGraph.Component.List[Graph] {
type Out = Nodes :: Edges :: HNil
}
implicit def nodeFields: Field.List[Graph, Nodes] {
type Out =
Node.Shape :: Node.ParentLink :: Node.Location :: Node.Backref :: HNil
} =
new PrimGraph.Component.Field.List[Graph, Nodes] {
type Out =
Node.Shape :: Node.ParentLink :: Node.Location :: Node.Backref :: HNil
}
implicit def edgeFields: Field.List[Graph, Edges] {
type Out = Edge.Shape :: HNil
} =
new PrimGraph.Component.Field.List[Graph, Edges] {
type Out = Edge.Shape :: HNil
}
// ========================================================================
// === Opaque Storage =====================================================
// ========================================================================
@opaque case class Str(opaque: String)
// sealed case class StringStorage() {
// val string: mutable.Map[Int, String] = mutable.Map()
// }
@opaque case class Backref(opaque: Vector[Int])
// sealed case class BackrefStorage() {
// val backref: mutable.Map[Int, Vector[Int]] = mutable.Map()
// }
// ========================================================================
// === Component Definitions ==============================================
// ========================================================================
// === Node ===
@component case class Nodes() { type Node[G <: PrimGraph] }
// sealed case class Nodes() extends PrimGraph.Component
// type Node[G <: PrimGraph] = PrimGraph.Component.Ref[G, Nodes]
// implicit class GraphWithNodes[G <: PrimGraph](
// graph: PrimGraph.GraphData[G]
// ) {
// def addNode()(implicit ev: PrimGraph.HasComponent[G, Nodes]): Node[G] = {
// graph.addComponent[Nodes]()
// }
// }
// === Edge ===
@component case class Edges() { type Edge[G <: PrimGraph] }
// sealed case class Edges() extends PrimGraph.Component
// type Edge[G <: PrimGraph] = PrimGraph.Component.Ref[G, Edges]
// implicit class GraphWithEdges[G <: PrimGraph](
// graph: PrimGraph.GraphData[G]
// ) {
// def addEdge()(implicit ev: PrimGraph.HasComponent[G, Edges]): Edge[G] = {
// graph.addComponent[Edges]()
// }
// }
// ========================================================================
// === Component Field Definitions ========================================
// ========================================================================
object Node {
@field object Shape {
type G = PrimGraph
case class Nul()
case class App(fn: Edge[G], arg: Edge[G])
case class Centre(fn: Edge[G])
case class Name(str: OpaqueData[String, StrStorage], linkEdge: Edge[G])
}
// sealed trait Shape extends PrimGraph.Component.Field
// object Shape {
// implicit def sized =
// new Sized[Shape] { type Out = _3 }
//
// sealed case class Nul() extends Shape
// sealed case class NulVal[G <: PrimGraph]()
// object Nul {
// val index = 0
// val any =
// PrimGraph.Component.VariantMatcher[Shape, Nul](index)
//
// implicit def sized =
// new Sized[Nul] { type Out = _0 }
//
// implicit def indexed =
// new VariantIndexed[Shape, Nul] { val ix = index }
//
// def unapply[G <: PrimGraph, C <: PrimGraph.Component](
// arg: PrimGraph.Component.Ref[G, C]
// )(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Option[NulVal[G]] = {
// any.unapply(arg).map(t => NulVal())
// }
//
// implicit class NulInstance[G <: PrimGraph, C <: PrimGraph.Component](
// node: PrimGraph.Component.Refined[
// Shape,
// App,
// PrimGraph.Component.Ref[G, C]
// ]
// ) {
// def nul(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): NulVal[G] = NulVal()
//
// def nul_=(value: NulVal[G])(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Unit = ()
// }
// }
//
// sealed case class App() extends Shape
// sealed case class AppVal[G <: PrimGraph](fn: Edge[G], arg: Edge[G])
// object App {
// val index = 1
// val any =
// PrimGraph.Component.VariantMatcher[Shape, App](index)
// implicit def sized =
// new Sized[App] { type Out = _2 }
//
// implicit def indexed =
// new VariantIndexed[Shape, App] { val ix = index }
//
// def unapply[G <: PrimGraph, C <: PrimGraph.Component](
// arg: PrimGraph.Component.Ref[G, C]
// )(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Option[(Edge[G], Edge[G])] =
// any.unapply(arg).map(t => scala.Tuple2(t.fn, t.arg))
//
// implicit class AppInstance[G <: PrimGraph, C <: PrimGraph.Component](
// node: PrimGraph.Component.Refined[
// Shape,
// App,
// PrimGraph.Component.Ref[G, C]
// ]
// ) {
// def fn(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Edge[G] =
// PrimGraph.Component.Ref(
// graph.primUnsafeReadFieldByIndex[C, Shape](
// PrimGraph.Component.Refined.unwrap(node).ix,
// 1
// )
// )
//
// def fn_=(value: Edge[G])(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Unit =
// graph.primUnsafeWriteFieldByIndex[C, Shape](
// PrimGraph.Component.Refined.unwrap(node).ix,
// 1,
// value.ix
// )
//
// def arg(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Edge[G] =
// PrimGraph.Component.Ref(
// graph.primUnsafeReadFieldByIndex[C, Shape](
// PrimGraph.Component.Refined.unwrap(node).ix,
// 2
// )
// )
//
// def arg_=(value: Edge[G])(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Unit =
// graph.primUnsafeWriteFieldByIndex[C, Shape](
// PrimGraph.Component.Refined.unwrap(node).ix,
// 2,
// value.ix
// )
//
// def app(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): AppVal[G] = {
// AppVal(
// this.fn,
// this.arg
// )
// }
//
// def app_=(value: AppVal[G])(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Unit = {
// this.fn = value.fn
// this.arg = value.arg
// }
// }
// }
//
// // A centre section
// sealed case class Centre() extends Shape
// sealed case class CentreVal[G <: PrimGraph](fn: Edge[G])
// object Centre {
// val index = 2
// val any =
// PrimGraph.Component.VariantMatcher[Shape, Centre](index)
// implicit def sized =
// new Sized[Centre] { type Out = _1 }
// implicit def indexed =
// new VariantIndexed[Shape, Centre] { val ix = index }
//
// def unapply[G <: PrimGraph, C <: PrimGraph.Component](
// arg: PrimGraph.Component.Ref[G, C]
// )(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Option[scala.Tuple1[Edge[G]]] =
// any.unapply(arg).map(t => scala.Tuple1(t.fn))
//
// implicit class CentreInstance[
// G <: PrimGraph,
// C <: PrimGraph.Component
// ](
// node: PrimGraph.Component.Refined[
// Shape,
// Centre,
// PrimGraph.Component.Ref[G, C]
// ]
// ) {
// def fn(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Edge[G] =
// PrimGraph.Component.Ref(
// graph.primUnsafeReadFieldByIndex[C, Shape](
// PrimGraph.Component.Refined.unwrap(node).ix,
// 1
// )
// )
//
// def fn_=(value: Edge[G])(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Unit =
// graph.primUnsafeWriteFieldByIndex[C, Shape](
// PrimGraph.Component.Refined.unwrap(node).ix,
// 2,
// value.ix
// )
//
// def centre(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): CentreVal[G] = {
// CentreVal(
// this.fn
// )
// )
// }
//
// def centre_=(value: CentreVal[G])(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Unit = {
// this.fn = value.fn
// }
// }
// }
//
// sealed case class Name() extends Shape
// sealed case class NameVal[G <: PrimGraph](
// str: String,
// linkEdge: Edge[G]
// )
// object Name {
// val index = 3
// val any = PrimGraph.Component.VariantMatcher[Shape, Name](index)
// implicit def sized =
// new Sized[Centre] { type Out = _1 } // Due to one field being opaque
// implicit def indexed =
// new VariantIndexed[Shape, Name] { val ix = index }
//
// def unapply[G <: PrimGraph, C <: PrimGraph.Component](
// arg: PrimGraph.Component.Ref[G, C]
// )(
// implicit graph: PrimGraph.GraphData[G],
// map: StrStorage,
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Option[scala.Tuple1[String]] = {
// any.unapply(arg).map(t => scala.Tuple1(t.str))
// }
//
// implicit class NameInstance[
// G <: PrimGraph,
// C <: PrimGraph.Component
// ](
// node: PrimGraph.Component.Refined[
// Shape,
// Name,
// PrimGraph.Component.Ref[G, C]
// ]
// ) {
// def str(
// implicit graph: PrimGraph.GraphData[G],
// map: StrStorage,
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): String = {
// map.str(PrimGraph.Component.Refined.unwrap(node).ix)
// }
//
// def str_=(value: String)(
// implicit graph: PrimGraph.GraphData[G],
// map: StrStorage,
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Unit = {
// map.str(PrimGraph.Component.Refined.unwrap(node).ix) = value
// }
//
// def linkEdge(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Edge[G] = {
// PrimGraph.Component.Ref(
// graph.primUnsafeReadFieldByIndex[C, Shape](
// PrimGraph.Component.Refined.unwrap(node).ix,
// 1 // as the other field is opaque
// )
// )
// }
//
// def linkEdge_=(value: Edge[G])(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Unit = {
// graph.primUnsafeWriteFieldByIndex[C, Shape](
// PrimGraph.Component.Refined.unwrap(node).ix,
// 1,
// value.ix
// )
// }
//
// def name(
// implicit graph: PrimGraph.GraphData[G],
// map: StrStorage,
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): NameVal[G] = {
// NameVal(
// this.str,
// this.linkEdge
// )
// }
//
// def name_=(value: NameVal[G])(
// implicit graph: PrimGraph.GraphData[G],
// map: StrStorage,
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Unit = {
// this.str = value.str
// this.linkEdge = value.linkEdge
// }
// }
// }
// }
@field case class ParentLink[G <: PrimGraph](parent: Edge[G])
// sealed case class ParentLink() extends PrimGraph.Component.Field
// sealed case class ParentLinkVal[G <: PrimGraph](parent: Edge[G])
// object ParentLink {
// implicit def sized =
// new Sized[ParentLink] { type Out = _1 }
//
// implicit class ParentLinkInstance[
// G <: PrimGraph,
// C <: PrimGraph.Component
// ](
// node: PrimGraph.Component.Ref[G, C]
// ) {
// def parent(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, ParentLink]
// ): Edge[G] = {
// PrimGraph.Component.Ref(
// graph.unsafeReadFieldByIndex[C, ParentLink](node.ix, 0)
// )
// }
//
// def parent_=(value: Edge[G])(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, ParentLink]
// ): Unit = {
// graph.unsafeWriteFieldByIndex[C, ParentLink](node.ix, 0, value.ix)
// }
//
// def parentLink(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, ParentLink]
// ): ParentLinkVal[G] = {
// ParentLinkVal(this.parent)
// }
//
// def parentLink_=(value: ParentLinkVal[G])(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, ParentLink]
// ): Unit = {
// this.parent = value.parent
// }
// }
//
// implicit def ParentLink_transInstance[
// F <: PrimGraph.Component.Field,
// R,
// G <: PrimGraph,
// C <: PrimGraph.Component
// ](
// t: PrimGraph.Component.Refined[F, R, PrimGraph.Component.Ref[G, C]]
// ): ParentLinkInstance[G, C] = t.wrapped
// }
@field case class Location[G <: PrimGraph](line: Int, column: Int)
// sealed case class Location() extends PrimGraph.Component.Field;
// sealed case class LocationVal[G <: PrimGraph](line: Int, column: Int)
// object Location {
// implicit def sized =
// new Sized[Location] { type Out = _2 }
//
// implicit class LocationInstance[
// G <: PrimGraph,
// C <: PrimGraph.Component
// ](
// node: PrimGraph.Component.Ref[G, C]
// ) {
// def line(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Location]
// ): Int =
// graph.unsafeReadField[C, Location](node.ix, 0)
//
// def line_=(value: Int)(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Location]
// ): Unit = graph.unsafeWriteFieldByIndex[C, Location](node.ix, 0, value)
//
// def column(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Location]
// ): Int =
// graph.unsafeReadFieldByIndex[C, Location](node.ix, 1)
//
// def column_=(value: Int)(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Location]
// ): Unit = graph.unsafeWriteFieldByIndex[C, Location](node.ix, 1, value)
//
// def location(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Location]
// ): LocationVal[G] =
// LocationVal(this.line, this.column)
//
// def location_=(value: LocationVal[G])(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Location]
// ): Unit = {
// this.line = value.line
// this.column = value.column
// }
// }
//
// implicit def Location_transInstance[
// F <: PrimGraph.Component.Field,
// R,
// G <: PrimGraph,
// C <: PrimGraph.Component
// ](
// t: PrimGraph.Component.Refined[F, R, PrimGraph.Component.Ref[G, C]]
// ): LocationInstance[G, C] = t.wrapped
// }
@field case class Backref[G <: PrimGraph](
references: OpaqueData[Vector[Int], BackrefStorage]
)
// sealed case class Backref() extends PrimGraph.Component.Field
// sealed case class BackrefVal[G <: PrimGraph](references: Vector[Int])
// object Backref {
// implicit def sized =
// new Sized[Backref] { type Out = _0 }
//
// implicit class BackrefInstance[G <: PrimGraph, C <: PrimGraph.Component](
// node: PrimGraph.Component.Ref[G, C]
// ) {
// def references(
// implicit graph: PrimGraph.GraphData[G],
// map: BackrefStorage,
// ev: PrimGraph.HasComponentField[G, C, Backref]
// ): Vector[Int] = {
// map.backref(node.ix)
// }
//
// def references_=(value: Vector[Int])(
// implicit graph: PrimGraph.GraphData[G],
// map: BackrefStorage,
// ev: PrimGraph.HasComponentField[G, C, Backref]
// ): Unit = {
// map.backref(node.ix) = value
// }
//
// def backref(
// implicit graph: PrimGraph.GraphData[G],
// map: BackrefStorage,
// ev: PrimGraph.HasComponentField[G, C, Backref]
// ): BackrefVal[G] = {
// BackrefVal(this.references)
// }
//
// def backref_=(value: BackrefVal[G])(
// implicit graph: PrimGraph.GraphData[G],
// map: BackrefStorage,
// ev: PrimGraph.HasComponentField[G, C, Backref]
// ): Unit = {
// this.references = value.references
// }
//
// implicit def Location_transInstance[
// F <: PrimGraph.Component.Field,
// R,
// G <: PrimGraph,
// C <: PrimGraph.Component
// ](
// t: PrimGraph.Component.Refined[F, R, PrimGraph.Component.Ref[G, C]]
// ): BackrefInstance[G, C] = t.wrapped
// }
// }
}
object Edge {
@field case class Shape[G <: PrimGraph](source: Node[G], target: Node[G])
// sealed case class Shape() extends PrimGraph.Component.Field
// sealed case class ShapeVal[G <: PrimGraph](
// source: Node[G],
// target: Node[G]
// )
// object Shape {
// implicit def sized =
// new Sized[Shape] { type Out = _2 }
//
// implicit class ShapeInstance[G <: PrimGraph, C <: PrimGraph.Component](
// node: PrimGraph.Component.Ref[G, C]
// ) {
// def source(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Node[G] =
// PrimGraph.Component.Ref(
// graph.unsafeReadFieldByIndex[C, Shape](node.ix, 0)
// )
//
// def source_=(value: Node[G])(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Unit =
// graph.unsafeWriteFieldByIndex[C, Shape](node.ix, 0, value.ix)
//
// def target(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Node[G] =
// PrimGraph.Component.Ref(
// graph.unsafeReadFieldByIndex[C, Shape](node.ix, 1)
// )
//
// def target_=(value: Node[G])(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Unit =
// graph.unsafeWriteFieldByIndex[C, Shape](node.ix, 1, value.ix)
//
// def shape(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): ShapeVal[G] = {
// ShapeVal(this.source, this.target)
// }
//
// def shape_=(value: ShapeVal[G])(
// implicit graph: PrimGraph.GraphData[G],
// ev: PrimGraph.HasComponentField[G, C, Shape]
// ): Unit = {
// this.source = value.source
// this.target = value.target
// }
// }
//
// implicit def Shape_transInstance[
// F <: PrimGraph.Component.Field,
// R,
// G <: PrimGraph,
// C <: PrimGraph.Component
// ](
// t: PrimGraph.Component.Refined[F, R, PrimGraph.Component.Ref[G, C]]
// ): ShapeInstance[G, C] = t.wrapped
// }
}
}
}

View File

@ -1,43 +0,0 @@
package org.enso.graph
import org.enso.graph.definition.Macro.opaque
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import shapeless.test.illTyped
import scala.collection.mutable
class OpaqueMacroTest extends AnyFlatSpec with Matchers {
val subject = "The @opaque macro"
subject should "define proper opaque maps" in {
"@opaque case class Backref(opaque: Vector[Int])" should compile
"@opaque case class String(opaque: String)" should compile
}
subject should "error if not passed a class def" in {
illTyped(
"@opaque object Foo",
"You must provide a class definition to the @opaque macro."
)
}
subject should "error if defined with incorrect val members" in {
illTyped(
"@opaque case class String()",
"You must define a constructor member called `opaque` that specifies your opaque type."
)
}
subject should "allow access to its member under the correct name" in {
@opaque case class Backref(opaque: String)
val backrefStorage = BackrefStorage()
val member: mutable.Map[Int, String] = backrefStorage.backref
val testStr = "Foo"
member(0) = testStr
member(0) shouldEqual testStr
}
}

View File

@ -1,104 +0,0 @@
package org.enso.graph
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import shapeless.{::, HNil, Nat}
import shapeless.Nat._
import scala.collection.mutable
class TypeFunctionTest extends AnyFlatSpec with Matchers {
object HListSumTest {
implicitly[HListSum.Aux[HNil, _0]]
implicitly[HListSum.Aux[_1 :: HNil, _1]]
implicitly[HListSum.Aux[_1 :: _2 :: HNil, _3]]
implicitly[HListSum.Aux[_1 :: _2 :: _3 :: HNil, _6]]
}
object HListTakeUntilTest {
case class A()
case class B()
case class C()
case class D[G <: Nat]()
implicitly[HListTakeUntil.Aux[A, HNil, HNil]]
implicitly[HListTakeUntil.Aux[A, A :: B :: C :: HNil, HNil]]
implicitly[HListTakeUntil.Aux[B, A :: B :: C :: HNil, A :: HNil]]
implicitly[HListTakeUntil.Aux[C, A :: B :: C :: HNil, A :: B :: HNil]]
}
object MapSizedTest {
case class A()
case class B()
case class C()
implicit def sizedA: Sized.Aux[A, _1] = new Sized[A] { type Out = _1 }
implicit def sizedB: Sized.Aux[B, _3] = new Sized[B] { type Out = _3 }
implicit def sizedC: Sized.Aux[C, _5] = new Sized[C] { type Out = _5 }
implicitly[MapSized.Aux[HNil, HNil]]
implicitly[MapSized.Aux[A :: B :: C :: HNil, _1 :: _3 :: _5 :: HNil]]
}
object SizeUntilTest {
case class A()
case class B()
case class C()
implicit def sizedA: Sized.Aux[A, _1] = new Sized[A] { type Out = _1 }
implicit def sizedB: Sized.Aux[B, _3] = new Sized[B] { type Out = _3 }
implicit def sizedC: Sized.Aux[C, _5] = new Sized[C] { type Out = _5 }
implicitly[SizeUntil.Aux[A, HNil, _0]]
implicitly[SizeUntil.Aux[A, A :: B :: C :: HNil, _0]]
implicitly[SizeUntil.Aux[B, A :: B :: C :: HNil, _1]]
implicitly[SizeUntil.Aux[C, A :: B :: C :: HNil, _4]]
}
object MapsOfTest {
case class A()
case class B()
case class C()
implicitly[MapsOf.Aux[HNil, HNil]]
implicitly[
MapsOf.Aux[Double :: HNil, mutable.Map[Int, Double] :: HNil]
]
implicitly[MapsOf.Aux[
String :: Double :: HNil,
mutable.Map[Int, String] :: mutable.Map[Int, Double] :: HNil
]]
}
"Generating a HList of Maps" should "work for opaque data" in {
type MyList = String :: Double :: HNil
val test = MapsOf[MyList].instance
test.select[mutable.Map[Int, String]] shouldEqual mutable.Map[Int, String]()
}
"A HList of Maps" should "allow selection by Value type" in {
val mapsOf = MapsOf[String :: Long :: HNil]
val test = MapsOf[String :: Long :: HNil].instance
MapsOf.getOpaqueData[Long, mapsOf.Out](test) shouldEqual mutable
.Map[Int, Long]()
}
"The opaque data maps" should "allow insertion and deletion" in {
val maps = MapsOf[String :: HNil]
val stringMap =
MapsOf.getOpaqueData[String, maps.Out](maps.instance)
val testMap: mutable.Map[Int, String] = mutable.Map()
stringMap(0) = "TestString"
testMap(0) = "TestString"
MapsOf.getOpaqueData[String, maps.Out](maps.instance) shouldEqual testMap
stringMap -= 0
testMap -= 0
MapsOf.getOpaqueData[String, maps.Out](maps.instance) shouldEqual testMap
}
}

View File

@ -1,39 +0,0 @@
package org.enso
import cats.data.NonEmptyList
package object data {
type List1[+T] = NonEmptyList[T]
object List1 {
def apply[T](el: T, tail: List[T]): List1[T] = new List1(el, tail)
def apply[T](el: T, tail: T*): List1[T] = new List1(el, tail.toList)
def apply[T](list: List[T]): Option[List1[T]] = fromListOption(list)
def unapply[T](t: List1[T]): Option[(T, List[T])] = Some((t.head, t.tail))
def fromListOption[T](lst: List[T]): Option[List1[T]] = lst match {
case Nil => None
case t :: ts => Some(List1(t, ts))
}
implicit class List1_ops[+T](lst: List1[T]) {
def mapInit[B >: T](f: T => B): List1[B] =
if (lst.tail.isEmpty) lst
else List1(f(lst.head), lst.tail.init.map(f) :+ lst.tail.last)
def mapLast[B >: T](f: T => B): List1[B] =
if (lst.tail.isEmpty) List1(f(lst.head), lst.tail)
else List1(lst.head, lst.tail.init :+ f(lst.tail.last))
def intersperse[B >: T](t: B): List1[B] =
List1(lst.head, lst.tail.flatMap(s => List(t, s)))
def +:[B >: T](that: List[B]): List1[B] = that match {
case Nil => lst
case s :: ss => List1(s, ss ++ lst.toList)
}
}
}
}

View File

@ -1,48 +0,0 @@
package org.enso.data
import org.enso.data
case class Shifted[+T](off: Int, wrapped: T) {
def map[S](f: T => S): Shifted[S] =
Shifted(off, f(wrapped))
}
object Shifted {
def apply[T](el: T): Shifted[T] = Shifted(0, el)
case class List1[+T](head: T, tail: List[Shifted[T]]) {
def map[S](f: T => S): List1[S] =
List1(f(head), tail.map(_.map(f)))
def toList(off: Int = 0): List[Shifted[T]] =
toList1(off).toList
def toList1(off: Int = 0): data.List1[Shifted[T]] =
data.List1(Shifted(off, head), tail)
def +:[B >: T](t: (Int, B)): List1[B] =
List1(t._2, Shifted(t._1, head) :: tail)
def +:[B >: T](t: Shifted[B]): List1[B] =
List1(t.wrapped, Shifted(t.off, head) :: tail)
def +[B >: T](that: List1[B]): List1[B] =
List1(head, tail ++ that.toList())
def +[B >: T](that: List[Shifted[B]]): List1[B] =
List1(head, tail ++ that)
def :+[B >: T](that: Shifted[B]): List1[B] =
List1(head, tail :+ that)
}
object List1 {
def apply[T](head: T): List1[T] = List1(head, Nil)
implicit def fromTuple[T](t: (T, List[Shifted[T]])): List1[T] =
List1(t._1, t._2)
def fromListDropHead[T](lst: List[Shifted[T]]) =
List1(lst.head.wrapped, lst.tail)
}
}

View File

@ -1,7 +1,5 @@
package org.enso.syntax.text
import cats.Monoid
////////////////////////////////////////////////////////////////////////////////
//// AbsolutePosition //////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
@ -15,24 +13,3 @@ import cats.Monoid
case class Location(start: Int, end: Int) {
def length: Int = end - start
}
object Location {
implicit val optionSpanMonoid: Monoid[Option[Location]] =
new Monoid[Option[Location]] {
def empty: Option[Location] = None
def combine(
x: Option[Location],
y: Option[Location]
): Option[Location] =
x match {
case None => y
case Some(lSpan @ Location(lStart, _)) =>
y match {
case None => Some(lSpan)
case Some(Location(_, rEnd)) =>
Some(Location(lStart, rEnd))
}
}
}
}

View File

@ -1 +0,0 @@
/optics-dev/Monocle/blob/master/LICENSE

View File

@ -1 +0,0 @@
/optics-dev/Monocle/blob/master/LICENSE

View File

@ -1,6 +0,0 @@
Copyright 2009-2017 java-diff-utils.
Copyright 2017 java-diff-utils.
Copyright 2018 java-diff-utils.
Copyright 2019 java-diff-utils.
Copyright 2020 java-diff-utils.
Copyright 2021 java-diff-utils.

View File

@ -1 +0,0 @@
Copyright (C) 2009 - 2017 java-diff-utils

View File

@ -1,11 +0,0 @@
Copyright (c) 2007-2008 Timothy Wall, All Rights Reserved
Copyright (c) 2007-2012 Timothy Wall, All Rights Reserved
Copyright (c) 2007-2013 Timothy Wall, All Rights Reserved
Copyright (c) 2007-2015 Timothy Wall, All Rights Reserved
Copyright (c) 2009 Timothy Wall, All Rights Reserved
Copyright (c) 2011 Timothy Wall, All Rights Reserved
Copyright (c) 2012 Timothy Wall, All Rights Reserved
Copyright (c) 2018 Matthias Bläsing
Copyright (c) 2019 Matthias Bläsing, All Rights Reserved
Copyright (c) 2021, Matthias Bläsing, All Rights Reserved
Copyright 2007 Timothy Wall

View File

@ -1,4 +0,0 @@
Copyright (c) 2007 Timothy Wall, All Rights Reserved
Copyright (c) 2007 Wayne Meissner, All Rights Reserved
Copyright (c) 2017 Matthias Bläsing, All Rights Reserved
Copyright (c) 2022 Carlos Ballesteros, All Rights Reserved

View File

@ -1,11 +0,0 @@
Copyright (C) 2022 the original author(s).
Copyright (c) 2002-2016, the original author or authors.
Copyright (c) 2002-2017, the original author or authors.
Copyright (c) 2002-2018, the original author or authors.
Copyright (c) 2002-2019, the original author or authors.
Copyright (c) 2002-2020, the original author or authors.
Copyright (c) 2002-2021, the original author or authors.
Copyright (c) 2002-2022, the original author or authors.
Copyright (c) 2022, the original author or authors.
regarding copyright ownership. The ASF licenses this file
this work for additional information regarding copyright ownership.

View File

@ -1,2 +0,0 @@
Copyright (C) 2009-2018 the original author(s).
Copyright (c) 2000-2005 Dieter Wimberger

View File

@ -1,10 +0,0 @@
"A footer on every Scaladoc page, by default the EPFL/Lightbend copyright notice. Can be overridden with a custom footer.",
Copyright 2005-2013 LAMP/EPFL
Copyright 2005-2017 LAMP/EPFL and Lightbend, Inc
Copyright 2005-2017 LAMP/EPFL and Lightbend, Inc.
Div(id = "footer", elems = Txt("Scala programming documentation. Copyright (c) 2002-2023 ") :: A(href = "https://www.epfl.ch", target = "_top", elems = Txt("EPFL")) :: Txt(" and ") :: A(href = "https://www.lightbend.com", target = "_top", elems = Txt("Lightbend")) :: Txt("."))
Properties.copyrightString
additional information regarding copyright ownership.
rem # Copyright EPFL and Lightbend, Inc.
rem # additional information regarding copyright ownership.
val versionMsg = s"Scaladoc ${Properties.versionString} -- ${Properties.copyrightString}"

View File

@ -1,2 +0,0 @@
Copyright 2002-2017 LAMP/EPFL and Lightbend, Inc.
Copyright EPFL and Lightbend, Inc.

View File

@ -1 +0,0 @@
See org.typelevel.cats-core_2.13-2.2.0-M3 for notices related to this module.

View File

@ -1 +0,0 @@
Copyright (c) 2015 Typelevel

View File

@ -1 +0,0 @@
See org.typelevel.cats-core_2.13-2.2.0-M3 for notices related to this module.

View File

@ -1 +0,0 @@
/typelevel/cats/blob/main/AUTHORS.md

View File

@ -1 +0,0 @@
/typelevel/cats/blob/main/COPYING

View File

@ -1 +0,0 @@
See org.typelevel.cats-core_2.13-2.2.0-M3 for notices related to this module.

View File

@ -1 +0,0 @@
/typelevel/cats/blob/main/AUTHORS.md

View File

@ -1 +0,0 @@
/typelevel/cats/blob/main/COPYING

View File

@ -1,2 +0,0 @@
Copyright (c) 2015 Miles Sabin
Copyright (c) 2016 Miles Sabin

View File

@ -1,3 +1,3 @@
F71AC5DBF4A656ED73C4C66E137A81B6EC6CA5A415270F1FD17E13498816540C
73FBF5BE43004B2B05E9BF4FFDCE8B46CED8459B9D5FBBC1A6D335917E082999
8318FC8DB8AD68F5E645BD2B7230C9EAC76273B2546C885DC6B2EA46CB8C88E2
34887BA71DCE953A646B7D4B8DA9C67719E4D2C3ECC24F935DADC3BE92671750
0