[Haskell-cafe] Re: Default (or empty) values
Pedro Baltazar Vasconcelos
pbv at dcc.fc.up.pt
Wed Jan 17 09:45:25 EST 2007
On Wed, 17 Jan 2007 16:57:54 +0300
Max Vasin <max.vasin at gmail.com> wrote:
> It does not enforce presence of required fields at type level. Also it
> does not enforce that fields pages and year are Int. And I want to
> move as much checks to compile time as possible.
You can combine the two solutions: a product-type of required fields plus list of optional fields. You're right that you lose the typing constraints on fields. I probabily woudn't bother, but you might be able to recover that with the type-classes or GADTs (?).
But more important: it sounds to me like you have two conflicting requirements: one the one hand you want to have required fields (presumability those that were not Maybe types) but on the other hand you want an "empty" book (i.e. with "" for title, etc.).
More information about the Haskell-Cafe