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:  99problems: different response from ghci <--> runhaskell
      / ghc (GiGi)
   2. Re:  Backtrace when a certain location in the code is
      executed (alex-hask...@copton.net)
   3. Re:  Error compiling OpenGL tutorial part 2 (Andrey Yankin)
   4. Re:  Backtrace when a certain location in the code is
      executed (Nathan H?sken)
   5. Re:  Backtrace when a certain location in the code is
      executed (Brandon Allbery)
   6. Re:  Error compiling OpenGL tutorial part 2 (Darren Grant)


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

Message: 1
Date: Fri, 17 Aug 2012 14:31:59 +0200
From: GiGi <looee...@gmail.com>
Subject: Re: [Haskell-beginners] 99problems: different response from
        ghci <--> runhaskell / ghc
To: Andres L?h <and...@well-typed.com>
Cc: beginners@haskell.org
Message-ID:
        <caep_llx+6bposhsgendewi2aksnha3jkxsxz6gfwodx7yyp...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

thanks Andres

On Fri, Aug 17, 2012 at 11:35 AM, Andres L?h <and...@well-typed.com> wrote:

> Hi.
>
> > So, my question is:  _where_ is the difference between ghci / runhaskell?
>
> See here:
>
>
> http://www.haskell.org/ghc/docs/latest/html/users_guide/interactive-evaluation.html#extended-default-rules
>
> Cheers,
>   Andres
>
> --
> Andres L?h, Haskell Consultant
> Well-Typed LLP, http://www.well-typed.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120817/5f32369d/attachment-0001.htm>

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

Message: 2
Date: Fri, 17 Aug 2012 14:45:06 +0200
From: alex-hask...@copton.net
Subject: Re: [Haskell-beginners] Backtrace when a certain location in
        the code is executed
To: beginners@haskell.org
Message-ID: <20120817124506.GA3329@apus>
Content-Type: text/plain; charset="iso-8859-1"

Hi

On Thu, Aug 16, 2012 at 04:31:47PM +0200, Nathan H?sken wrote:
> I am trying to understand haskell program not written by me.
> During runtime one function is called with parameters which makes the
> function throw an error. I want to know from where the function is called.

The execution model of Haskell is completely different. Actually, code
locations are not executed. Instead, expressions are evaluated. And to
make things worse, this evaluation is performed lazyly. So there is no
stack trace as you know it from C++.

There is one nice hack, though, that often helps in such situations. The
module Debug.Trace exports a handy function 'trace :: String -> a -> a'.
It always returns the second argument but outputs the String to stdout
as a side effect. The hack is, that this function can be called in pure
code! (No IO type involved).

So, go to all locations in your code where you call the function is
question and wrap the calls into a trace each.

Greetings

Alex
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120817/96c7238a/attachment-0001.pgp>

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

Message: 3
Date: Fri, 17 Aug 2012 18:06:22 +0400
From: Andrey Yankin <yankin...@gmail.com>
Subject: Re: [Haskell-beginners] Error compiling OpenGL tutorial part
        2
To: Darren Grant <therealklu...@gmail.com>
Cc: beginners@haskell.org
Message-ID:
        <canxq4z2ommm-0tvosgw0n6an2q4h6vti1pq5wtlzmjqdkwr...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi!

Try to group points and 7 with parentheses or put $ before points,
since points became a function at this step in tutorial.

But error message is a real mystery.
How could the actual type of mapM_ be unit?
Can somebody here explain this, please?
Is unit a monad?


2012/8/16 Darren Grant <therealklu...@gmail.com>:
> I am currently following the OpenGL tutorial here:
>
> http://www.haskell.org/haskellwiki/OpenGLTutorial2
>
> But in the current incarnation of Display.hs
> (http://pastebin.com/g4NekDVh) I am getting the following error:
>
>
> $ cabal install
> Resolving dependencies...
> Configuring mygl-0.1...
> Preprocessing executables for mygl-0.1...
> Building mygl-0.1...
> [3 of 5] Compiling Display          ( Display.hs,
> dist\build\mygl\mygl-tmp\Display.o )
>
> Display.hs:13:9:
>     Couldn't match expected type `IO a0' with actual type `()'
>     In the return type of a call of `mapM_'
>     In a stmt of a 'do' expression:
>         mapM_
>           (\ (x, y, z)
>              -> preservingMatrix
>               $ do { color
>                    $ Color3 ((x + 1.0) / 2.0) ((y + 1.0) / 2.0) ((z +
> 1.0) / 2.0);
>                      translate $ Vector3 x y z;
>                    cube (0.1 :: GLfloat) })
>           points
>           7
>     In the expression:
>       do { clear [ColorBuffer];
>            scale 0.7 0.7 (0.7 :: GLfloat);
>            mapM_
>              (\ (x, y, z)
>                 -> preservingMatrix
>                  $ do { color
>                       $ Color3 ((x + 1.0) / 2.0) ((y + 1.0) / 2.0) ((z
> + 1.0) / 2.0);
>                       .... })
>              points
>              7;
>            flush }
> cabal.exe: Error: some packages failed to install:
> mygl-0.1 failed during the building phase. The exception was:
> ExitFailure 1
>
>
>
> Not being too familiar with the Haskell syntax I'm not sure how to go
> about decomposing the code to find the source of the problem.
>
> Is there any general advice that might help me with this sort of situation?
>
>
> Thank you!
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners



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

Message: 4
Date: Fri, 17 Aug 2012 16:35:52 +0200
From: Nathan H?sken <nathan.hues...@posteo.de>
Subject: Re: [Haskell-beginners] Backtrace when a certain location in
        the code is executed
To: beginners@haskell.org
Message-ID: <502e56c8.8080...@posteo.de>
Content-Type: text/plain; charset=ISO-8859-1

On 08/17/2012 02:45 PM, alex-hask...@copton.net wrote:
> Hi
> 
> On Thu, Aug 16, 2012 at 04:31:47PM +0200, Nathan H?sken wrote:
>> I am trying to understand haskell program not written by me.
>> During runtime one function is called with parameters which makes the
>> function throw an error. I want to know from where the function is called.
> 
> The execution model of Haskell is completely different. Actually, code
> locations are not executed. Instead, expressions are evaluated. And to
> make things worse, this evaluation is performed lazyly. So there is no
> stack trace as you know it from C++.

Well, yes. But one could trace when a value is evaluated and for what it
is evaluated (recursively to get something like a backtrace).

> There is one nice hack, though, that often helps in such situations. The
> module Debug.Trace exports a handy function 'trace :: String -> a -> a'.
> It always returns the second argument but outputs the String to stdout
> as a side effect. The hack is, that this function can be called in pure
> code! (No IO type involved).
>
> So, go to all locations in your code where you call the function is
> question and wrap the calls into a trace each.

That is nice, and can be pretty time-consuming for what I want to do.
On the other hand, in the current problem there are not many calls to
the function, so it should be doable :).

Thanks!
Nathan




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

Message: 5
Date: Fri, 17 Aug 2012 11:32:46 -0400
From: Brandon Allbery <allber...@gmail.com>
Subject: Re: [Haskell-beginners] Backtrace when a certain location in
        the code is executed
To: Nathan H?sken <nathan.hues...@posteo.de>
Cc: beginners@haskell.org
Message-ID:
        <cakfcl4vrmn1yy2ydsquumbek5io64aywzad0_sbbumr+xv+...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Thu, Aug 16, 2012 at 10:31 AM, Nathan H?sken <nathan.hues...@posteo.de>wrote:

> I am trying to understand haskell program not written by me.
> During runtime one function is called with parameters which makes the
> function throw an error. I want to know from where the function is called.
>

If this is an exception, as opposed to crashing with a signal, then you can
compile the program with profiling and pass it parameters "+RTS -xc" to see
the evaluation stack when the exception is thrown.  See the description of
the -xc RTS option at
http://www.haskell.org/ghc/docs/latest/html/users_guide/runtime-control.html#rts-options-debugging.

-- 
brandon s allbery                                      allber...@gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20120817/99501918/attachment-0001.htm>

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

Message: 6
Date: Fri, 17 Aug 2012 11:55:06 -0700
From: Darren Grant <therealklu...@gmail.com>
Subject: Re: [Haskell-beginners] Error compiling OpenGL tutorial part
        2
To: Andrey Yankin <yankin...@gmail.com>
Cc: beginners@haskell.org
Message-ID:
        <ca+jd6shp87pas238maskhpgvjva7g18rfc2nulj222jfckg...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi,

You're right it was order of operations with points leading to the
error. Without the application or parenthesizing '(points 7)' the
evaluation becomes '((mapM_ a points) 7)'.

I still don't fully understand the error though.


Thanks!



On Fri, Aug 17, 2012 at 7:06 AM, Andrey Yankin <yankin...@gmail.com> wrote:
> Hi!
>
> Try to group points and 7 with parentheses or put $ before points,
> since points became a function at this step in tutorial.
>
> But error message is a real mystery.
> How could the actual type of mapM_ be unit?
> Can somebody here explain this, please?
> Is unit a monad?
>
>
> 2012/8/16 Darren Grant <therealklu...@gmail.com>:
>> I am currently following the OpenGL tutorial here:
>>
>> http://www.haskell.org/haskellwiki/OpenGLTutorial2
>>
>> But in the current incarnation of Display.hs
>> (http://pastebin.com/g4NekDVh) I am getting the following error:
>>
>>
>> $ cabal install
>> Resolving dependencies...
>> Configuring mygl-0.1...
>> Preprocessing executables for mygl-0.1...
>> Building mygl-0.1...
>> [3 of 5] Compiling Display          ( Display.hs,
>> dist\build\mygl\mygl-tmp\Display.o )
>>
>> Display.hs:13:9:
>>     Couldn't match expected type `IO a0' with actual type `()'
>>     In the return type of a call of `mapM_'
>>     In a stmt of a 'do' expression:
>>         mapM_
>>           (\ (x, y, z)
>>              -> preservingMatrix
>>               $ do { color
>>                    $ Color3 ((x + 1.0) / 2.0) ((y + 1.0) / 2.0) ((z +
>> 1.0) / 2.0);
>>                      translate $ Vector3 x y z;
>>                    cube (0.1 :: GLfloat) })
>>           points
>>           7
>>     In the expression:
>>       do { clear [ColorBuffer];
>>            scale 0.7 0.7 (0.7 :: GLfloat);
>>            mapM_
>>              (\ (x, y, z)
>>                 -> preservingMatrix
>>                  $ do { color
>>                       $ Color3 ((x + 1.0) / 2.0) ((y + 1.0) / 2.0) ((z
>> + 1.0) / 2.0);
>>                       .... })
>>              points
>>              7;
>>            flush }
>> cabal.exe: Error: some packages failed to install:
>> mygl-0.1 failed during the building phase. The exception was:
>> ExitFailure 1
>>
>>
>>
>> Not being too familiar with the Haskell syntax I'm not sure how to go
>> about decomposing the code to find the source of the problem.
>>
>> Is there any general advice that might help me with this sort of situation?
>>
>>
>> Thank you!
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners@haskell.org
>> http://www.haskell.org/mailman/listinfo/beginners



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

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


End of Beginners Digest, Vol 50, Issue 21
*****************************************

Reply via email to