Giter Site home page Giter Site logo

dotty-macro-examples's People

Contributors

anatoliykmetyuk avatar bishabosha avatar cchantep avatar jlareck avatar liufengyun avatar nicolasstucki avatar ritschwumm avatar shapelesscat avatar wangzaixiang avatar yuriymazepin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dotty-macro-examples's Issues

A ternary operator example wanted

Could it be possible with Dotty to write some macro for ternary operator that would replace

A ? B : C

by

if (A)
  B
else
  C

without adding an overhead in runtime?

Expand case class default values example

Hi,

I think this defaultParamsInference is a great example I'd like to extend further to include the type of each case class field.

What amazes me is I didn't realize you can cast a Tree as you do here:
https://github.com/lampepfl/dotty-macro-examples/blob/main/defaultParamsInference/src/macro.scala#L18

I thought I would need to use the Symbol's signature to get the type but I don't see a lot of documentation for signature or how to access type information (such as individually selecting types from higher orders, such as List[Int], as enabled in scala 2 by typeSignature or scala.reflect.macros.Context.typeCheck).

So can someone please clarify how tree or signature can be used to get detailed type information for each case class field?

Thanks!

Fail to update the version to 3.0.0

I try to update the version to 3.0.0 in build.sc:

def scalaVersion = "3.0.0"

When try to run mill abstractTypeclassBody.run I see:

[20/38] abstractTypeclassBody.resolvedIvyDeps | Downloading [2/2] artifacts (~0/0 bytes)
1 targets failed
abstractTypeclassBody.resolvedIvyDeps 
Resolution failed for 1 modules:
--------------------------------------------
  org.scala-lang:scala3-library_3.0:3.0.0 
	not found: /home/shapeless-cat/.ivy2/local/org.scala-lang/scala3-library_3.0/3.0.0/ivys/ivy.xml
	not found: https://repo1.maven.org/maven2/org/scala-lang/scala3-library_3.0/3.0.0/scala3-library_3.0-3.0.0.pom

Instantiate a class from a Map

May you add the example: instantiate a class from a Map

    case class Foo(a: Int, c: String)
    val params: Map[String, String] = Map("a" -> "1", "c" -> "hi")
    fromParams[Foo](params) // Right(Foo(1, "hi")))

nice to have example

It would be nice to have an example where a macro runs inside a function, but it returns a tuple of the function name and an Object that has the parameters as vals and the parameter values as typed values.

def blah(x: Int, y: String, z: Float) =
  val (name, params) = functionMacro
  println("x value in function $name is ${params.x}")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.