On Tuesday, February 21, 2017 at 2:16:55 AM UTC, Max Goldstein wrote:
>
> Records can still be useful in union types if you have more than a few
> fields, or multiple fields of the same type. Often you write a function
> that updates a record by looking at a select few fields and it never needs
> to know about others. Occasionally you will have multiple records of this
> sort. So you can pipe the different records in different cases to the same
> function to handle that part of the update, and then other logic to handle
> whatever else needs to happen.
>
Yes, I think that is what I was trying to say with "except for the simple
case where you want to write a function that projects the fields of a
record onto a sub set". It is handy to be able to write a function like
this:
justNeedSomeFields { field1, field2 } = ..
and for the compiler to accept that function in all the obvious places that
it should be allowed.
Beyond that though, I don't see extensible records as being of any use at
all. In particular declarations like this:
type alias WithPosition = { a | rect: Rectangle, yOffset: Float }
are just leading to problems and making things harder than they should be.
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.