GithubHelp home page GithubHelp logo

Comments (3)

sugarmanz avatar sugarmanz commented on June 1, 2024

https://kotlinlang.slack.com/archives/CJ699L62W/p1647637345993219?thread_ts=1647621597.259189&cid=CJ699L62W

Arrow Meta dropped support for generating source from typed quotes after deprecating the Proofs plugin that I linked before:
arrow-kt/arrow-meta#969

Thus, we should look into alternatives. The simple recommendation in KSP, although that still doesn't support in-place modification of source, nor first class IDE support. Both problems with the Arrow Meta implementation, so could be sufficient. We could always build a proper compiler plugin, but that has a bit more complexity and removes the benefits of KSP.

KSP will likely be the first path of investigation.

from hooks.

sugarmanz avatar sugarmanz commented on June 1, 2024

KSP seemed to be going well upon initial analysis. However, there seems to be an incompatibility with how we determine the type of the generated hook. We use the actual expression to determine to the types to pull out and combine with the context param:

val ktCallExpression = property.initializer as? KtCallExpression

KSP doesn't seem to support this claiming it is beyond their scope:
google/ksp#136 (comment)

I started thinking about ways to get around this:

  1. Do some reified type magic in DSL helper. I don't know if this is actually possible. Dynamically building a return type from input type parameter type parameters?
    protected inline fun <reified R, reified FWithoutContext : Function<R>, FWithContext : Function<R>> syncHook2(): SyncHook<FWithContext> {
        // pls ignore this 
        val fWithoutContext = FWithoutContext::class
        val fWithoutContextType = typeOf<FWithoutContext>()
        return syncHook(fWithoutContext)
    }
  1. Instead of method helpers, try annotation helpers:
public abstract class Hooks : HooksDsl() {

    @Sync<(newSpeed: Int) -> Unit>()
    public abstract val accelerate: SyncHook<*>
}

(Which is what I ended up going with for now)

from hooks.

sugarmanz avatar sugarmanz commented on June 1, 2024

Closed with #24

from hooks.

Related Issues (9)

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.