
Yes, I see. Would it be possible to have a standard strict list, i.e. something equivalent of
data SList a = SNil | SCons !a SList
(which could be a member of the same class as the normal lists, and have the usual functions (length, ++, isPrefixOf...) overloaded)?
Yes, it would be possible, but we can't do it without making sweeping changes to standard libraries and deviating from Haskell 98 quite a bit. It's something to bear in mind should the topic of Haskell 2 come up, though. Cheers, Simon

"Simon Marlow"
Yes, I see. Would it be possible to have a standard strict list,
Yes, it would be possible, but we can't do it without making sweeping changes to standard libraries and deviating from Haskell 98 quite a bit. It's something to bear in mind should the topic of Haskell 2 come up, though.
Yes, I realise that. Perhaps it'd be possible to (for one particular module) override the default [] and (:) to use a strict-element list. I.e. import Prelude hiding... import StrictLists ... (The intention is to make *all* lists in that module strict) Anyway, I tried to rewrite my program to use custom-defined lists instead of []-type lists. Unfortunately, I ended up consuming vastly more space, and additionally needing a huge stack. And everything was a lot slower. I've probably messed up something, somewhere. Sigh. Thanks for all your help, though! -kzm -- If I haven't seen further, it is by standing in the footprints of giants

ketil@ii.uib.no (Ketil Z. Malde) writes:
Thanks for all your help, though!
One interesting(?) observation, using a custom data type of data STuple = STuple !Int Foo is slightly less efficient than using a normal tuple (Int,Foo) Seems to go against theory, in which STuple should use three words plus the Foo, while (,) should use three words plus the Foo, plus two for the Int. Perhaps the Ints are constructed anyway, since they are inserted from a function parameter? Sounds reasonable, I suppose; memory use seemed to be the same (from "top"), and there was only a speed difference. And one more thing, would parametrised types make a difference? E.g. my array is data MyArray label elts = MA label (Array Int elts) which means I have data Foo l a = Foo (MyArray l a) !Int and so on. As far as I can see, this shouldn't matter (a heap object is a heap object), but am I seeing far enough, I wonder? -kzm -- If I haven't seen further, it is by standing in the footprints of giants

"Simon" == Simon Marlow
writes:
>> Yes, I see. Would it be possible to have a standard strict list, >> i.e. something equivalent of >> >> data SList a = SNil | SCons !a SList >> >> (which could be a member of the same class as the normal lists, >> and have the usual functions (length, ++, isPrefixOf...) >> overloaded)? Simon> Yes, it would be possible, but we can't do it without making Simon> sweeping changes to standard libraries and deviating from Simon> Haskell 98 quite a bit. It's something to bear in mind Simon> should the topic of Haskell 2 come up, though. If there are significant changes to be made anyway, wouldn't it be the best thing to generalize lists to a type class of which lists are an instance of? The nice list comprehension syntax could then be used also for other data structures, and combinators like map, filter, scanl applied to arrays, trees etc. Analogously to the Num class, one could have a function like *toList*, and one would expect from a program to establish: toList . combinator_in_X_a = combinator_in_[a] . toList Cheers -- Christoph
participants (3)
-
Ch. A. Herrmann
-
ketil@ii.uib.no
-
Simon Marlow