Re: [Haskell-cafe] Debugging
On 5/5/07, Stefan O'Rear [EMAIL PROTECTED] wrote: On Fri, May 04, 2007 at 10:44:15PM -0700, Ryan Dickie wrote: I've only written trivial applications and functions in haskell. But the title of this thread got me thinking. In an imperative language you have clear steps, states, variables to watch, etc. What techniques/strategies might one use for a functional language? I personally most often use a divide-and-conquer approach. I pick a point about halfway down the call stack, and add trace calls. If the subproblems are handled correctly, narrow scope to higher levels; otherwise narrow to lower levels. Repeat until you have a single misbehaving function. Isn't that called binary search, instead of divide-and-conquer? BTW, how about adding assertion in Haskell? Can it be done? (I've searched in my GHC 6.4.2 library documentation, and can't find 'assert') Is there any way to automatically clean all the mess I've done in debugging/asserting (like removing all trace/assert expressions) when I compile Haskell source code? Or should I create a simple program to remove them? Stefan -- Demi masa.. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Debugging
Sorry, replying myself. On 5/5/07, Monang Setyawan [EMAIL PROTECTED] wrote: BTW, how about adding assertion in Haskell? Can it be done? (I've searched in my GHC 6.4.2 library documentation, and can't find 'assert') This can be done using Assertions. Lines below are taken from the docs. Assertions assert :: Bool - a - a If the first argument evaluates to True, then the result is the second argument. Otherwise an AssertionFailed exception is raised, containing a String with the source file and line number of the call to assert. Assertions can normally be turned on or off with a compiler flag (for GHC, assertions are normally on unless optimisation is turned on with -O or the -fignore-asserts option is given). When assertions are turned off, the first argument to assert is ignored, and the second argument is returned as the result. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Debugging
Hi, I'm a beginner Haskell user. Is there any way to trace/debug the function application in GHC? -- Demi masa.. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Debuggingy
On 5/5/07, Stefan O'Rear [EMAIL PROTECTED] wrote: On Sat, May 05, 2007 at 11:36:16AM +0700, Monang Setyawan wrote: Hi, I'm a beginner Haskell user. Is there any way to trace/debug the function application in GHC? Absolutely! [EMAIL PROTECTED]:/tmp$ ghci X.hs ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | |GHC Interactive, version 6.7.20070502, for Haskell 98. / /_\\/ __ / /___| |http://www.haskell.org/ghc/ \/\/ /_/\/|_|Type :? for help. Loading package base ... linking ... done. [1 of 1] Compiling Main ( X.hs, interpreted ) Ok, modules loaded: Main. *Main :break fac Great!! Thanks, it really helps. I should update my GHC to the newest version (I use the old 6.4.2 with no break command) Is there any editor/IDE supporting this break command? It should be cooler if we can debug functions just by placing mark in the line. Stefan -- Demi masa.. -- Demi masa.. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe