I am looking for design guidelines on when to model a collection of records 
as a Dict vs. a List.

The TodoMVC uses a List, though at first glance a Dict seems like a more 
natural match:
- There are several "id based" Msg's (ex. EditingEntry, UpdateEntry, 
Delete, Check)
- Using Html.Keyed should be (slightly) easier to use

But I think I understand why a List is more pragmatic.
In (my) practice, things get muddy attempting to implement TodoMVC with a 
Dict.
Dict.update wants a (Maybe v -> Maybe v) resulting in nested case 
statements which are okay but preferable to avoid.
(...it could be that my FP-fu is too weak to factor a concise expression.
Maybe.map doesn't appear useful as record updates aren't compose-able?)

So, the "mapWhen" idiom (via an "updateEntry" helper) does seem to be the 
simplest approach

let
  updateEntry t =
       if ti.id = id then { t | field = newValue } else t
in
  { model | entries = List.map updateEntry model.entries }

So if Dict isn't the best choice for a use case like TodoMVC...what kinds 
of use cases is it good for?



-- 
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.

Reply via email to