[Haskell-cafe] type inference and named fields
Henning Thielemann
lemming at henning-thielemann.de
Thu Jun 23 15:23:17 EDT 2005
On Thu, 23 Jun 2005, Christian Maeder wrote:
> Malcolm Wallace wrote:
> >>voidcast :: Fields a -> Fields Void
> >>voidcast v@(VariantWithTwo{}) = v { field1 = Void , field2 = Void }
> >>voidcast v@(VariantWithOne{}) = v { field1 = Void }
>
> I would not expect that updating only field1 can change the type of v.
> The right thing is to construct a new value. This looks as follows with
> record syntax:
>
> voidcast VariantWithTwo{} =
> VariantWithTwo { field1 = Void , field2 = Void }
> voidcast VariantWithOne{} =
> VariantWithOne { field1 = Void }
Erm, I have overlooked this, too. So my update function proposal doesn't
affect the type aspect of record update syntax.
More information about the Haskell-Cafe
mailing list