kind-projector | Compiler plugin for making type lambdas
kandi X-RAY | kind-projector Summary
kandi X-RAY | kind-projector Summary
One piece of Scala syntactic noise that often trips people up is the use of type projections to implement anonymous, partially-applied types. For example:. Many people have wished for a better way to do this. The goal of this plugin is to add a syntax for type lambdas. We do this by rewriting syntactically valid programs into new programs, letting us seem to add new keywords to the language. This is achieved through a compiler plugin performing an (un-typed) tree transformation.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of kind-projector
kind-projector Key Features
kind-projector Examples and Code Snippets
Community Discussions
Trending Discussions on kind-projector
QUESTION
I am trying to set different versions for the dependencies and plugins on my build.sbt
script, depending the value of the scalaVersion
on a crossCompiled
project.
Here is a reduced and simplified representation of what I have so far:
...ANSWER
Answered 2021-Nov-04 at 20:07Regarding the libraries, an approach that I've often seen in projects is to do it like this:
QUESTION
I'm migrating some scalaz based code to typelevel cats.
project/plugins.sbt
...ANSWER
Answered 2021-May-27 at 22:58The idiomatic way to write that would be this:
QUESTION
I have a project which depends on https://github.com/typelevel/kind-projector and is currently cross-compiled against scala 2.12 and 2.13, and I want to add support for scala 3.0. However, kind-projector is not available on scala 3.0 since the syntax it enables is part of the native scala 3 syntax.
Before, I used this setting to add the compiler plugin:
...ANSWER
Answered 2021-May-18 at 12:25addCompilerPlugin
is a shortcut for libraryDependencies += compilerPlugin(dependency)
Thus, it should work with something like this
QUESTION
I wonder what is the difference between the two here:
...ANSWER
Answered 2021-Mar-04 at 14:35I am pretty sure they are the same.
From Overriding the publishing convention:
crossVersion setting can override the publishing convention:
CrossVersion.disabled
(no suffix)CrossVersion.binary
(_)CrossVersion.full
(_)The default is either
CrossVersion.binary
orCrossVersion.diabled
depending on the value of crossPaths.
From More about using cross-built libraries:
These are equivalent:
QUESTION
I am trying to understand why Adding sbt plugins in plugins.sbt in the project, works perfectly fine, but if I add the compiler plugins in that file it does not work ?
I thought any .sbt or .scala file in project, is made available for the build definition.
The only place where compiler plugins works is in the build.sbt. Hence i am confused as to why ?
In particular i am working with Kind-Projector
...ANSWER
Answered 2021-Feb-19 at 16:50Remeber sbt is recursive.
.sbt
define things that are available in the current layer.
.scala
files define thins that will be available in the next layer.
Adding an sbt plugin in project/bar.sbt
is adding that plugin to the meta layer, as such the meta-layer that compiles the sbt you are using to compile your project adds those plugins to the next sbt layer.
So if you add a compiler plugin in project/foo.sbt
then you are adding that compiler plugin to the compiler used to compile the project (meta) layer of sbt, but it will not be available in the current layer of sbt. That is the reason why compiler plugins are added in the build.sbt
file, so they are added to the compiler used to compile your code.
QUESTION
I am writing a compiler plugin to rewrite a function definition as a tuple of the function hash + function body
So the following
...ANSWER
Answered 2020-Dec-20 at 15:56Thanks to @SethTisue for answering in the comments. I am writing up a answer for anybody who might face a similar issue in the future.
As Seth mentioned, using mkTuple
was the right way to go. In order to use it, you need the following import
QUESTION
I am trying to use https://github.com/estatico/scala-newtype as follows:
...ANSWER
Answered 2020-Jun-20 at 19:07The README.md of scala-newtype says:
This expands into a type and companion object definition, so newtypes must be defined in an object or package object.
Macros are allowed to expand classes into other classes with the same name and companion objects, but from what I can tell, the newtype
annotation turns your case class
into an object of the same name (along with a type alias like type DbUrl = DbUrl.Type
). This behavior (turning a top-level annottee into a tree of some other kind) isn't allowed. If the annotation had generated a class DbUrl
, and maybe an object of the same name, though, it would have been all right, but pretty much anything else won't work.
To fix your problem, all you need to do is move this into a package object (or some other scope, as long as it isn't top-level).
Edit: As Dmytro Mitin pointed out, the created type is not the type of DbUrl
but rather something like type DbUrl = DbUrl.Type
with an uppercase "T", where the definition of DbUrl.Type
looks something like this (I'm just copying this from the README):
QUESTION
I would like to compile via sbt to WAR instead of JAR file and I followed this guide.
I have changed the build.sbt
to:
ANSWER
Answered 2020-May-23 at 23:43There is a bug in documentation - see https://github.com/sbt/sbt/issues/4490
Try using dedicated sbt plugin - xsbt-web-plugin - instead of reading that website. According to current docs you need to add to project/plugins.sbt
QUESTION
I have created a web app and when I try to run with sbt run
, it shows:
ANSWER
Answered 2020-May-23 at 22:20You don't have a main class, the entrypoint to your program defined. On JVM you have to have at least one class which defines
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install kind-projector
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page