Skip to content

Instantly share code, notes, and snippets.

@phenan
Created October 21, 2017 14:09
Show Gist options
  • Save phenan/fad34116e17c4b761a7f851019068ef5 to your computer and use it in GitHub Desktop.
Save phenan/fad34116e17c4b761a7f851019068ef5 to your computer and use it in GitHub Desktop.
BytePrinters.scala の用例 (2通りの書き方)
import combinator._
object PrinterExamples extends BytePrinters {
def u2_s4_data: BytePrinter[(Int, Int)] = {
case (a, b) => u2(a) >> s4(b)
}
def length_bytes: BytePrinter[Array[Byte]] = bs => for {
_ <- u2(bs.length)
_ <- bytes(bs)
} yield ()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment