Is there a no-fuss serialization method for Haskell, similar to Erlang’s term_to_binary/binary_to_term calls? Data.Binary seems unnecessarily complicated and raw. See this example where you are basically manually encoding terms to integers.
Is there a no-fuss serialization method for Haskell, similar to Erlang’s term_to_binary/binary_to_term calls? Data.Binary
Share
Use Data.Binary, and one of the deriving scripts that come with the package.
It’s very simple to derive Binary instances, via the ‘derive’ or ‘deriveM’ functions provided in the tools set of Data.Binay.
For any ‘a’ in Data, it derives a Binary instance for you as a String. There’s a putStr version too, deriveM.
Example:
The example you cite is an example of what the machine generated output looks like — yes, it is all bits at the lowest level! Don’t write it by hand though — use a tool to derive it for you via reflection.