[Haskell-cafe] Inverse of HaskellDB
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 , 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 .
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 .
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 , but that's also rather complicated.
More information about the Haskell-Cafe