• raulraja

    raulraja

    3 years ago
    Thanks!
    raulraja
    1 replies
    Copy to Clipboard
  • Imran/Malic

    Imran/Malic

    3 years ago
    @dmitriy.novozhilov Do you know how I can get the import for org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices. It is not in the kotlin-compiler-embeddable artefact
    Imran/Malic
    dmitriy.novozhilov
    3 replies
    Copy to Clipboard
  • Imran/Malic

    Imran/Malic

    3 years ago
    Or should we just go deeper in the resources meaning instead of
    compile "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version"
    we do:
    api "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlin_version"
    Imran/Malic
    2 replies
    Copy to Clipboard
  • raulraja

    raulraja

    3 years ago
    I discussed this internally but thought I’d keep everyone in the loop here too: Here is a preliminary design of what enabling QuasiQuote support over a Compiler Descriptor may look like: https://github.com/47deg/arrow-meta-prototype/compare/rr-tree-quotes-poc#diff-109f0a910d70fe85c5eea3bc6dce4775 That is the basic algebra with an embedded function that exercises the steps it takes to transforms a string into a descriptor tree then back. Supporting then an individual descriptor like ValueParameters may look like this: https://github.com/47deg/arrow-meta-prototype/compare/rr-tree-quotes-poc#diff-21516eec047a3b472606f772e9accd8d Essentially if we implement this algebra for each Declaration Descriptor that there is out there matching the different KtElements and strategies to update or create under a parent then we can support quasiquotes in Kotlin in the
    syntheticResolver
    . Where users do something like:
    func({
      "fun <$typeArgs> $name($params): $returnType = $body" //find
    }) { fn ->
      "fun <$typeArgs> $name($params): $returnType = $body" //transform
    }
    In this case that would be the identity element for the
    ValueParameter
    declaration quote. This is in a similar way the quasiquote style syntax that scala-meta uses and much easier for most use cases to develop compiler plugins in comparison with the compiler internals, descriptor and phases we have to deal today. Say you had a use case to add logging to all functions named
    foo
    that return
    Unit
    . This will be the expression that satisfies that use case in a compiler plugin:
    func({
      "fun <$typeArgs> foo($params): Unit = $body" //find
    }) { fn ->
      "fun <$typeArgs> $name($params): $returnType { 
          println("inside foo: Unit")
          return $body" 
      }
    }
    raulraja
    Imran/Malic
    +1
    6 replies
    Copy to Clipboard
  • raulraja

    raulraja

    3 years ago
  • raulraja

    raulraja

    3 years ago
    The TC plugin automatically finds the factory that will be used as expression if found in the type class package, the data type package or in the local modules if flagged as
    internal
    raulraja
    h
    +1
    17 replies
    Copy to Clipboard
  • shikasd

    shikasd

    3 years ago
    Did you explore possible solutions for debugging generated code?
    shikasd
    raulraja
    4 replies
    Copy to Clipboard
  • shikasd

    shikasd

    3 years ago
    Hey, as a followup to my message above: If you are generating new files in the
    build
    folder (and mark them in gradle) instead of appending to already existing ones, debug seems to work out of the box I have implemented POC to entertain the idea - https://github.com/ShikaSD/kotlin-compiler-di/commit/b7c7f77f5b0b1436e7107421f21fcb6f1910cf88
    shikasd
    h
    7 replies
    Copy to Clipboard
  • Imran/Malic

    Imran/Malic

    3 years ago
    In Addition to our current compiler plugins we’d like to present
    autofold
    , which will give you an automatic fold function over valid GADT/ ADT in vanilla Kotlin at compile time.
    sealed class A
    
    data class B(val x: Int) : A()
    data class C(val x: Int) : A()
    object D : A()
    
    sealed class Expr<out A, B>
    data class Const(val number: Double) : Expr<Nothing, Double>()
    data class Sum<C>(val e1: Expr<Int, C>, val e2: Expr<Int, C>) : Expr<Int, C>()
    object NotANumber : Expr<Nothing, Nothing>()
    fun syntheticExprFold(): Int =
        Sum(
          e1 = Const(3.0),
          e2 = Const(2.1)
        ).fold(
          { c: Const -> c.number.toInt() },
          { _: Sum<Double> -> 0 },
          { 94 }
        )
    
    fun syntheticAFold(): Int =
        B(44).fold(
          { b: B -> b.x * b.x },
          { c: C -> c.x - c.x },
          { 0 }
        )
    Here is the code: https://github.com/47deg/arrow-meta-prototype/blob/master/compiler-plugin/src/main/kotlin/arrow/meta/autofold/AutoFoldPlugin.kt :arrow:
    Imran/Malic
    1 replies
    Copy to Clipboard
  • simon.vergauwen

    simon.vergauwen

    3 years ago
    @Bob Glamm
    simon.vergauwen
    Bob Glamm
    +1
    8 replies
    Copy to Clipboard