
Malcolm Wallace wrote:
I believe this is a very different question from the consecutive update one.
I agree, consecutive and parallel updates are quite different.
I can see no reason to outlaw a type change, where all the relevant types change at the same time:
update_ok v@(A{}) = v { one=Void, two=Void } update_ok' v@(A{}) = (\A one two -> A Void Void) v
Because typing fails in your original example: voidcast v@VariantWithOne{} = v {field1 = Void} What would be the "lambda equivalent"?
voidcast v@VariantWithOne{} = (\ (VariantWithOne a) -> VariantWithOne Void) v
would go through. Whereas
voidcast v@VariantWithOne{} = ( \ x -> case x of VariantWithTwo a b -> VariantWithTwo Void b VariantWithOne a -> VariantWithOne Void) v
fails like the field notation. I think writing "VariantWithOne {field1 = Void}" instead of "v {field1 = Void}" is as clear as writing "Right r" again on the rhs instead of "x" from the pattern "x@(Right r)" Christian