Skip to content

Instantly share code, notes, and snippets.

@iracigt
iracigt / ParserExamples.scala
Created December 9, 2019 18:10
A parser combinator library for parsing (and unparsing) binary data
import shapeless.Generic
case class Complex(re: Int, im: Int)
case class Foo(a: Int, b: Int, c: Int)
object ParserExample extends App {
def parseFoo: Parser[Foo] = UIntParser(2) ~ UIntParser(1) ~ UIntParser(1) ^^ Generic[Foo]
def parseComplex: Parser[Complex] = UIntParser(8) ~ UIntParser(8) ^^ Generic[Complex]

Keybase proof

I hereby claim:

  • I am iracigt on github.
  • I am iracigt (https://keybase.io/iracigt) on keybase.
  • I have a public key ASCSJ9zWSpmDz6qEQKyFXZNUse8Ng5AONv2-3ji4yfnS-wo

To claim this, I am signing this object: