Hi,

just an idea (using Seq from Data.Seq and Map from Data.Map):

> newtype DataTable a b = DataTable (Map b (Seq a))

or if you know you won't have repeated values, you could have

> newtype DataTable a b = DataTable (Map b (Set a))

Both those ideas sort the data (partially or fully). If you need to preserve the ordering, you could do something like

> new DataTable a b = DataTable (Seq (a, Seq b))

Best regards,
Petr Pudlak


2012/12/19 Christopher Howard <christopher.howard@frigidcode.com>
Is there some good data type out there that basically provides a simple
table, but with optimization for repeating values on one column?
Something like:

Data Table a b

...where it assumes that 'a' values will usually be unique, while 'b'
values will usually be repeated from a small set? (But not needing to be
fixed beforehand.)

Like in...

client | patron
---------------
Bob    | Tom
Sarah  | Tom
Dick   | Tom
George | Harry
Moe    | Harry

--
frigidcode.com


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe