[Haskell-cafe] Debugging with gdb?
Hi, As I don't know anything about Haskell, can I make a stupid question: Is there any method to create debug symbols for a Haskell program, and is it possible to debug with gdb? Thanks! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Debugging with gdb?
On Tue, Apr 12, 2011 at 11:59 PM, Svante Signell wrote: > Hi, > > As I don't know anything about Haskell, can I make a stupid question: Is > there any method to create debug symbols for a Haskell program, and is > it possible to debug with gdb? > You can run gdb on a Haskell program, but it's unlikely you'll learn anything useful unless you're a compiler writer trying to debug your compiler or runtime system. ghci (the interactive version of GHC) has a built-in debugger that may be the closest thing to what you're used to with gdb. There is also a small cottage industry of debuggers that are more tailored to the process of debugging a functional program. Cheers, Tim -- Tim Chevalier * http://cs.pdx.edu/~tjc/ * Often in error, never in doubt "an intelligent person fights for lost causes,realizing that others are merely effects" -- E.E. Cummings ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Debugging with gdb?
On 13 April 2011 07:59, Svante Signell wrote: > As I don't know anything about Haskell, can I make a stupid question: Is > there any method to create debug symbols for a Haskell program, and is > it possible to debug with gdb? You cannot create debug symbols. Things that are possible: 1. You may use the -debug flag to GHC to link with the debug RTS, which has full debugging information for GDB. Note that this only lets you debug the *RTS*, not any of the code you wrote 2. Use GDB to debug your Haskell code without giving it any symbols or understanding of the Haskell calling conventions. This is very difficult. Information on this is on the GHC wiki: http://hackage.haskell.org/trac/ghc/wiki/Debugging/CompiledCode?redirectedfrom=DebuggingGhcCrashes 3. Use the GHCi debugger, which does actually work surprisingly well: http://www.haskell.org/ghc/docs/7.0.3/html/users_guide/ghci-debugger.html Cheers, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RFC: Extendable and Easy-To-Use Logger (HLogger)
Jon, thanks for HLogger! For my (small) needs I was looking for a simple logging solution, and I couldn't get HSLogger to do what I wanted, whereas your simpleLogger fitted the bill perfectly. I suppose a good thing would be conditional buffering, as other noted: in development mode I want to get my log entries flushed to disk immediately, while in production I don't want to impact the performance of my running application by waiting for the logs. I didn't think that the invocations needed to be made easier: I just used "logNotice logger message", hard to do shorter. JP On Tue, Apr 12, 2011 at 11:45 PM, Henk-Jan van Tuyl wrote: > On Tue, 12 Apr 2011 19:10:09 +0200, Gregory Collins > wrote: > >> On Tue, Apr 12, 2011 at 6:40 PM, Jon Kristensen >> wrote: >>> >>> Hello Haskellers! >>> >>> As I have now implemented everything that I could think of, I would like >>> to >>> ask the Haskell community to give some feedback on HLogger so that I can >>> continuing improving it. Some questions: >>> >>> Do you have any general/architectural thoughts on things I might be doing >>> wrong? >> >> 1) Use "Text" as the string type, not "String" >> >> 2) Re: SimpleLogger: writing to and flushing the log file upon >> receiving each message is absolutely the wrong thing to do in >> high-performance code. Each write() is a context switch into the >> kernel, and doing it this way will kill your throughput (in messages >> per second). What we do in our webserver (which relies on >> high-throughput access logging) is to buffer messages to the log >> channel in memory, and perform the actual writes in a separate worker >> thread no more often than once every N seconds. > > If you want to know what the last thing was that your application was doing, > before it crashed (e.g. at the customers site), you better write every > message immediately to disk. > > Regards, > Henk-Jan van Tuyl > > > -- > http://Van.Tuyl.eu/ > http://members.chello.nl/hjgtuyl/tourdemonad.html > -- > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- JP Moresmau http://jpmoresmau.blogspot.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Using DPH
> Yeah, the Repa fold and sum functions just use the equivalent Data.Vector > ones. They're not parallelised and I haven't looked at the generated code. > I'll add a ticket to the trac to fix these, but won't have time to work on it > myself in the near future. > Ok. Thank you for your help. I will try again with the future versions. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RFC: Extendable and Easy-To-Use Logger (HLogger)
On Tue, Apr 12, 2011 at 11:45 PM, Henk-Jan van Tuyl wrote: > > If you want to know what the last thing was that your application was doing, > before it crashed (e.g. at the customers site), you better write every > message immediately to disk. Yes, I suppose it would depend on your use case whether you wanted to optimize for throughput or for latency to secondary storage. I just know from experience that for high-throughput server applications, writing each message to disk is going to introduce unacceptable context-switching overhead. G -- Gregory Collins ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Debugging with gdb?
Max and Tim, Thank you for your replies, continuation below. On Wed, 2011-04-13 at 08:27 +0100, Max Bolingbroke wrote: > On 13 April 2011 07:59, Svante Signell wrote: > > As I don't know anything about Haskell, can I make a stupid question: Is > > there any method to create debug symbols for a Haskell program, and is > > it possible to debug with gdb? > > You cannot create debug symbols. Things that are possible: > > 1. You may use the -debug flag to GHC to link with the debug RTS, > which has full debugging information for GDB. Note that this only lets > you debug the *RTS*, not any of the code you wrote > > 2. Use GDB to debug your Haskell code without giving it any symbols > or understanding of the Haskell calling conventions. This is very > difficult. Information on this is on the GHC wiki: > http://hackage.haskell.org/trac/ghc/wiki/Debugging/CompiledCode?redirectedfrom=DebuggingGhcCrashes > > 3. Use the GHCi debugger, which does actually work surprisingly well: > http://www.haskell.org/ghc/docs/7.0.3/html/users_guide/ghci-debugger.html The problem is that I'm trying to bootstrap ghc to 6.10.1 using 6.8.2 under Debian GNU/Hurd. Yes, I know these packages are old but so far we only have a working 6.8.2 version and 6.10.1 is the latest version not requiring 6.10 to bootstrap. Cross-compiling is another, not yet tested, alternative. The problem is that the configure step hangs when compiling the random library, and I've tried a lot of settings, the hang is at the same place. A stripped down call is: cd libraries/random: ../cabal-bin /usr/bin/ghc6 ../bootstrapping.conf configure --verbose=3 --with-compiler =../../ghc/stage1-inplace/ghc --with-hc-pkg=../../utils/ghc-pkg/install-inplace/bin/ghc-pkg Configuring random-1.0.0.1... Creating dist (and its parents) ("../../ghc/stage1-inplace/ghc",["--numeric-version"]) ../../ghc/stage1-inplace/ghc is version 6.10.1 ("../../utils/ghc-pkg/install-inplace/bin/ghc-pkg",["--version"]) ../../utils/ghc-pkg/install-inplace/bin/ghc-pkg is version 6.10.1 ("../../ghc/stage1-inplace/ghc",["--supported-languages"]) Reading installed packages... ("../../utils/ghc-pkg/install-inplace/bin/ghc-pkg",["dump","--global"]) ^C <- hang here! The last part of the gdb backtrace shows: #5 0x011d4ce0 in __libc_read (fd=DWARF-2 expression error: DW_OP_reg operations must be used either alone or in conjuction with DW_OP_piece or DW_OP_bit_piece. ) at ../sysdeps/mach/hurd/read.c:27 #6 0x084919c8 in s9qJ_ret () #7 0x0861f842 in StgRun () #8 0x087c44e0 in ?? () I assume the calling program is cabal-bin, but no debug symbols are available. (I have debug versions of libc/gnumach/hurd installed). Setting a breakpoint in the calling program does not seem to be possible. Any hints? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Debugging with gdb?
Hello Svante, I have a few recommendations, places where I'd check: 1. Consult the arguments passed to read() usign GDB (your libc has debugging symbols) and see if they are obviously wrong. It seems more plausible that they are something that would be right for Linux, but not so right for Hurd. 2. Take the source code for ghc-pkg, and start adding debug prints, checking to see if the print is triggered or not (it will be useful if you can figure out what command you can run to just recompile ghc-pkg). See if you can reduce the program to a minimal one that still hangs. 3. Compile GHC with the flag -ddump-stg, and pipe all of this output to a file. With any luck, the block s9qJ will have been present during this stage, at which point you can use it to trace back to a file. Note that due to lazy evaluation, s9qJ is probably /not/ actually the culprit, which is why I recommend doing (2) first; it's a lot easier to wade around smaller bits of code. Another recommendation is to bootstrap 6.8.3. (the last 6.8 release) first, before attempting 6.10.1. Edward ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Syntastic support for cabal
Hi all I'm using Haskell mode for Vim, as well as syntastic. I've found syntastic particularly useful as I'm quite new to Haskell and sometimes get the types of my functions wrong. When working on Cabal packages however, syntastic marks import statements which import modules local to the cabal package as being incorrect because the module cannot be found. Has anyone solved this, or do you have pointers on how I can? Thanks -- Luke Randall Sent with Sparrow ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Syntastic support for cabal
On Wednesday 13 April 2011 at 1:34 PM, Luke Randall wrote: > I'm using Haskell mode for Vim, as well as syntastic. I've found syntastic > particularly useful as I'm quite new to Haskell and sometimes get the types > of my functions wrong. > > When working on Cabal packages however, syntastic marks import statements > which import modules local to the cabal package as being incorrect because > the module cannot be found. Has anyone solved this, or do you have pointers > on how I can? > > > > I forgot to mention that it does this by setting the following in Vim: let makeprg = 'ghc '.shellescape(expand('%')).' -e :q' let errorformat = '%-G\\s%#,%f:%l:%c:%m,%E%f:%l:%c:,%Z%m,' ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Generating random graph
Hi Mitar, > I have made this function to generate a random graph for > Data.Graph.Inductive library: > > generateGraph :: Int -> IO (Gr String Double) > generateGraph graphSize = do > when (graphSize < 1) $ throwIO $ AssertionFailed $ "Graph size out > of bounds " ++ show graphSize > let ns = map (\n -> (n, show n)) [1..graphSize] > es <- fmap concat $ forM [1..graphSize] $ \node -> do > nedges <- randomRIO (0, graphSize) > others <- fmap (filter (node /=) . nub) $ forM [1..nedges] $ \_ -> > randomRIO (1, graphSize) > gen <- getStdGen Others have already remarked that you could implement this as a pure function. However, the mistake is the use of getStdGen here, which is (almost?) never what you need: two consecutive valls of getStdGen will return the same generator. You should call newStdGen instead. Best regards, Bertram ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Higher-kinded Quantification
Thanks! The issue with eta-reduction had been confusing me... Best, Leon On Tue, Apr 12, 2011 at 3:35 PM, Dan Doel wrote: > On Tuesday 12 April 2011 11:27:31 AM Leon Smith wrote: >> I think impredicative polymorphism is actually needed here; if I write >> ... >> Then I get a type error >> ... > > I'm not going to worry about the type error, because that wasn't what I had in > mind for the types. The type for loop I had in mind was: > > [i] -> Iterator i o m a -> Iterator i o m a > > Then, feedPure cracks open the first (forall m. ...), instantiates it to the m > for the result, and runs loop on it. If we had explicit type application, it'd > look like: > > feedPure l it = /\m -> loop l (it@m) > > but as it is it's just: > > feedPure l it = loop l it > > Which cannot be eta reduced. > >> But what I find rather befuddling is the kind error: >> > feedPure' :: [i] -> Iterator i o (forall (m :: * -> *) . m) a -> Iterator >> > i o (forall (m :: * -> *) . m) a feedPure' = undefined >> >> Iterator.hs:193:58: >> `m' is not applied to enough type arguments >> Expected kind `*', but `m' has kind `* -> *' >> In the type signature for `feedPure'': >> feedPure' :: [i] >> -> Iterator i o (forall m :: (* -> *). m) a >> -> Iterator i o (forall m :: (* -> *). m) a >> >> Is impredicative polymorphism restricted to the kind *? > > The problem is that (forall (m :: * -> *). m) is not a valid type, and forall > is not a valid way to construct things with kind * -> *. You have: > > m :: * -> * |- T[m] :: * ==> |- (forall (m :: * -> *). T[m]) :: * > > but that is the only way forall works. > > -- Dan > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Service Component Architecture and Distributed Haskell
Hi all. There's recently been some talk about distributed haskell, but what I wish to see is interest from an experienced member of the Haskell community in implementing Haskell components with SCA/Tuscany. Please see this and consider it, it'd be great to be able to use Haskell in the same project with Java/Scala. Thanks. Link: http://www.haskell.org/pipermail/haskell/2010-April/022004.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] IO and Cont as monads
2011/4/12 Burak Ekici : > Dear List, > > I am quite new in Haskell's categorical manner of programming. However I > have enough knowledge in Category Theory. > I want to ask a question, maybe very well-known one by some of you, about > monads of Haskell. > > For the type constructors like Maybe and [], I managed to prove that > together with 2 natural transformations (bind + return), both of these > triples construct a monad. But when I try to prove that IO and Cont type > constructors with the same natural transformations (bind + return) are > monads as well, it was failed. > > Here my question is: Is there anyone who knows how to prove that IO and Cont > are monads with satisfing following properties: IO doesn't obey the monad laws, due to the presence of seq in Haskell. Sad but true... Cheers, Tim -- Tim Chevalier * http://cs.pdx.edu/~tjc/ * Often in error, never in doubt "an intelligent person fights for lost causes,realizing that others are merely effects" -- E.E. Cummings ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Fucntion composing
Adam Krauze schrieb: > Hello, > as I am newbie to Haskell and my introductory question is: > > given functions say f and g with type signatures > > f :: (Num a) => [a] -> [a] -> [(a,a)] // f takes two lists and zips them > into one in some special way > g :: (Num a) => a -> [(a,a)] -> [a] // g using some Num value calculates > list of singletons from list of pairs > > of course g 0 :: (Num a) => [(a,a)] ->[a] > > now I want to create function h :: (Num a) => [a] -> [a] -> [a] in such way > > that (g 0) consumes output of f. > > But when I try > > Prelude> :t (g 0).f http://www.haskell.org/haskellwiki/Composing_functions_with_multiple_values ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell Weekly News: Issue 177
Welcome to issue 177 of the HWN, a newsletter covering developments in the [1]Haskell community. This release covers the week of April 3 to 9, 2011. You can find a HTML rendition of this issue at: http://bit.ly/hR2sMB Announcements Brent Yorgey [2]sent out a call for contributions for the second edition of Typeclassopedia. Roel van Dijk started what became a popular[3]thread on the mailing list about encodings of Haskell source files. What would you like to see here? I have gotten mixed feedback on what constitutes interesting items for the "announcements" section of the mailing list. Some have pointed out that package announcements tend to be noisy and not all that interesting to the community at large, or that have a bias towards only pointing out packages where the maintainer decides to send an email to the mailing list. What do *you* think? How about the "calls for papers"? Do those catch your attention? Let me hear what you think. Quotes of the Week * ion: Itâs a well-known historical fact cave men writing Haskell hated the ASCII pseudoglyphs. * shapr: I persuaded academics to show up and hang out. [...] I told the academics that there were academics worth chatting with on #haskell :-) * pjscott: If you really want to see something ridiculous, try looking at the auto-generated library documentation for anything involving regular expressions. The type declarations in Text.Regex.TDFA are like something H. P. Lovecraft might write about. * monochrom: the road to haskell is paved with good abstractions Top Reddit Stories * Typeclassopedia second edition: call for contributions From (byorgey.wordpress.com), scored 53 with 1 comments. Read on [4]reddit. Read the [5]original post. * High-Performance Web Applications In Haskell : Gregory Collins : QCon London :: PDF From (qconlondon.com), scored 45 with 8 comments. Read on [6]reddit. Read the [7]original post. * Haskell For the Cloud (new paper by Jeff Epstein, Andrew Black, and and Simon Peyton Jones) From (research.microsoft.com), scored 41 with 23 comments. Read on [8]reddit. Read the [9]original post. * Yhc is dead !? From (yhc06.blogspot.com), scored 32 with 27 comments. Read on [10]reddit. Read the [11]original post. * What is a functional language? :: Robert Harper From (existentialtype.wordpress.com), scored 29 with 35 comments. Read on [12]reddit. Read the [13]original post. * Functions are values From (existentialtype.wordpress.com), scored 27 with 16 comments. Read on [14]reddit. Read the [15]original post. * Understanding practical API design, static typing and functional programming. From (blog.tmorris.net), scored 27 with 2 comments. Read on [16]reddit. Read the [17]original post. * Platform Robots in Nikki and the Robots: a Haskell platform game From (joyridelabs.de), scored 22 with 3 comments. Read on [18]reddit. Read the [19]original post. * A Model for Denotative Continuous-Time Programming (AKA: FRP) From (creativelad.wordpress.com), scored 21 with 1 comments. Read on [20]reddit. Read the [21]original post. * Type Kata: Local data type From (blog.ezyang.com), scored 19 with 3 comments. Read on [22]reddit. Read the [23]original post. Top StackOverflow Questions * [24]Difference between State, ST, IORef, and MVar votes: 16, answers: 3 * [25]Duality approaches in functional programming votes: 11, answers: 1 * [26]What are the main differences of language features between Haskell and the functional part of F#? [closed] votes: 9, answers: 5 * [27]Using the Maybe Monad in "reverse" in Haskell votes: 9, answers: 3 * [28]How to reason about space complexity in Haskell votes: 8, answers: 1 About the Haskell Weekly News To help create new editions of this newsletter, please send stories to dstc...@gmail.com. I'm in dire need of finding good "quotes of the week". If you happen to come across any, please don't hesitate to send it along. Until next time, Daniel Santa Cruz References 1. http://haskell.org/ 2. http://article.gmane.org/gmane.comp.lang.haskell.general/18636 3. http://article.gmane.org/gmane.comp.lang.haskell.cafe/87815 4. http://www.reddit.com/r/haskell/comments/ghs1x/typeclassopedia_second_edition_call_for/ 5. http://byorgey.wordpress.com/2011/04/03/call-for-contributions-second-edition-of-the-typeclassopedia/ 6. http://www.reddit.com/r/haskell/comments/gj7ud/highperformance_web_applications_in_haskell/ 7. http://qconlondon.com/dl/qcon-london-2011/slides/GregoryCollins_HighPerformanceWebApplicationsInHaske
[Haskell-cafe] Template Haskell tutorials?
Hi, The links to the supposedly brilliant Template Haskell tutorials by Bulat are broken. http://www.haskell.org/bz/thdoc.htm http://www.haskell.org/bz/th3.htm Does anyone know if these tutorials moved to somewhere else? greetings, Kenneth___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe