[Haskell-cafe] relational data representation in memory
jeremy at n-heptane.com
Wed May 21 20:05:21 EDT 2008
At Thu, 22 May 2008 01:04:24 +0200,
Marc Weber wrote:
> Some way representing relational data which is typically stored in
> databases such as Postgresql..
> Rewriting something like Postgresql in haskell would take ages..
> So I'd be satisfied with having in memory representation only (this
> would fit the HAppS state system very well .. :)
Are you familiar with the HAppS IxSet library?
You would do something like:
$( deriveAll [''Ord,''Eq,''Read,''Show,''Default]
data CD = CD AlbumTitle Artist [Track]
newtype Artist = Artist String
newtype AlbumTitle = AlbumTitle String
data Track = Track TrackTitle TrackIndex
newtype TrackIndex = TrackIndex Int
newtype TrackTitle = TrackTitle String
$(inferIxSet "CDS" 'noCalcs [''AlbumTitle, ''TrackTitle, ''Artist])
This creates a table with indexs on AlbumTitle, TrackTitle, and
You can do a simple query like:
mycds @= (Artist "Wesley Willis")
to get all the tracks by Wesley Willis.
You should be able to build joins, etc on top of that.
More information about the Haskell-Cafe