[Haskell-beginners] How to "add column" to a Table?

martin martin.drautzburg at web.de
Sun Apr 26 10:13:35 UTC 2015


Hello all,

I suppose the natural representation for a Table is a List of Tuples. Or more generally I'll probably end up with a type
"Table a" where a stands for the Columns.

I cannot figure out how to add a new Column to a Table. What would be the type of such an operation? If I just want to
add an empty Column (which what an RDBMS would do), would I do something like this?

addColumn :: ColumnDef -> Table a -> Table b

But what is this ColumnDef? It would need to contain the name and type of the new column. To implement this operation I
would have to somewehre add a column to something. But what is the type of this something. I don't see how I can add a
component to a Tuple in a generic way, or can I?

I browsed some code on Hackage and found code which uses Data.Proxy. It this the right direction? Or do I need to look
at GADTs, or template haskell? Or am I overcomplicating things, and there is a true haskellish solution?


More information about the Beginners mailing list