agentm / project-m36

Project: M36 Relational Algebra Engine
The Unlicense
894 stars 48 forks source link

What is the purpose of ``TypeConstructorMapping`` in ``csvAsRelation`` #252

Closed kozross closed 4 years ago

kozross commented 4 years ago

This function is a bit unclear to me, but this argument in particular is confusing. What does it do, and how would I provide one correctly?

agentm commented 4 years ago

The TypeConstructorMapping holds onto all the type constructor definitions along with related data constructors. This is necessary in decoding CSV because we support writing CSV files with user-defined algebraic data types, so we have to be able to read them back.

Typically, this mapping is maintained by the database and passed around as necessary, but you can get a bootstrapped version in DataTypes/Basic.hs

kozross commented 4 years ago

How would I define one, supposing I had three attributes, one being a Text, another an Int, and another a user-defined type Foo?

agentm commented 4 years ago

Take a look at the primitive data types as well as the non-empty list type for examples.

agentm commented 4 years ago

Please reopen this ticket if you need further assistance.