47degrees / helios

A purely functional JSON library for Kotlin built on Λrrow
https://47degrees.github.io/helios/
Apache License 2.0
169 stars 22 forks source link

Add Enum encoder and decoder #91

Closed Octogonapus closed 5 years ago

Octogonapus commented 5 years ago

This PR adds an Enum encoder and decoder implementation. I wasn't sure where to put this, let me know if it should be moved.

Closes #85.

pakoito commented 5 years ago

LGTM, @AdrianRaFo can merge :D

AdrianRaFo commented 5 years ago

I think we should create a companion object on Foo

enum class Foo{
  A;
  companion object
}

to get something like Foo.encoder()

Besides, I would add a section on the coding section in the documentation explaining how to use this

Octogonapus commented 5 years ago

@AdrianRaFo I wanted to have an API like Foo.encoder() but I couldn't figure out the correct method signature to make it happen. This does not work: fun <E : Enum<E>> Enum.Companion.encoder() This does not compile: fun <E : Enum<E>> Enum<E>.Companion.encoder() This does not compile: fun <E : Enum<E>> E.Companion.encoder()

Do you know how to write that part?

AdrianRaFo commented 5 years ago

I'll take a look

AdrianRaFo commented 5 years ago

Besides, please remember to assign yourself the issue or left a comment if you are going to take it :wink:

AdrianRaFo commented 5 years ago

@Octogonapus Let me know you thought about this https://github.com/Octogonapus/helios/pull/1

Octogonapus commented 5 years ago

@AdrianRaFo I would have assigned the issue to myself, but I can't do that as an external collaborator. I thought my intention to work on the issue was clear from my comments.

AdrianRaFo commented 5 years ago

You're right, just for future references ☺️

Octogonapus commented 5 years ago

Not sure why the benchmark failed.

AdrianRaFo commented 5 years ago

don't worry about them, they fail some times. I'll restart them