Created
October 21, 2017 14:09
-
-
Save phenan/fad34116e17c4b761a7f851019068ef5 to your computer and use it in GitHub Desktop.
BytePrinters.scala の用例 (2通りの書き方)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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