https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
arrow-meta
  • i

    Imran/Malic

    05/08/2019, 2:45 PM
    This is what I got with the PSI approach:
    a
    • 2
    • 9
  • r

    raulraja

    06/20/2019, 10:09 AM
    https://github.com/47deg/arrow-meta-prototype/blob/master/compiler-plugin/src/main/java/arrow/meta/extensions/MetaCompilerPlugin.kt#L396-L400
    k
    • 2
    • 3
  • d

    dsavvinov

    06/20/2019, 10:15 AM
    Hi folks! First of all, a few little disclaimers: I will try my best to react in a timely manner on your questions, but, unfortunately, I cannot guarantee that discussions won’t hang from time to time on my side (especially, initially, when I have to dive into the context). Also, just to be clear, I’m operating here completely out of my curiosity about your work and wish to help. All my advices and suggestions shouldn’t be treated as an official support from Kotlin Team, nor as an encouragement to write compiler plugins. Compiler API is still unstable, no guarantees are made about it, we are not responsible for any issues and poor UX with it, blah-blah-blah, you get it 🙂 Here, I’m just a guy who happens to know a bit how Kotlin Compiler works
    👍 6
    s
    • 2
    • 1
  • s

    simon.vergauwen

    06/21/2019, 3:57 PM
    And currently there are no plans on this changing, correct? It's poor UX for any user of any mpp library that includes any meta, no? I think has been asked already but it wasn't 100% clear to me if there was any ongoing discussion or plans to improve this. Also there is any (public) road map for plugins?
    d
    • 2
    • 1
  • r

    raulraja

    06/21/2019, 6:05 PM
    Someone in the channel mentioned that there is a way to Shadow the jar of the compiler plugin so the same sources can be used for the IDEA one and avoid two different modules. Is that something that makes sense or you'd recommend?
    d
    • 2
    • 1
  • r

    raulraja

    06/22/2019, 8:38 PM
    why I essentially want is an implicit type conversion which currently is workaround with a cast even though we have proof that OptionOf is only extended by Option
    d
    • 2
    • 15
  • r

    raulraja

    06/23/2019, 11:59 PM
    @dsavvinov @dmitriy.novozhilov in case any of you can help with the reason and alternatives. I’m getting this error when attempting to modify a Psi node in the `SyntenthicResolverExtensions.generateSyntheticClasses(PackageDescriptor...)`:
    Caused by: java.util.MissingResourceException: Can't find bundle for base name messages.PsiBundle, locale en_GB
    	at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1581)
    	at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1396)
    	at java.util.ResourceBundle.getBundle(ResourceBundle.java:782)
    	at org.jetbrains.kotlin.com.intellij.psi.PsiBundle.getBundle(PsiBundle.java:45)
    	at org.jetbrains.kotlin.com.intellij.psi.PsiBundle.message(PsiBundle.java:33)
    	at org.jetbrains.kotlin.com.intellij.psi.impl.CheckUtil.checkWritable(CheckUtil.java:47)
    	at org.jetbrains.kotlin.com.intellij.extapi.psi.ASTDelegatePsiElement.replace(ASTDelegatePsiElement.java:371)
    k
    • 2
    • 2
  • r

    raulraja

    06/24/2019, 12:01 AM
    Seems like any calls to
    replace
    or
    astReplace
    in any psi element fails with similar errors. Is there a way with compiler plugins to modify the PsiElements to make adjustments and replacements before it goes into type checking and generation?
    a
    • 2
    • 5
  • r

    raulraja

    06/25/2019, 11:59 PM
    @dsavvinov @dmitriy.novozhilov or others that may know, I’m implementing the KEEP-87 as a compiler plugin to see if its possible in arrow meta. I’m attempting currently to get a hold of the resolver of the function injected with
    @with
    to enhance the scope resolution of that function so it takes in account the
    Semigroup<A>
    type to resolve
    combine
    without the need to wrap the body in
    with (S) { a.combine(b) }
    . What part of the compiler do I need to look into to avoid the
    unresolved reference: combine
    ? In the actual Keep impl this happens in the
    BodyResolver
    but not sure how to get to that point in a compiler plugin. Any help or pointers in the right direction is appreciated.
    d
    • 2
    • 4
  • r

    raulraja

    06/26/2019, 12:03 PM
    Can a compiler plugin suppress or intercept the diagnostic for
    NoValueForParameter
    similar to how it was done in the KEEP https://github.com/arrow-kt/kotlin/pull/6/files#diff-792252e1fcae31609d7348297b7c45f4R46 ?
    🇳🇴 1
    • 1
    • 1
  • r

    raulraja

    06/28/2019, 7:03 PM
    Thanks!
    d
    • 2
    • 1
  • i

    Imran/Malic

    06/29/2019, 12:06 PM
    @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
    d
    • 2
    • 3
  • i

    Imran/Malic

    06/29/2019, 12:07 PM
    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"
    • 1
    • 2
  • r

    raulraja

    07/06/2019, 9:59 AM
    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" 
      }
    }
    👏🏻 5
    i
    h
    • 3
    • 6
  • r

    raulraja

    07/17/2019, 12:30 AM
    implicit_cast_for_kinded_values_replaces___fix___.kt
    🤯 1
    k
    • 2
    • 5
  • r

    raulraja

    07/27/2019, 4:45 AM
    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
    h
    s
    • 3
    • 17
  • s

    shikasd

    07/31/2019, 1:16 AM
    Did you explore possible solutions for debugging generated code?
    r
    • 2
    • 4
  • s

    shikasd

    08/08/2019, 1:01 AM
    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
    h
    • 2
    • 7
  • i

    Imran/Malic

    08/23/2019, 8:22 AM
    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:
    • 1
    • 1
  • s

    simon.vergauwen

    09/05/2019, 1:11 PM
    @Bob Glamm
    b
    r
    • 3
    • 8
  • s

    shikasd

    09/11/2019, 3:31 PM
    @raulraja Hey, I have seen you adding some extensions for PackageFragmentProvider. Did you find any use for those extensions in terms of providing additional files? I was trying to generate some synthetic descriptors using it, but failed miserably with lots of recursion errors.
    r
    • 2
    • 12
  • r

    raulraja

    09/15/2019, 8:39 PM
    More related progress, the type-class plugin is working in my local branch in both CLI and IDE augmenting function scopes
    typeclass_function_enhanced_scope_resolution.mov
    ❤️ 1
    f
    t
    • 3
    • 6
  • t

    thanh

    09/16/2019, 10:25 AM
    I have one question about the plugin, If I have a library that uses arrow-meta plugin, when an app uses my library, does it need to use arrow-meta as well?
    s
    r
    • 3
    • 4
  • t

    thanh

    09/19/2019, 6:17 AM
    Hey Raul, could you please help me to build and run your branch? I'd like to play around and maybe work on in later. Thanks!
    👍 2
    🔝 1
    r
    • 2
    • 34
  • r

    raulraja

    09/19/2019, 9:51 AM
    Looking forward to meeting you there 🍻
    🍻 4
    🍺 5
    🚰 1
    t
    • 2
    • 1
  • r

    raulraja

    09/30/2019, 12:14 AM
    @pakoito or anyone that can help rewriting some suspension so it works in IR…. We have an issue with Meta, the IR format and some of the stuff we have in the Arrow code base. Seems like IR is not complete even for JVM and does not support certain things we seem to use in Arrow. 1. Type aliases like Validated.Valid / Validated.Invalid declared in the same file that point to an inner class is one of them. This easy to resolve because those type aliases wouldn’t need to be there if Valid and Invalid weren’t nested. I got passed this issue refactoring Valid and Invalid to be top level. 2. suspended anonymous functions like this one fail to find their context:
    fun <B> bindingFilter(c: suspend MonadFilterSyntax<F>.() -> B): Kind<F, B> {
        val continuation = MonadFilterContinuation<F, B>(this)
        val wrapReturn: suspend MonadFilterSyntax<F>.() -> Kind<F, B> = { just(c()) }
        wrapReturn.startCoroutine(continuation, continuation)
        return continuation.returnedMonad()
      }
    In this function IR codegen freaks out with :
    { just(c()) }
    getting into this error: https://github.com/JetBrains/kotlin/blob/9c9d2b5ad4ac27a0792d3cf4c62599fb3e09ebbb/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt#L420 Seems like IR is unable to deal with suspended lambdas like this one. While I still have work in the comprehension plugin which will get rid of this problem all together I wonder if there is a way to rewrite that so that is not a suspended lambda.
    s
    p
    • 3
    • 2
  • r

    raulraja

    10/08/2019, 4:28 PM
    May be a good first compiler contribution if someone is interested. My guess is that they don’t handle in the impl correctly the fact that the function is suspended and it runs into an NPE
    k
    • 2
    • 7
  • j

    Joachim Ansorg

    10/15/2019, 1:32 PM
    @Imran/Malic cc @raulraja https://github.com/arrow-kt/arrow/pull/1713 is a wip pull request to add test support to the Arrow IntelliJ plugin. This will only be useful when the metadata generation has been implemented. Let me know if this proposal makes sense at all or if you have questions about it.
    👏 2
    i
    r
    • 3
    • 3
  • k

    kitttn

    10/16/2019, 4:15 PM
    Hi guys. Wanted to play around meta plugin this weekend, but it looks like it’s archived on GH (https://github.com/arrow-kt/arrow-meta-prototype, from channel header). Any updated links to compile and test?
    r
    • 2
    • 3
  • i

    Imran/Malic

    10/21/2019, 3:06 PM
    As an example if you want to write your own version of the typeclass- plugin you would start defining a costume HKT plugin before you start your implementation. Without HKT you will gain littel with Typeclasses.
    💯 1
    a
    • 2
    • 3
Powered by Linen
Title
i

Imran/Malic

10/21/2019, 3:06 PM
As an example if you want to write your own version of the typeclass- plugin you would start defining a costume HKT plugin before you start your implementation. Without HKT you will gain littel with Typeclasses.
💯 1
a

amanda.hinchman-dominguez

10/21/2019, 3:10 PM
that is taken care of when you list the order of plugins being used in
MetaPlugin
, yeah?
i

Imran/Malic

10/21/2019, 3:11 PM
I dont understand your question.
a

amanda.hinchman-dominguez

10/21/2019, 3:12 PM
Okay - write your own version of typeclasses-plugin. Could you do something like
open class MetaPlugin : Meta {
  @ExperimentalContracts
  override fun intercept(ctx: CompilerContext): List<Plugin> =
    listOf(
      customHTK,
      typeClasses,
      comprehensions,
      lenses
    )
}
View count: 1