[Haskell-cafe] Re: Default (or empty) values

Max Vasin max.vasin at gmail.com
Wed Jan 17 11:05:08 EST 2007


>>>>> "Pedro" == Pedro Baltazar Vasconcelos <pbv at dcc.fc.up.pt> writes:

Pedro> On Wed, 17 Jan 2007 16:57:54 +0300
Pedro> 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.

Pedro> You can combine the two solutions: a product-type of
Pedro> required fields plus list of optional fields. You're right
Pedro> that you lose the typing constraints on fields. I probabily
Pedro> woudn't bother, but you might be able to recover that with
Pedro> the type-classes or GADTs (?).

I have only a very basic understading of what GADTs are :-(

Pedro> But more important: it sounds to me like you have two
Pedro> conflicting requirements: one the one hand you want to have
Pedro> required fields (presumability those that were not Maybe
Pedro> types) but on the other hand you want an "empty" book
Pedro> (i.e. with "" for title, etc.).

I want to get as strict type checking as possible while writing as
little code handling Book as possible. The empty value is needed only
to start with when analising external represenation. And as suggested
by Colin DeVilbiss and Henning Thielemann it will be better to use
undefined for required fields.

-- 
WBR,
Max Vasin.



More information about the Haskell-Cafe mailing list