[Haskell-cafe] Inverse of HaskellDB

Chris Eidhof chris at eidhof.nl
Wed Sep 29 05:41:49 EDT 2010

On 28 sep 2010, at 17:33, Ozgur Akgun wrote:

> How do you define relationships between data types?
> Well, why is it any different from other fields? From one of your examples [1], I'd expect you to have a list of questions in the Quiz data type, and if necessary, a quiz field in the Question data type. This might be a bit tricky but certainly achievable [2].

This is really tricky. For example, consider storing a large tree in the database:

> data Tree = Node Int Tree Tree | Leaf Int

This means you need to read the entire tree from the database. Or consider cyclic datastructures (such as the example you gave). How do you store this? The only way to inspect this is using a library like data-reify [1].

I think the problem might be a bit harder than you suspect.

Another way to solve it is using Sebastiaan Visser's framework, described in his paper [2], but that's also rather complicated.


[1]: http://hackage.haskell.org/package/data-reify
[2]: http://github.com/downloads/sebastiaanvisser/msc-thesis/wgp10-genstorage.pdf

More information about the Haskell-Cafe mailing list