argonaut-io/argonaut — pull request #110 by tixxit (2014-06-12 15:17:37+00:00)
Title: Allow DecodeJson ||| to combine as supertype.

Allow ||| to return a DecodeJson of the common super type of the 2 arguments (DecodeResult already does this). This was motivated by this pattern:

sealed trait AB
case class A(a: A) extends AB
case class B(b: B) extends AB

val acodec: CodecJson[A] = casecodec1(A.apply, A.unapply)("a")
val bcodec: CodecJson[B] = casecodec1(B.apply, B.unapply)("b")
implicit val abdecoder: DecodeJson[AB] = acodec ||| bcodec

The alternative is to use the ||| on DecodeResult.