Menu
  • HOME
  • TAGS

.dropUnit on .hlist'ed codecs doesnt seem to work

scala,shapeless,scodec

The hlist combinator converts a Codec[A] in to a Codec[A :: HNil]. This is typically used with other combinators, like flatZip, which require an HList based codec. Repeated use of the ~ operator creates a left-associated Tuple2 based structure. For example, int8 ~ bool ~ int8 has type Codec[((Int, Boolean),...

Scodec: Coproducts could not find implicit value for parameter auto: scodec.codecs.CoproductBuilderAuto

scala,scodec

The code that is there now needs two minor changes: The Message trait must be sealed, or otherwise, Shapeless will not provide a Generic.Aux[Message, SomeCoproduct] instance. The call to Codec.coproduct[Message] must be after all the subtypes are defined. Moving the companion to the end of the file is sufficient. With...

Scodec: How to create a codec for an optional byte

scodec

One way to do this is using the scodec.codecs.optional combinator, which returns a Codec[Option[A]] given a Codec[Boolean] and a Codec[A]. val structure: Codec[(Int, Option[Int])] = uint(7) ~ optional(bool, uint8) This gives us a codec of (Int, Option[Int]) - we need to convert this to a codec of Int. To do...