[Haskell-cafe] relational data representation in memory using haskell?

Salvatore Insalaco kirby81 at gmail.com
Thu May 22 06:48:42 EDT 2008

2008/5/22 Marc Weber <marco-oweber at gmx.de>:
> So in haskell it would look like this:
>        let updatedCd = 0x22  CD (0x6 "My song")  (0x20 ( 0x23 : ...)
>            updatedTrack = 0x23 Track ( 0x21 "updated track title" ) 0x22
>        in (0x27) DB (0x24 (updatedCd:otherCds)) (0x25 (updatedTrack:otherTracks))

Mmmm I don't think that this is a good way to go.
Let me do a counter-example:

data A = A String
data B = B String [A]
data C = C String [B]
data D = D String [C]

Suppose to have some As, Bs, Cs, Ds in your database. Now you want to
"update" the String of A. As you cannot "update" stuff in Haskell
mantaining the same pointer, you've got a "new A". So you must find
all Bs that had this A in their list, and update that.
Unfortunately lists are not mutable too, so you are creating a new
list; so you need to create new containing Bs too. But then you must
change Cs... and so on.
A little change like changing the String in A requires updating the whole "DB".


More information about the Haskell-Cafe mailing list