Skip to content

Instantly share code, notes, and snippets.

Avatar

Nami Nasserazad namiazad

  • TomTom
  • Netherlands
View GitHub Profile
@namiazad
namiazad / Simple Serialiser-Deserialiser using Shapeless.scala
Last active Sep 26, 2015
Simple serialisation, de-serialsation using Shapeless
View Simple Serialiser-Deserialiser using Shapeless.scala
package derivation
import java.util.Locale
import shapeless._
import scala.reflect.ClassTag
import scala.util.Try
sealed trait Utensil
@namiazad
namiazad / To Byte Sequence Converter.scala
Last active Feb 9, 2018
A Scala DSL to convert data to a byte sequence representation
View To Byte Sequence Converter.scala
import java.io.{ByteArrayOutputStream, DataOutputStream}
import shapeless._
case class Container(dos: DataOutputStream, baos: ByteArrayOutputStream) {
def ~[A: ByteSequenceRepr](arg: A) = implicitly[ByteSequenceRepr[A]].toByteSequence(this, arg)
def ~| : Array[Byte] = {
dos.close()
baos.toByteArray
}