[Haskell-cafe] Selda, type operators and heterogeneous lists
Marc Busqué
marc at lamarciana.com
Fri Apr 13 13:59:44 UTC 2018
Hi there!
I'm using [selda](https://github.com/valderman/selda) package to deal
with relational databases.
This package represents database tables in haskell in a type-safe way.
And to do so it leans on type operators. For example, here they are two
different tables:
```
categories :: Table (RowID:*:Text)
expenses :: Table (RowID:*:Text:*:Double:*:RowID)
```
As both of them belong to different types, I can't put them in a single
list out of the box:
```
[categories, expenses] --- not valid!!
```
I'm aware of [different solutions](https://wiki.haskell.org/Heterogenous_collections) to deal with it, but they don't convince me:
- Algebraic data types: I think in this situation it is specially a
burden having to play type-switching... There can exist a lot of
different table schemas and they may change at any moment.
- Universal type: I see it as a kind of hack
- Existential types: I have read that usually it is an anti-pattern, and
in this case I don't understand how it should work, because types are
constructed with `:*:` operator.
So my question if it exists some natural way to treat types built with
type operators as a single type. I have to recognize I don't understand
well how all this stuff about type operators works. I have read
something but I still don't get it. So any direction with it would be
very gratifying, too :)
Thanks in advance.
Marc Busqué
http://waiting-for-dev.github.io/about/
More information about the Haskell-Cafe
mailing list