How do I do automatic data serialization of data objects in Haskell
Posted
by Adam Gent
on Stack Overflow
See other posts from Stack Overflow
or by Adam Gent
Published on 2010-04-22T11:49:21Z
Indexed on
2010/04/22
11:53 UTC
Read the original article
Hit count: 300
One of the huge benefits in languages that have some sort of reflection/introspecition is that objects can be automatically constructed from a variety of sources.
For example in Java I can use the same objects for persisting to a db (with Hibernate) serializing to XML (with JAXB) or serializing to JSON (json-lib). You can do the same in Ruby and Python also usually following some simple rules for properties or annotations for Java.
Thus I don't need lots "Domain Transfer Objects". I can concentrate on the domain I am working in.
It seems in very strict FP like Haskell and Ocaml this is not possible. Particularly Haskell. The only thing I have seen is doing some sort of preprocessing or meta-programming (ocaml). Is it just accepted that you have to do all the transformations from the bottom upwards?
In other words you have to do lot of boring work to turn a data type in haskell into JSON/XML/DB Row object and back again into a data object.
© Stack Overflow or respective owner