Ben Woodworth
12/06/2019, 11:42 PM// Defined in a "common" sourceSet
interface Dependency {
// member definitions
}
// Defined in other platform-specific sourceSets, with varying class/package names
@PlatformType
interface PlatformDependency : Dependency {
// more platform-specific member definitions
}
In each platform-specific sourceSet of my codebase, anytime there's a Dependency
instance, it's guaranteed to be a PlatformInstance
. That can be denoted with @PlatformType
, and I want to write a plugin and treats Dependency
types (in this case) as `PlatformDependency`s everywhere within that sourceset. Right now I'm manually upcasting, but that's verbose/tedious. Is this possible/easy-ish to do? And where's a good place for me to start?Imran/Malic
12/06/2019, 11:49 PM@Platform
Ben Woodworth
12/06/2019, 11:58 PMPlatformDependency
. My use case is similar to kotlin multiplatform, except I can't use expect/actual, since all the sourceSets are compiled into a single jar, and the classpaths can't overlap each other.raulraja
12/07/2019, 1:33 AMImran/Malic
12/07/2019, 11:09 AMamanda.hinchman-dominguez
12/07/2019, 7:14 PMBen Woodworth
12/08/2019, 3:26 AMFc...
).
They're all interfaces, though I suppose there could be open classes as well:
https://github.com/BenWoodworth/FastCraft/tree/master/src/common/kotlin/net/benwoodworth/fastcraft/platform
Platform-specific dependencies (named BukkitFc...
).
Some classes/interfaces. These are the ones that'll be marked with @PlatformType
:
https://github.com/BenWoodworth/FastCraft/tree/master/src/bukkit/kotlin/net/benwoodworth/fastcraft/bukkitImran/Malic
12/08/2019, 8:32 PMamanda.hinchman-dominguez
12/08/2019, 9:55 PMBen Woodworth
12/09/2019, 1:30 AMamanda.hinchman-dominguez
12/10/2019, 8:25 AMImran/Malic
12/10/2019, 10:19 AMImran/Malic
12/10/2019, 10:21 AMtype-proofs
.Imran/Malic
12/10/2019, 10:24 AMtype-proof
, here is more: <https://kotlinlang.slack.com/archives/C1JMF6UDV/p1574244934048100?thread_ts=1574092607.040600&cid=C1JMF6UDV>.Imran/Malic
12/10/2019, 10:35 AMF
and all itโs platform specific abstractions G
, H
, etc..Imran/Malic
12/10/2019, 10:41 AMMeta
Imran/Malic
12/10/2019, 11:03 AMtype-proofs
and rolling your own typeclass
so those functions from below are auto-generated by the compiler.Imran/Malic
12/10/2019, 11:07 AMSemigroup
looks like.
Btw, super awesome Minecraft plugin. @raulraja you should check it out here <https://www.spigotmc.org/resources/fastcraft.20544/>Imran/Malic
12/10/2019, 11:10 AMamanda.hinchman-dominguez
12/10/2019, 11:15 AMamanda.hinchman-dominguez
12/10/2019, 11:15 AMamanda.hinchman-dominguez
12/10/2019, 11:16 AMImran/Malic
12/10/2019, 11:20 AMraulraja
12/10/2019, 11:59 AMraulraja
12/10/2019, 12:00 PMraulraja
12/10/2019, 12:00 PMImran/Malic
12/10/2019, 12:01 PMImran/Malic
12/10/2019, 12:02 PMquotes
can do the same.amanda.hinchman-dominguez
12/10/2019, 12:03 PMBen Woodworth
12/10/2019, 9:43 PMI think the main question I kind of have at the moment is the motivation behind using annotations to create a proof...If you mean why I have
@PlatformType
, that's just the first idea that came to mind, so the classes/interfaces could be easily identified. But that's just because I've used them in the past for annotation processing and code generation. I'm definitely interested in seeing what other options there are!!
@Imran/Malic
Type proofs have crossed my mind (as well as using contracts somehow), but I didn't realize they could be defined concretely with @Proof
annotations. I'm excited to see that be released, because it seems like a powerful tool I could make use of!
As for quotes
, I'm not sure I know what that is precisely. Is that related to the hello world plugin, where a function definition is substituted with Kotlin code within a string? And how would I make use of them here?raulraja
12/10/2019, 10:13 PMraulraja
12/10/2019, 10:14 PMraulraja
12/10/2019, 10:15 PMamanda.hinchman-dominguez
12/11/2019, 3:58 PMamanda.hinchman-dominguez
12/11/2019, 3:58 PMamanda.hinchman-dominguez
12/11/2019, 4:05 PMprivate fun ElementScope.toFlatMap(
bind: KtProperty,
remaining: List<KtExpression>): Scope<KtExpression> {
return """|${source}.flatMap { $argName $typeName ->
| ${toFlatMap(remaining)}
|}""".expression
}
amanda.hinchman-dominguez
12/11/2019, 4:06 PMBen Woodworth
12/11/2019, 10:29 PMamanda.hinchman-dominguez
12/11/2019, 10:30 PM