Created
April 23, 2015 15:42
-
-
Save clayrat/3ec844fc22a9f68758b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argonaut._, Argonaut._, Shapeless._ | |
object Tool { | |
trait Enum { | |
type EnumVal <: Value | |
protected trait Value { self: EnumVal => | |
val name: String | |
} | |
} | |
object BarEnum extends Enum { | |
sealed trait EnumVal extends Value | |
val BarA = new EnumVal { val name = "A" } | |
val BarB = new EnumVal { val name = "B" } | |
val BarC = new EnumVal { val name = "C" } | |
} | |
final case class Foo(barEnum: Option[BarEnum.EnumVal]) | |
def main(args: Array[String]) { | |
implicit def BarEnumValEncodeJson: EncodeJson[BarEnum.EnumVal] = | |
EncodeJson((s: BarEnum.EnumVal) => jString(s.name)) | |
val fooEncoder = implicitly[EncodeJson[Foo]] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment