On Friday, March 3, 2017 at 12:15:59 PM UTC, Rupert Smith wrote:
>
> On Friday, March 3, 2017 at 6:16:15 AM UTC, Richard Feldman wrote:
>>
>> Re-posting the first example from Franscisco's thread 
>> <https://groups.google.com/forum/#!topic/elm-discuss/vzcrRdgY1-w>:
>>
>
> I think item 2 from Franscisco's thread is looking for an easy way to add 
> and remove fields from a record, producing a new record with a different 
> type. Let me just abuse the list append (++) operator to give the idea of 
> how a field would be added:
>
> someRecord ++ { newField = "blah" }
>
> The long hand version might be
>
> addNewField someRecord = 
>   { newField = "blah", someRecord.existingField1, 
> someRecord.existingField2, ... }
>
> Not sure how I feel about operations that produce records of a different 
> type, but if its really just syntax sugar for something you can write out 
> in long hand, it does not seem so unreasonable.
>

I wanted to be able to add fields to records, but when I found out I could 
not, then I changed the way I create data models; which is to simply nest 
smaller records inside in such a way that each partitions off a piece of 
the data that behaves as an independent unit. As per the recommendation 
that nesting is better than 
extending: 
https://groups.google.com/forum/#!msg/elm-discuss/AaL8iLjhEdU/pBe29vQdCgAJ

So I do not need this syntax any longer myself, since I have a way to break 
down bigger models into piece and put pieces back together again to form 
bigger or transformed models. In fact I think not having it has made me 
consider my data models more carefully and to build better ones. Being able 
to add and remove fields feels more like javascript where you don't declare 
the type of things up-front, you just keep hacking more fields on.

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to