Safe modelling of relational data in Haskell

前端 未结 5 1788
醉梦人生
醉梦人生 2021-01-30 13:25

I find it very common to want to model relational data in my functional programs. For example, when developing a web-site I may want to have the following data structure to stor

5条回答
  •  有刺的猬
    2021-01-30 14:08

    Another radically different approach to representing relational data is used by the database package haskelldb. It doesn't work quite like the types you describe in your example, but it is designed to allow a type-safe interface to SQL queries. It has tools for generating data types from a database schema and vice versa. Data types such as the ones you describe work well if you always want to work with whole rows. But they don't work in situations where you want to optimize your queries by only selecting certain columns. This is where the HaskellDB approach can be useful.

提交回复
热议问题