kaitai-io / kaitai_struct

Kaitai Struct: declarative language to generate binary data parsers in C++ / C# / Go / Java / JavaScript / Lua / Nim / Perl / PHP / Python / Ruby
https://kaitai.io
4.03k stars 197 forks source link

Haskell support #190

Open GreyCat opened 7 years ago

GreyCat commented 7 years ago

Moved from https://github.com/kaitai-io/kaitai_struct_compiler/issues/92. Original message:

It will be nice to have Haskell in the target languages.

GreyCat commented 7 years ago

@gaa-cifasis I believe you've seen http://doc.kaitai.io/new_language.html — if you don't, please take a look, and if you (or someone else who knows Haskell well) wants to champion new language addition — let us proceed.

raehik commented 2 years ago

Any parties interested in working on this may take a look at my related work in raehik/binrep. You can perhaps think of it like a restricted Kaitai Struct-esque binary representation DSL. Many types and concepts can be translated into a (possibly parameterized) binrep type. High-level concepts like sum types and successive fields are handled at the type definition level, e.g. the order you define fields in a constructor is their order in the schema. Alternatively, you can drop this automation and write it out manually.

Some syntax will be hard to translate while retaining the same type guarantees binrep provides, and binrep doesn't have the parsing prowess of Kaitai Struct (but it can serialize!), so it will be less help there. The parsing and serializing code will be especially useful, since they use awfully efficient libraries.

I haven't used Kaitai Struct and am not prepared to take charge here, but if someone wishes to discuss the Haskell side of the language support, feel free to contact me.