[Haskell-beginners] How to improve lazyness of a foldl (and memory footprint)

Giacomo Tesio giacomo at tesio.it
Wed May 15 14:55:43 CEST 2013


Turned out that I didn't need fold at all, just a proper groupBy.

As for these lines

module Main (
>
>     main
>
> ) where
>
>
they were generated by Leksah. Do you suggest to remove them? And what
about Leksah as an IDE: do you use it?


Giacomo


On Wed, May 15, 2013 at 9:35 AM, Giacomo Tesio <giacomo at tesio.it> wrote:

> Thanks a lot!
>
> Yesterday on freenode's #haskell channel Cane noted how my laziness
> problem reside in the foldl use in foldTradingSample.
> I have to turn it into a foldr (but I'm still unsure how...)
>
>
> Giacomo
>
>
> On Wed, May 15, 2013 at 12:46 AM, Henk-Jan van Tuyl <hjgtuyl at chello.nl>wrote:
>
>> On Tue, 14 May 2013 11:22:27 +0200, Giacomo Tesio <giacomo at tesio.it>
>> wrote:
>>
>>  Hi, I'm trying to improve a small haskell program of mine.
>>>
>> :
>>
>> Some remarks:
>>
>> 0) Use hlint (available on Hackage) for improvement suggestions
>> 1) You don't have to write the module heading in Main.hs, it is not a
>> library (why export main?)
>> 2) Change "print" to "putStrLn" if you want to display messages without
>> quotes
>> 2) switchArgs is only partially defined, add something like:
>>      switchArgs [x] = putStrLn $ "Unknown tool: " ++ x
>> 3) Use shorter lines, for example change:
>>
>>   importTrades outDir csvFile = transformFile csvFile (foldTradingSample.
>> **getTickWriteTrades)   (saveTradingSamples outDir)
>>
>> to:
>>
>>   importTrades outDir csvFile =
>>     transformFile
>>       csvFile
>>       (foldTradingSample.**getTickWriteTrades)
>>       (saveTradingSamples outDir)
>> 4) It is considered good practice, to write the function
>>    composition operator between spaces (change f.g to f . g)
>>
>> I have analyze your software further to see how sufficient laziness can
>> be reached.
>>
>> Regards,
>> Henk-Jan van Tuyl
>>
>>
>> --
>> Folding at home
>> What if you could share your unused computer power to help find a cure?
>> In just 5 minutes you can join the world's biggest networked computer and
>> get us closer sooner. Watch the video.
>> http://folding.stanford.edu/
>>
>>
>> http://Van.Tuyl.eu/
>> http://members.chello.nl/**hjgtuyl/tourdemonad.html<http://members.chello.nl/hjgtuyl/tourdemonad.html>
>> Haskell programming
>> --
>>
>> ______________________________**_________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://www.haskell.org/**mailman/listinfo/beginners<http://www.haskell.org/mailman/listinfo/beginners>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130515/acff42af/attachment.htm>


More information about the Beginners mailing list