On Thursday 24 February 2005 23:27, Keean Schupke wrote: > Benjamin Franksen wrote: > >>Well at the moment this would give an error, but remember the > >>list is heterogeneous, so you can just not give the list a type, and > >>simply append the specific function... admitedly this is not as > >>type-safe. > >> > >>hUpdateAtLabel field2 someFunction myRecord > > > >That is an advantage of hLists as compared to normal records. > > > >A disadvantage is that each field access needs to traverse the list. I > > wonder if this isn't rather less efficient than the random access > > provided by normal records. > > Well, not quite true, because the type of the label is used to index the > value, the selection happens at compile time. So at run time there is no > instance selection left... it is simply the value. At least in theory! > whether > the particular compiler/interpreter does this is implementation dependant. > This is why we decided that the simpler to implement list was better than > a more complex tree structure.
Hmm. I haven't seen it from this perspective, yet! At first reading, I thought this is simply too good to be true. I mean, there is some sort of list structured thing representing the whole record, right? Then how can the function that selects an element *not* traverse through the list? After thinking for some time about this, my head begins to spin badly! I tend to believe now, that it could indeed be possible that the compiler performs the traversal at compile time, but the thought still gives me headaches. Ben _______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell