Send Beginners mailing list submissions to
        [email protected]

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
        [email protected]

You can reach the person managing the list at
        [email protected]

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


Today's Topics:

   1. Re:  exceptions and stacks (Amy de Buitl?ir)
   2. Re:  exceptions and stacks (Emmanuel Touzery)
   3. Re:  exceptions and stacks (Emmanuel Touzery)
   4. Re:  exceptions and stacks (Emmanuel Touzery)
   5. Re:  exceptions and stacks (Emmanuel Touzery)


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

Message: 1
Date: Tue, 6 Nov 2012 17:33:46 +0000 (UTC)
From: Amy de Buitl?ir <[email protected]>
Subject: Re: [Haskell-beginners] exceptions and stacks
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

Yes, I've had similar problems with that %$#*! "*** Exception: Prelude.head:
empty list" exception. When I was newer to Haskell, I was very worried about how
often I might encounter that sort of problem. If it gives you any hope or
comfort, over time I haven't found this to be much too of a problem in practice.

In addition to the debugger, another valuable tool is Debug.Trace (see
http://hackage.haskell.org/packages/archive/base/latest/doc/html/Debug-Trace.html).
It basically allows you to add some temporary debug print to your code. I find
it particularly useful that "empty list" exception.




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

Message: 2
Date: Tue, 6 Nov 2012 20:34:50 +0100
From: Emmanuel Touzery <[email protected]>
Subject: Re: [Haskell-beginners] exceptions and stacks
To: [email protected]
Message-ID:
        <CAC42Re=w28vgkphjbzvnnkok2beb68vhfvagsyyjxycqatt...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

well it certainly requires will to build with profiling.
i had to reinstall all my cabal packages with profiling enabled, which i
finally managed to do now..

and now it tells me:
ghc -prof -auto-all Prog.hs

    Dynamic linking required, but this is a non-standard build (eg. prof).
    You need to build the program twice: once the normal way, and then
    in the desired way using -osuf to set the object file suffix.

Ah well.. I'll fight some more with this later. Not exactly "out of the
box"...

Emmanuel

On Tue, Nov 6, 2012 at 1:02 PM, Ozgur Akgun <[email protected]> wrote:

> Hi Emmanuel,
>
> It is indeed good practice to write total programs in general. However, I
> understand the need for stack traces in practice.
>
> There are some slides by Simon Marlow on the issue, ironically using your
> example in the title.
>
> In short: check the -xc flag in
> http://www.haskell.org/ghc/docs/7.0.1/html/users_guide/runtime-control.html
>
> Hope this helps,
> Ozgur
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20121106/7deeabc6/attachment-0001.htm>

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

Message: 3
Date: Tue, 6 Nov 2012 21:30:26 +0100
From: Emmanuel Touzery <[email protected]>
Subject: Re: [Haskell-beginners] exceptions and stacks
To: [email protected]
Message-ID:
        <CAC42Ren_WmqLHYHGgPr=fdasqaflq5g9jit7iklvqzmr3p3...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

OK apparently i just needed to build normally then again with:

 ghc -prof -auto-all -osuf prof *.hs

Well the instructions were clear but it was after the big fight with cabal.

Well now the executable is 47Mb compared to 23Mb before, but if I'll get
the stack it's worth it. It's running now, it takes a while before it hits
the crash.

Emmanuel

On Tue, Nov 6, 2012 at 8:34 PM, Emmanuel Touzery <[email protected]> wrote:

> well it certainly requires will to build with profiling.
> i had to reinstall all my cabal packages with profiling enabled, which i
> finally managed to do now..
>
> and now it tells me:
> ghc -prof -auto-all Prog.hs
>
>     Dynamic linking required, but this is a non-standard build (eg. prof).
>     You need to build the program twice: once the normal way, and then
>     in the desired way using -osuf to set the object file suffix.
>
> Ah well.. I'll fight some more with this later. Not exactly "out of the
> box"...
>
> Emmanuel
>
>
> On Tue, Nov 6, 2012 at 1:02 PM, Ozgur Akgun <[email protected]> wrote:
>
>> Hi Emmanuel,
>>
>> It is indeed good practice to write total programs in general. However, I
>> understand the need for stack traces in practice.
>>
>> There are some slides by Simon Marlow on the issue, ironically using your
>> example in the title.
>>
>> In short: check the -xc flag in
>> http://www.haskell.org/ghc/docs/7.0.1/html/users_guide/runtime-control.html
>>
>> Hope this helps,
>> Ozgur
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20121106/caf47744/attachment-0001.htm>

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

Message: 4
Date: Tue, 6 Nov 2012 22:37:48 +0100
From: Emmanuel Touzery <[email protected]>
Subject: Re: [Haskell-beginners] exceptions and stacks
To: [email protected]
Message-ID:
        <CAC42Rekt9Wy2CVgzCY5LmRJUXLdWJsOrcsHMRs=guego+uu...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

so in the end I had to build the program with:

 ghc -prof -auto-all -rtsopts -osuf prof *.hs

so also -rtsopts. After the simple ghc *.hs build.

then I run it with:

+RTS -xc -RTS

in the command-line.

but it doesn't appear to work properly, I guess I didn't quite compile or
run it correctly. It constantly displays me some stack position during the
whole runtime even when there is no problem.
When the real problem comes, it still displays the same stack it did for
the whole runtime, but there is no "head" in that function.

I'll probably end up debugging this one "by hand", but I would really would
like to have a general solution for the problem for the future, where
tooling would help me...

annotating/modifying my code... it really seems wrong in this case :-/

On Tue, Nov 6, 2012 at 8:34 PM, Emmanuel Touzery <[email protected]> wrote:

> well it certainly requires will to build with profiling.
> i had to reinstall all my cabal packages with profiling enabled, which i
> finally managed to do now..
>
> and now it tells me:
> ghc -prof -auto-all Prog.hs
>
>     Dynamic linking required, but this is a non-standard build (eg. prof).
>     You need to build the program twice: once the normal way, and then
>     in the desired way using -osuf to set the object file suffix.
>
> Ah well.. I'll fight some more with this later. Not exactly "out of the
> box"...
>
> Emmanuel
>
>
> On Tue, Nov 6, 2012 at 1:02 PM, Ozgur Akgun <[email protected]> wrote:
>
>> Hi Emmanuel,
>>
>> It is indeed good practice to write total programs in general. However, I
>> understand the need for stack traces in practice.
>>
>> There are some slides by Simon Marlow on the issue, ironically using your
>> example in the title.
>>
>> In short: check the -xc flag in
>> http://www.haskell.org/ghc/docs/7.0.1/html/users_guide/runtime-control.html
>>
>> Hope this helps,
>> Ozgur
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20121106/1920b0eb/attachment-0001.htm>

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

Message: 5
Date: Tue, 6 Nov 2012 22:45:04 +0100
From: Emmanuel Touzery <[email protected]>
Subject: Re: [Haskell-beginners] exceptions and stacks
To: [email protected]
Message-ID:
        <CAC42Re=69oc7zzkahggpqbrw0qbtmxv0db8tjpxuumg1nf2...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

well studying it further it seems the output I got was:

<GHC.List.CAF>TvChannelsParse: Prelude.head: empty list

It was a bit difficult to extract it because the normal output of my
program is really flooded by extra text from the RTS options.

So I get this GHC.List.CAF extra information; not particularly useful (I
mean for sure the head fails in GHC.List, I already knew that). I see
others got the same as I did:
http://www.haskell.org/pipermail/haskell-cafe/2008-February/040053.html

 So maybe there is nothing to expect from that profiling trick after all...
>From what I can tell on the link that I found, the person ended up using a
third party library to track the problem. If there is nothing builtin, I'll
just mark head lines in my code to find the culprit, but it really seems
wrong and disappointing from a modern language if there is no better way.

emmanuel


On Tue, Nov 6, 2012 at 10:37 PM, Emmanuel Touzery <[email protected]>wrote:

> so in the end I had to build the program with:
>
>  ghc -prof -auto-all -rtsopts -osuf prof *.hs
>
> so also -rtsopts. After the simple ghc *.hs build.
>
> then I run it with:
>
> +RTS -xc -RTS
>
> in the command-line.
>
> but it doesn't appear to work properly, I guess I didn't quite compile or
> run it correctly. It constantly displays me some stack position during the
> whole runtime even when there is no problem.
> When the real problem comes, it still displays the same stack it did for
> the whole runtime, but there is no "head" in that function.
>
> I'll probably end up debugging this one "by hand", but I would really
> would like to have a general solution for the problem for the future, where
> tooling would help me...
>
> annotating/modifying my code... it really seems wrong in this case :-/
>
> On Tue, Nov 6, 2012 at 8:34 PM, Emmanuel Touzery <[email protected]>wrote:
>
>> well it certainly requires will to build with profiling.
>> i had to reinstall all my cabal packages with profiling enabled, which i
>> finally managed to do now..
>>
>> and now it tells me:
>> ghc -prof -auto-all Prog.hs
>>
>>     Dynamic linking required, but this is a non-standard build (eg. prof).
>>     You need to build the program twice: once the normal way, and then
>>     in the desired way using -osuf to set the object file suffix.
>>
>> Ah well.. I'll fight some more with this later. Not exactly "out of the
>> box"...
>>
>> Emmanuel
>>
>>
>> On Tue, Nov 6, 2012 at 1:02 PM, Ozgur Akgun <[email protected]> wrote:
>>
>>> Hi Emmanuel,
>>>
>>> It is indeed good practice to write total programs in general. However,
>>> I understand the need for stack traces in practice.
>>>
>>> There are some slides by Simon Marlow on the issue, ironically using
>>> your example in the title.
>>>
>>> In short: check the -xc flag in
>>> http://www.haskell.org/ghc/docs/7.0.1/html/users_guide/runtime-control.html
>>>
>>> Hope this helps,
>>> Ozgur
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20121106/167a1945/attachment.htm>

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

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 53, Issue 10
*****************************************

Reply via email to