Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Lazy vs Strict ponderings... (Daniel Fischer)
   2. Re:  Lazy vs Strict ponderings... (Daniel Fischer)
   3. Re:  Lazy vs Strict ponderings... (Sean Charles)
   4. Re:  Lazy vs Strict ponderings... (Daniel Fischer)
   5. Re:  Lazy vs Strict ponderings... (Sean Charles)
   6.  "cabal install wxcore --enable-shared" Error (Paulo Pocinho)
   7. Re:  Question about functors (or maybe not...) (C K Kashyap)


----------------------------------------------------------------------

Message: 1
Date: Sun, 20 Mar 2011 15:55:24 +0100
From: Daniel Fischer <daniel.is.fisc...@googlemail.com>
Subject: Re: [Haskell-beginners] Lazy vs Strict ponderings...
To: beginners@haskell.org
Message-ID: <201103201555.24772.daniel.is.fisc...@googlemail.com>
Content-Type: Text/Plain;  charset="iso-8859-1"

On Sunday 20 March 2011 10:37:23, Heinrich Apfelmus wrote:
> s...@objitsu.com wrote:
> >>> 2) Don't worry about memory leaks until they actually appear. If
> >>> they do, use a profiling tool to find out what's going on. Most
> >>> likely, one of the two things above happened in an interesting way.
> > 
> > At the risk of sounding stupid in Haskell mode, how would I be aware
> > of this other than obvious messages or seg-faults about memory
> > getting low ?
> 
> The usual sign is that GHC is requesting more RAM from the OS than it
> should. For instance, if you expect your program to run in constant
> space, but GHCs memory usage keeps growing by 100 MB every twenty
> seconds, then you have a space leak. You can also run a profile
> preemptively and look at the graph.
> 
>    http://book.realworldhaskell.org/read/profiling-and-optimization.html
> 

Before profiling, I'd first

a) watch in top [whatever the corresponding utility is called on Windows]
b) run with +RTS -s (requires to link with the -rtsopts flag in GHC >= 7)

to see whether there's a problem.
Important in the +RTS -s output are (for this)
- GC time
- maximum residency
- total memory in use

The total allocation figure is rather irrelevant, don't worry if that's 
high but the above are small.

If the memory usage is much higher than you'd expect, you likely have a 
memory leak (but be aware that datatypes like lists and trees have fairly 
large overhead).

If GC time is large but memory usage is small enough, you have a problem 
which is technically not a memory leak, but requires similar diagnosis and 
remedies.

If the above indicates a problem, unless it's obvious where the problem 
must be (and it rarely is), profile to locate it.

However, the interaction of profiling and optimisations is quite 
complicated (some optimisations are impossible when compiling for profiling 
if they would eliminate a cost-centre) and compiling for profiling can 
occasionally change the time/space behaviour of a programme.
So it might be that the profiling run doesn't show a problem present in the 
production build (indicates that some optimisation is in fact a 
pessimisation in your case) or shows a problem not present in the 
production build (some optimisation eliminating the leak is prevented by 
profiling bookkeeping).
Both effects are rare, though. Nevertheless I like to confirm the existence 
of a problem before profiling.

> >> It is likely that, if you develop a medium to large sized application
> >> for a customer, memory leaks will appear at the customers site. It
> >> will often be very difficult to reproduce the situation and find the
> >> leak.
> > 
> > That scares me enough to not want to use Haskell for serious
> > application development. With 26 years in the trade I have had too
> > many times when a fault cannot be reproduced and despite an 'obvious
> > fault in the source' being fixed and the problem never coming back,
> > without being able to reproduce and thus confirm that you have
> > eliminated the problem, you can't ever relax on a Saturday night! LOL
> > 
> > I hate the word 'random' when clients describe problems too!

The good thing is that most common space leaks are pretty reliable, so you 
shouldn't hear that word too often ;)

> 
> That were the fears that I wanted to address with "don't worry". :D
> 
> You see, the thing is this: any kind of error can happen at the
> customer's site, be it memory leaks, dangling pointers, division by zero
> or all the nasty bugs you put in your code. The programming language you
> choose influences both the kind of errors and the frequency of errors.
> Choosing Haskell over an imperative language like C, Pascal or Java
> drastically reduces logic bugs, and hence the total frequency of errors,
> even though you might be slightly worse off on the memory leak side,
> because laziness introduces a complication there.

A small caveat. Before you've gathered the experience to avoid the common 
traps, you can be more than 'slightly worse off on the memory leak side', 
so it's probably a good idea to hone your skills on smaller projects first.

> But that is a small price to pay for the general reduction in errors.
> 
> >> See also "On the reliability of programs",
> >> http://www.cs.utexas.edu/users/EWD/transcriptions/EWD03xx/EWD303.html
> 
> Dijkstra would be very happy about how close mathematics and Haskell
> are.
> 
> 
> 
> Regards,
> Heinrich Apfelmus



------------------------------

Message: 2
Date: Sun, 20 Mar 2011 16:02:14 +0100
From: Daniel Fischer <daniel.is.fisc...@googlemail.com>
Subject: Re: [Haskell-beginners] Lazy vs Strict ponderings...
To: beginners@haskell.org
Cc: s...@objitsu.com
Message-ID: <201103201602.14397.daniel.is.fisc...@googlemail.com>
Content-Type: Text/Plain;  charset="iso-8859-1"

On Sunday 20 March 2011 09:09:04, s...@objitsu.com wrote:
> > If you
> > want to produce quality software, it is best to be sure what you are
> > doing during the whole development process. There should be a set of
> > guidelines, on how to prevent space leaks.
> 
> I guess "being sure..." comes with experience of the language, like  
> any other.

Yes, possibly even more so (since your experience with C doesn't help much 
with coming to grips with a [mostly] pure lazy [non-strict, strictly 
speaking] functional language)

> I can 'think' in quite a few languages with complete  
> confidence, knowing that things will just work. I guess Haskell is a  
> bigger elephant sandwich!

Not so much bigger, more a different kind of animal.



------------------------------

Message: 3
Date: Sun, 20 Mar 2011 16:12:45 +0000
From: Sean Charles <s...@objitsu.com>
Subject: Re: [Haskell-beginners] Lazy vs Strict ponderings...
To: Daniel Fischer <daniel.is.fisc...@googlemail.com>
Cc: beginners@haskell.org
Message-ID: <4d86277d.2000...@objitsu.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

[snip]
> Not so much bigger, more a different kind of animal.
And I am a vegetarian! LOL

Can we pretend Haskell is a really big aubergine or something ? I think 
that might help ...
:)




------------------------------

Message: 4
Date: Sun, 20 Mar 2011 17:22:56 +0100
From: Daniel Fischer <daniel.is.fisc...@googlemail.com>
Subject: Re: [Haskell-beginners] Lazy vs Strict ponderings...
To: Sean Charles <s...@objitsu.com>
Cc: beginners@haskell.org
Message-ID: <201103201722.56412.daniel.is.fisc...@googlemail.com>
Content-Type: Text/Plain;  charset="iso-8859-1"

On Sunday 20 March 2011 17:12:45, Sean Charles wrote:
> [snip]
> 
> > Not so much bigger, more a different kind of animal.
> 
> And I am a vegetarian! LOL

But you were the first to mention elephant sandwiches.

> 
> Can we pretend Haskell is a really big aubergine or something ? I think
> that might help ...
> 
> :)

I'd rather think of it as a cauliflower (has more structure than an 
aubergine).



------------------------------

Message: 5
Date: Sun, 20 Mar 2011 16:56:17 +0000
From: Sean Charles <s...@objitsu.com>
Subject: Re: [Haskell-beginners] Lazy vs Strict ponderings...
To: Daniel Fischer <daniel.is.fisc...@googlemail.com>
Cc: beginners@haskell.org
Message-ID: <4d8631b1.6050...@objitsu.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed


> But you were the first to mention elephant sandwiches.
That's true. I cannot deny this.
>> Can we pretend Haskell is a really big aubergine or something ? I think
>> that might help ...
>>
>> :)
> I'd rather think of it as a cauliflower (has more structure than an
> aubergine).
Romanesco then. Feels right for Haskell

:)




------------------------------

Message: 6
Date: Sun, 20 Mar 2011 18:17:29 +0000
From: Paulo Pocinho <poci...@gmail.com>
Subject: [Haskell-beginners] "cabal install wxcore --enable-shared"
        Error
To: beginners@haskell.org
Message-ID:
        <AANLkTi=B7R0STZhuvwx2=JdVcpaT8FCy2HX3cRPA3-g=@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

I'm trying to build an application using "ghc -dynamic mywxapp.hs".

Everything not involving wx compiles with dll linking.
However, I can't build the required dynamic libraries for wxcore.

Using "cabal install wxcore --enable-shared" gives the following:

collect2: ld returned 1 exit status
Creating library file: dist\build\libHSwxcore-0.12.1.6-ghc7.0.2.dll.a
cabal: Error: some packages failed to install:
wxcore-0.12.1.6 failed during the building phase. The exception was:
ExitFailure 1

Using "cabal install wxcore --enable-shared  --enable-split-objs"
gives the following:

E:\Tools\Haskell Platform\2011.2.0.0\mingw\bin\ld.exe: BFD (GNU
Binutils) 2.20.51.20100613 internal
error, aborting at ../../binutils-2.20.51/bfd/coffcode.h line 954 in
handle_COMDAT

E:\Tools\Haskell Platform\2011.2.0.0\mingw\bin\ld.exe: Please report this bug.

cabal: Error: some packages failed to install:
wxcore-0.12.1.6 failed during the building phase. The exception was:
ExitFailure 1

Is it possible to fix?



------------------------------

Message: 7
Date: Sun, 20 Mar 2011 23:51:38 +0530
From: C K Kashyap <ckkash...@gmail.com>
Subject: Re: [Haskell-beginners] Question about functors (or maybe
        not...)
To: Felipe Almeida Lessa <felipe.le...@gmail.com>
Cc: beginners <beginners@haskell.org>
Message-ID:
        <AANLkTi=FQbH5GD7vQhzzaaKQCbVEih6N-qzQet94P=1...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hi Patrick,
You probably have already looked at
http://www.haskell.org/haskellwiki/Haskore
Regards,
Kashyap
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110320/21396f9b/attachment-0001.htm>

------------------------------

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 33, Issue 29
*****************************************

Reply via email to