[Haskell-cafe] type inference and named fields

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Fri Jun 24 09:38:47 EDT 2005


Christian Maeder <maeder at tzi.de> writes:

> > voidcast v@(VariantWithOne{}) = v { field1 = Void , field2 = Void }
> 
> Setting field2 only assures type correctness, but the value of field2
> would be ignored at runtime.

Exactly what I was proposing.

> > I could write a single expression that updated all possible variants
> > of a type, simply by unioning all their possible labels.
> 
> I want to detect errors as early as possible.

But you can already write this:

> > voidcast v@(VariantWithOne{}) = v { field1 = Void , field2 = Void }

and you do not get a compile time error - it is a runtime error.
I am proposing that it should not be thought of as an error at all.

Regards,
    Malcolm


More information about the Haskell-Cafe mailing list