Last active
August 29, 2015 14:22
-
-
Save joshcough/cb780644c86df1e988ee 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 scalaz._, Scalaz._ | |
import argonaut._, Argonaut._ | |
/** | |
* Main prints: | |
* -\/(Double: [--\(d)]) | |
* \/-(Dubble(56.45)) | |
* \/-(Pint(56)) | |
* \/-(Pint(56)) | |
*/ | |
object ArgonautDoubleWeirdness { | |
case class Pint(i: Int) | |
implicit def PintCodecJson: CodecJson[Pint] = casecodec1(Pint.apply, Pint.unapply)("i") | |
case class Dubble(d: Double) | |
implicit def DubbleCodecJson: CodecJson[Dubble] = casecodec1(Dubble.apply, Dubble.unapply)("d") | |
def main (args: Array[String]) { | |
println(Parse.decodeEither[Dubble]("""{"d":"56.45"}""")) | |
println(Parse.decodeEither[Dubble]("""{"d":56.45}""")) | |
println(Parse.decodeEither[Pint]("""{"i":"56"}""")) | |
println(Parse.decodeEither[Pint]("""{"i":56}""")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment