
On Thu, May 6, 2010 at 9:37 PM, Brent Yorgey
data MyList a = MyList {mylist::[a], mylength::Int}
There's no magic going on here, if you call a function to compute some complicated feature of a data structure multiple places in your code, it will be computed multiple times, just like in any other language. Caching the features you need as in the above example is a good idea if the data structures won't change often, and you really do need the features many times.
Notice that if you don't need mylength anywhere in your code, it won't be computed (except if you made your smart constructor extra-strict) so it's way easier in Haskell to implement the "compute this only once but only if I really need it" scheme that you often see in other languages. -- Jedaï