[elm-discuss] Re: Modeling cross-references

2016-09-25 Thread Wouter In t Velt
> > On Sunday, September 25, 2016 at 8:54:50 AM UTC+10, Eric G wrote: >> >> - Is it better to use Dicts as the basic 'table' structure, if frequently >> rendering lists of items filtered and sorted in various ways? In short, is >> it better to convert a `List (ID, Item)` to a Dict for finding

[elm-discuss] Re: Modeling cross-references

2016-09-24 Thread Francesco Orsenigo
If the random access happens only on user input, ie it's not something you need to do several thousands times per second, stick to Lists. If you need a particular sorting order, stick to Lists. You can use `Dict.foldl/r` to map a dictionary to a list in a single step, rather than first

[elm-discuss] Re: Modeling cross-references

2016-09-24 Thread Eric G
Thanks for this question and the suggestions - very useful to issues I am dealing with now. Some questions: - Is it better to use Dicts as the basic 'table' structure, if frequently rendering lists of items filtered and sorted in various ways? In short, is it better to convert a `List (ID,

[elm-discuss] Re: Modeling cross-references

2016-09-24 Thread Spencer Judd
I tend to model things like this with Dicts, Sets, and a type alias for each identifier. So, something like type alias Model = { artists : Dict ArtistId Artist , albums : Dict AlbumId Album } type alias ArtistId = Int type alias Artist = { id : ArtistId , name : String , albums

[elm-discuss] Re: Modeling cross-references

2016-09-23 Thread Francesco Orsenigo
I'm writing a real time strategy game and I'm using numeric ids on everything. For example, each unit has an Id, and the command to attack another unit contains the target unit id. I keep all units in a (Dict UnitId Unit), so I can access each quickly. It's not as handy (or fast) as having

[elm-discuss] Re: Modeling cross-references

2016-09-23 Thread 'Rupert Smith' via Elm Discuss
On Friday, September 23, 2016 at 9:44:47 AM UTC+1, Rupert Smith wrote: > > type Album = > Album { name : String, artists : Maybe List Artist } > | Reference String > > type Artist = > Artist { name : String, albums : Maybe List Album } > | Reference String > Would also make the ids

[elm-discuss] Re: Modeling cross-references

2016-09-23 Thread 'Rupert Smith' via Elm Discuss
On Thursday, September 22, 2016 at 11:24:38 PM UTC+1, Dénes Harmath wrote: > > in a typical model, there are cross-references: e.g. we have artists and > albums, and the album refers to its artist. How do we model this in Elm? A > possible approach is giving unique identifiers to objects and