<div dir="ltr">Based on what you've said, I would define a Serial or Binary instance for single bytecodes, and then use this to write a function :: ByteString -> [Bytecode].<div><br></div><div>Then, you can convert raw JVM bytecode into some convenient Haskell data, and then do whatever processing you want to this.</div><div><br></div><div>--Will</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Aug 29, 2015 at 6:12 PM, Gautier DI FOLCO <span dir="ltr"><<a href="mailto:gautier.difolco@gmail.com" target="_blank">gautier.difolco@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello all,<br><br>I have some bytecodes to parse and I look for the most idiomatic way to do it.<br>It's mostly JVM Bytecode, long story short, I have some embedded JVM Bytecodes:<br> * one part is specification-defined, from 0x00 to 0xB8, differ from the regular JVM Bytecode<br> * and the other part is proprietary and changes often<br><br>I have two main goals:<br> * print the signification of each bytecodes (a more explicit one than the hexadecimal value of the bytecode)<br> * Do some analysis on it, spot patterns, apply markov model on it and so on.<br><br>The issue with JVM Bytecode in general is that each bytecode hasn't been made equal. Some of them requires parameters, some of them modify the length of the next bytecode, etc.<br>I'm not looking for a way to parse bytecode quickly, or for a library doing it for me.<br>I look for a simple/composable/idiomatic way to do it.<br>So if you have any thoughts, papers, articles or even code snippets (part of a library of not) that is done in the Haskell-way, please, share it :)<br><br>Thanks in advance for your help.<br></div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div>