47degrees / helios Goto Github PK
View Code? Open in Web Editor NEWA purely functional JSON library for Kotlin built on Λrrow
Home Page: https://47deg.github.io/helios
License: Apache License 2.0
A purely functional JSON library for Kotlin built on Λrrow
Home Page: https://47deg.github.io/helios
License: Apache License 2.0
After #50 was merged we will have the current Helios benchmarking.
We also want to add the Benchmarks comparing it with the other libraries (executeBenchmarks
task will give us that) and upload it as part of the CI on the same way master_benchmark
does.
We want to move from detekt
to klint
as Arrow already did
Both modules helios-meta and helios-dsl-meta are so similar so can be joined on a single one
We faced some problems retrieving the GitHub token from Travis. This apparently doesn't work with external contributors when they try to merge from a fork
.
Source: https://travis-ci.org/47deg/helios/jobs/547077103
As a temporary fix, we could look into the properties and use compareBenchmark
if the CI task is not available.
Pending on: 47degrees/hood#29
We need to add support for all the java time types like Instant
and ZonedDateTime
Hi,
We play with nullable types, eg: val a: String?
inside our data class. However generated code as well as simple test snippet results in StackOverflowError:
"Nullable String element" {
val str: String? = "abc"
val js: Json = NullableEncoderInstance<String>(String.encoder()).run {
str.encode()
}
println(js)
}
It looks like NullableEncoderInstance cannot see encode
extension function of the enclosed encoder:
override fun A?.encode(): Json =
this?.let { a -> encoderA().let { a.encode() } } ?: JsNull
We can add on the ktor repo an integration for helios
We need to add support for the java time types to be used as keys in Maps adding their KeyDecoder
and KeyEncoder
.
After #48 was merged we need to use the json benchmark and delete the saved master benchmarks.
Also as part of this ticket, we want to clone the repo from the master branch and execute its benchmarks as part of the ci.
We can add on the retrofit repo an integration for helios
When using Option following code is generated for decoder:
value["items"].fold({Either.Left(KeyNotFound("items"))}, { arrow.core.Option.Companion.decoder(ListDecoderInstance(kotlin.String.decoder())).run { decode(it) } }),
So when "items" are not in the JSON error is returned despite using Option (which should allow not only values with null, but also non existing values).
We should add to the project description the URL to the new microsite deployed on Github pages
From 2.x.x to 3.x.x.
The test should use the JUnit runner with the new version
More info here : https://github.com/kotlintest/kotlintest
https://github.com/kotlintest/kotlintest/blob/master/doc/arrow-matchers.md
The annotation processor generates invalid code for sealed classes.
This code:
@json
sealed class LinkType {
object Rotary : LinkType()
object Prismatic : LinkType()
companion object
}
Generates this:
fun LinkType.toJson(): Json = JsObject(mapOf())
fun Json.Companion.toLinkType(value: Json): Either<DecodingError, LinkType> =
Either.applicative<DecodingError>().map(
, { ->
LinkType()
}).fix()
fun LinkType.Companion.encoder() = object : Encoder<LinkType> {
override fun LinkType.encode(): Json = this.toJson()
}
fun LinkType.Companion.decoder() = object : Decoder<LinkType> {
override fun decode(value: Json): Either<DecodingError, LinkType> =
Json.toLinkType(value)
}
Apart from the issue with the call to map()
, it's not possible to construct a LinkType
because it is a sealed class.
Helios deploy setting needs to be fixed and added to the CI according to Hood CI setting https://github.com/47deg/hood/blob/master/.travis.yml
I'm hitting the following error while generating decoders
[kapt] An exception occurred: java.lang.NoSuchMethodError: helios.meta.compiler.json.JsonElement.getPairs()Ljava/util/List;
I'm using helios in androidTests with the following dependencies:
androidTestImplementation "com.47deg:helios-core:0.2.0"
kaptAndroidTest "com.47deg:helios-dsl-meta:0.2.0"
androidTestImplementation "com.47deg:helios-integration-retrofit:0.2.0"
kaptAndroidTest "com.47deg:helios-meta:0.2.0"
androidTestImplementation "com.47deg:helios-optics:0.2.0"
androidTestImplementation "com.47deg:helios-parser:0.2.0"
And the data class I'm trying to generate a decoder for is:
@Serializable
@JsonClass(generateAdapter = true)
@json
data class CodeGeneratedNetworkResponse(
val users: List<NetworkUser>,
val status: String? = null,
@SerialName("is_real_json")
@Json(name = "is_real_json")
val isRealJson: Boolean = false
) {
companion object
}
The AsyncParser needs to be updated deleting the try catch and using Arrow Try
Currently JsDecimal
is just only used for BigInteger
and BigDecimal
and all the other types Int
, Long
... extends from the Number
interface.
If we use JsNumber
for the Number
interface we can reduce a lot of boilerplate without losing compatibility between them.
We need to add a CI for the PRs and maybe also for releases
We want to review the codecs in order to find performance improvements related to them
We should avoid deploying on upload commits. All those commits are done by 47degdev
so we can filter by this on the travis.yml
Polish up JsonPath
to be more like new arrow-optics DSL.
I tried to this on the sidebar.yml
:
- title: Integrations
nested_options:
- title: Retrofit
url: /docs/integrations/retrofit/
but it didn't work. I looked into the Arrow repo and that should be fine. Any clue @calvellido?
Related to #13
There is a problem lied with the meta compiler. More specifically when generating encoders/decoders for product types that depend on other encoders/decoders such as List<String>
or Option< List<String>>
.
@json data class Friend(val _id: String, val tags: List<String>)
@json data class SpecialFriend(val _id: String, val errorOrTags: Option< List<String>>)
We need to investigate how to safely generate encoders for these product types.
We will create a brand + basic microsite template
Related to this we could improve the name of the json errors
Now, kotlin has its own serializer for json https://github.com/Kotlin/kotlinx.serialization.
Would be awesome to include it into the benchmark comparison
The @json
annotation can only be used on data classes. I don't see why helios shouldn't support enum
types as well. The enum value can be encoded as a String
.
I will create a Jekyll site
The following link referenced in the Quickstart page is dead
https://github.com/47deg/helios/tree/master/helios-sample/src/main/kotlin/helios/sample
Currently, we have Arrow 0.6.2
There are so many changes and package modification from that version so, be careful doing this
We can add on the http4k repo an integration for helios
Gradle 4.2 -> 4.10.2
Gradle version plugins 0.17.0 -> 0.20.0
A data class which contains a member which is a typealias
causes the generated code to be invalid.
This code:
typealias Foo = Either<String, Int>
@json
data class DataClass1(
val foo: Foo
) {
companion object
}
Generates this:
fun DataClass1.toJson(): Json = JsObject(mapOf(
"foo" to com.octogonapus.heliosdemo.Foo.encoder().run { foo.encode() }
))
foo.encode()
is an unresolved reference.
Changing the data class to:
@json
data class DataClass1(
val foo: Either<String, Int>
) {
companion object
}
Generates this, which compiles fine:
fun DataClass1.toJson(): Json = JsObject(mapOf(
"foo" to arrow.core.Either.Companion.encoder(kotlin.String.encoder(), kotlin.Int.encoder()).run { foo.encode() }
))
There is a sample project containing this code here https://github.com/Octogonapus/helios-demo/tree/typealias_issue (specifically on branch typealias_issue
).
We successfully publish releases but there is an error with the snapshot publish process
We have new Arrow version 0.10.0 now. So it's time to update Arrow.
I would love to work on that if you think that's okay.
This generated file (https://pastebin.com/vM1vCkwr) depends on another generated file (https://pastebin.com/2gWXjBbU). Both files are emitted into the same folder on disk, but their package
statements differ, causing the former file to need import statements for the encoder & decoder methods in the latter file. Without these import statements, the former file fails to compile.
We need to fix the css styles in the header button and features in the home section.
There are no default encoder()
and decoder()
functions for array types (Array<T>
, DoubleArray
, etc.). It looks like these were not added because the array types do not have companion objects. I think helios should still have functions for them, though. For example, here is a DoubleArray
decoder I threw together:
fun doubleArrayDecoder() = object : Decoder<DoubleArray> {
override fun decode(value: Json): Either<DecodingError, DoubleArray> = binding {
value.asJsArray()
.toEither { ArrayDecodingError(value) }
.bind()
.value
.map {
it.asJsNumber()
.toEither { NumberDecodingError(it) }
.bind()
.decode(Double.decoder())
.bind()
}
.toDoubleArray()
}
}
We need to update the code with Kotlin 1.3.0 version
We need to add documentation about helios and how to use it in order to create the proper microsite.
Must to include:
This doc is apart from the Readme issue (#9)
Currently, we only have the toJsonString()
method to transform a Json
to a String
.
We can support some extra methods like noSpaces
or spaces2
to print the Json
with some formatting
We need to update https://github.com/arturbosch/detekt to the last version RC 9.2
in maven and update the detekt.yml
according to the kotlin style guide https://kotlinlang.org/docs/reference/coding-conventions.html
We need to add a check ideally per PR in order to know if we are decreasing the benchmarks.
The easiest way could be a task to update the benchmark through the CI
Currently the add function looks like this:
fun add(key: String, value: Json): JsObject = JsObject(hashMapOf(key to value))
It's a bit confusing. Is it intentional? Maybe as an of
it would be clearer.
We need to find a better way to compare json numbers for the eq instances
I know this project is still in development and not usable yet, but it looks very attractive, especially for people coming from Scala and Circe, so why don't put some effort into creating some sort of documentation, at least in the README.md
. I believe it would help attract more developers to use and contribute to it.
We need to add the Helios retrofit integration to the microsite documentation and also add a little example on the samples
module (or in a new module under the same folder)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.