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: How to understand the type "ShowS"? (Rustom Mody) 2. Re: Overwriting wxFrame::ProcessEvent in wxHaskell (Henk-Jan van Tuyl) 3. finding the exact instance of a function causing an error (Nathan H?sken) 4. Re: finding the exact instance of a function causing an error (Julian Arni) 5. :trace seems not to work in ghci (Nathan H?sken) ---------------------------------------------------------------------- Message: 1 Date: Wed, 25 Sep 2013 17:30:45 +0530 From: Rustom Mody <rustompm...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] How to understand the type "ShowS"? Message-ID: <CAJ+TeocxosisSaSAq1NXn3ubA9ZX7FGX=e9j-ukt6pzb-br...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" On Tue, Sep 24, 2013 at 3:45 PM, yi lu <zhiwudazhanjiang...@gmail.com>wrote: > Prelude> :i ShowS > type ShowS = String -> String -- Defined in `GHC.Show' > > It is a type of a function? I cannot understand this type, and don't know > how to create functions of this type. > > And this function "shows" > > Prelude> :i shows > shows :: Show a => a -> ShowS -- Defined in `GHC.Show' > > I don't know how this function works. > > Just attempting to give an imperative programmer's motivation for shows. Look at the picture at start of http://en.wikipedia.org/wiki/Linked_list which corresponds to the Haskell list a = [12,19,37] and 'a' would be a pointer pointing to the 12-node. Now if we wanted to add something -- say 8 -- before 12, its a simple operation: Make a new node containing 8, point it to the 12-node Assign a to this new node [Remember we are in imperative-land!!] This is a simple or constant-time operation However adding something to the end is harder: we have to start from a and walk down the list till the end and then mutate it to the new 8-node -- an O(n) operation where n is the length of the list. How can we have an O(1) add_to_end operation? Well in imperative land there are many approaches, one of which is that for every list like a, we also store an a_end pointing to the last element of a and then mutate that. This converts an O(n) operation into an O(1) operation at the cost of a mere extra pointer. shows is the same idea in FP-land! The haskell list a = [12,19,37] is as you surely know a = 12 : (19 : (37: [])) Replace the [] all the way in with an x and to make it valid lambda-bind it; ie a = \ x -> 12 : (19 : (37 : x)) a :: [Int] -> [Int] If the Int were Char that would be the Shows type And that lambda-exp basically constitutes your 'pointer-to-the-end' In particular with normal lists [12,19,37] ++ some_list needs 3 steps to walk down the first list However instead of [12,19,37] if we have the lambda-exp 'a' above we just need to do a some_list and we have append being done by a single beta reduction step! Voila! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20130925/403a52e7/attachment-0001.html> ------------------------------ Message: 2 Date: Wed, 25 Sep 2013 14:10:20 +0200 From: "Henk-Jan van Tuyl" <hjgt...@chello.nl> To: "Haskell Beginners Mailinglist" <beginners@haskell.org>, Nathan H?sken <nathan.hues...@posteo.de> Subject: Re: [Haskell-beginners] Overwriting wxFrame::ProcessEvent in wxHaskell Message-ID: <op.w3yurj1mpz0...@zen5.arnhem.chello.nl> Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes On Wed, 04 Sep 2013 10:48:10 +0200, Nathan H?sken <nathan.hues...@posteo.de> wrote: > I want that in wxHaskell to! But I do not know if and how I can > overwrite the ProcessEvent function of wxFrame in wxHaskell ... anyone > knows if there is a way? Maybe you can use the blog article "How does wxHaskell event handling work ? part 1" http://wewantarock.wordpress.com/2011/06/17/how-does-wxhaskell-event-handling-work-part-1/ It seems that there is no part 2 of this story. Regards, Henk-Jan van Tuyl -- Folding@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 Haskell programming -- ------------------------------ Message: 3 Date: Wed, 25 Sep 2013 23:57:38 +0200 From: Nathan H?sken <nathan.hues...@posteo.de> To: Haskell Beginners Mailinglist <beginners@haskell.org> Subject: [Haskell-beginners] finding the exact instance of a function causing an error Message-ID: <52435c52.6000...@posteo.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hey, I have a program, that, when I run it fails with: Main: Prelude.tail: empty list Can I somehow find out which exat instance of tail causes this error? I tried compiling with -prof and running with +RTX -xc, which gives me: *** Exception (reporting due to +RTS -xc): (THUNK_2_0), stack trace: GHC.List.CAF --> evaluated by: SYSTEM.SYSTEM *** Exception (reporting due to +RTS -xc): (THUNK_2_0), stack trace: GHC.List.CAF *** Exception (reporting due to +RTS -xc): (THUNK_2_0), stack trace: GHC.List.CAF Does not really help me ... Thanks! Nathan ------------------------------ Message: 4 Date: Wed, 25 Sep 2013 18:05:26 -0400 From: Julian Arni <jka...@mit.edu> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] finding the exact instance of a function causing an error Message-ID: <CANct4CRxs9zB=pgg7tg0fzxsjorb_zkypdju2avganyg7pn...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Try running the program with the ghci debugger and -fbreak-on-error<http://www.haskell.org/ghc/docs/7.6.2/html/users_guide/ghci-debugger.html#ghci-debugger-exceptions> . On Wed, Sep 25, 2013 at 5:57 PM, Nathan H?sken <nathan.hues...@posteo.de>wrote: > Hey, > > I have a program, that, when I run it fails with: Main: Prelude.tail: > empty list > > Can I somehow find out which exat instance of tail causes this error? > I tried compiling with -prof and running with +RTX -xc, which gives me: > > *** Exception (reporting due to +RTS -xc): (THUNK_2_0), stack trace: > GHC.List.CAF > --> evaluated by: SYSTEM.SYSTEM > *** Exception (reporting due to +RTS -xc): (THUNK_2_0), stack trace: > GHC.List.CAF > *** Exception (reporting due to +RTS -xc): (THUNK_2_0), stack trace: > GHC.List.CAF > > Does not really help me ... > > Thanks! > Nathan > ______________________________**_________________ > Beginners mailing list > Beginners@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/20130925/e87612bf/attachment-0001.html> ------------------------------ Message: 5 Date: Thu, 26 Sep 2013 12:35:51 +0200 From: Nathan H?sken <nathan.hues...@posteo.de> To: Haskell Beginners Mailinglist <beginners@haskell.org> Subject: [Haskell-beginners] :trace seems not to work in ghci Message-ID: <52440e07.1040...@posteo.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hey, I have a program I want to debug in ghci because it crashes with an exception. So I do: Prelude> :l Main Ok, modules loaded: Main, PlotDisplay, PlotDiagram, ForexData. Prelude Main> :set -fbreak-on-exception Prelude Main> :trace main (...) Stopped at <exception thrown> _exception :: e = _ [<exception thrown>] Prelude Main> :hist Empty history. Perhaps you forgot to use :trace? [<exception thrown>] Prelude Main> :back no more logged breakpoints [<exception thrown>] Prelude Main> :force _exception _exception = GHC.Exception.SomeException (GHC.Exception.ErrorCall "Prelude.tail: empty list") What could be the reason why :hist/:back/:trace are not working? Thanks! Nathan ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 63, Issue 39 *****************************************