[Haskell-cafe] fgl Data.Graph examples

2008-05-15 Thread Anatoly Yakovenko
Can someone post some simple examples of using the Data.Graph library? So I can define a simple graph let g = buildG (1,2) [(1,2), (2,1)] but how do i label my edges and nodes? i want to be able to name my nodes, and add weights to the edges and be able to update those weights as well. Thanks,

Re: [Haskell-cafe] Two-iteration optimisation (was: GHC Predictability)

2008-05-15 Thread Luke Palmer
On Thu, May 15, 2008 at 8:45 PM, Andrew Coppin <[EMAIL PROTECTED]> wrote: > Yitzchak Gale wrote: >> >> >> And of course, you wouldn't want that: >> >> f xs = xs : map expensiveCalculation xs >> >> Please don't fuse those two loops into one. >> > > ...doesn't type check. Did you mean (++)? Hmm? Wh

Re: [Haskell-cafe] bottomless Top?

2008-05-15 Thread Conor McBride
On 16 May 2008, at 01:13, Jonathan Cast wrote: On 15 May 2008, at 4:29 AM, Conor McBride wrote: Replying slap-foreheadedly to own post... On 15 May 2008, at 11:56, Conor McBride wrote: Folks I'm also wondering whether it makes sense to have a "bottomless Top" type, with constructor _ and

Re: [Haskell-cafe] runInteractiveCommand: program ends before writing or reading all the output

2008-05-15 Thread Olivier Boudry
On Thu, May 15, 2008 at 6:23 PM, Duncan Coutts <[EMAIL PROTECTED]> wrote: > > On Thu, 2008-05-15 at 13:40 -0400, Olivier Boudry wrote: > As an example let me show you as an example how we use it in Cabal: > > Hi Duncan, I tried to place a "length text `seq`" before the mapM_ writeExport to force

Re: [Haskell-cafe] bottomless Top?

2008-05-15 Thread Jonathan Cast
On 15 May 2008, at 4:29 AM, Conor McBride wrote: Replying slap-foreheadedly to own post... On 15 May 2008, at 11:56, Conor McBride wrote: Folks I'm also wondering whether it makes sense to have a "bottomless Top" type, with constructor _ and lazy pattern _ (with (undefined :: Top) equal to _

Re: [Haskell-cafe] Re: Richer (than ascii) notation for haskell source?

2008-05-15 Thread Richard A. O'Keefe
On 15 May 2008, at 8:33 pm, Yitzchak Gale wrote: The point is that it is always best to keep language syntax as simple as possible, for many reasons. In the case of Unicode, that means staying as close as possible to the spirit of Unicode and minimizing our own ad hoc rules. In particular, Unic

Re: [Haskell-cafe] runInteractiveCommand: program ends before writing or reading all the output

2008-05-15 Thread Duncan Coutts
On Thu, 2008-05-15 at 13:40 -0400, Olivier Boudry wrote: > Hi all, > > It's the first time I use the runInteractiveCommand and I was probably > bitten by laziness. Yes. I think Philip diagnosed the problem correctly. As an example let me show you as an example how we use it in Cabal: rawSystem

Re: [Haskell-cafe] Fun with Darcs

2008-05-15 Thread Duncan Coutts
On Wed, 2008-05-14 at 21:49 +0100, Andrew Coppin wrote: > At this point, my best guess is that the unofficial Gtk2hs binary is > broken somehow. [Although I don't recall hearing anybody yelling about > it...] Maybe tomorrow I'll try again on my other box that has an older > GHC on it and see h

Re: Re[2]: [Haskell-cafe] Fun with Darcs

2008-05-15 Thread Duncan Coutts
On Thu, 2008-05-15 at 01:01 +0400, Bulat Ziganshin wrote: > Hello Andrew, > > Thursday, May 15, 2008, 12:49:32 AM, you wrote: > > > touch. Now, let's see what this IDE actually looks li-- oh you have GOT > > to be KIDDING me! It can't find the right GTK DLL?!? > > gtk2hs includes *developer* gt

Re: [Haskell-cafe] Write Haskell as fast as C. [Was: Re: GHC predictability]

2008-05-15 Thread Andrew Coppin
Mattias Bengtsson wrote: A good read. With Don, it usually is. ;-) Side point: Is the name "go" part of the idiom you mentioned? I sometimes use the same practise but usually just calls the worker the same as the real function with an added prime ('). I usually use "work". Same differ

Re: [Haskell-cafe] Write Haskell as fast as C. [Was: Re: GHC predictability]

2008-05-15 Thread Don Stewart
moonlite: > On Thu, 2008-05-15 at 11:31 -0700, Don Stewart wrote: > > I've written an extended post on how to understand and reliably optimise > > code like this, looking at it all the way down to the assembly. > > > > The result are some simple rules to follow for generated code as good > > as gc

Re: [Haskell-cafe] Two-iteration optimisation (was: GHC Predictability)

2008-05-15 Thread Andrew Coppin
Yitzchak Gale wrote: And of course, you wouldn't want that: f xs = xs : map expensiveCalculation xs Please don't fuse those two loops into one. ...doesn't type check. Did you mean (++)? In the case of "mean", the outer function in question is /, and that is a good candidate for fusion

Re: [Haskell-cafe] Write Haskell as fast as C. [Was: Re: GHC predictability]

2008-05-15 Thread Darrin Thompson
On Thu, May 15, 2008 at 2:31 PM, Don Stewart <[EMAIL PROTECTED]> wrote: > I've written an extended post on how to understand and reliably optimise > code like this, looking at it all the way down to the assembly. > That is a _fabulous_ article. I'm looking forward to the HOF installment. -- Darri

[Haskell-cafe] Re: Write Haskell as fast as C. [Was: Re: GHC predictability]

2008-05-15 Thread Achim Schneider
Don Stewart <[EMAIL PROTECTED]> wrote: > http://cgi.cse.unsw.edu.au/~dons/blog/2008/05/16#fast > Can you put this on the wiki, with the title "An example of how Haskell executes programs", right next to the "Haskell for C programmers" tutorial? It's really helpful for people who are more or l

Re: [Haskell-cafe] Write Haskell as fast as C. [Was: Re: GHC predictability]

2008-05-15 Thread Evan Laforge
> Side point: Is the name "go" part of the idiom you mentioned? I > sometimes use the same practise but usually just calls the worker the > same as the real function with an added prime ('). I like to use "go" or the name of the function with _ prepended. For threading state type things outside o

Re: [Haskell-cafe] getting output from shell commands

2008-05-15 Thread Olivier Boudry
Hi Philip, I just asked a question to the list about using runInteractiveCommand. You may find the code useful but will need to either remove the forkIO instruction or synchronize the two threads using a MVar to avoid the concurrency problem I had. You'll find the thread here: http://www.has

Re: [Haskell-cafe] getting output from shell commands

2008-05-15 Thread Jeff Polakow
Hello, > I would like to be able to run a shell command like curl and process the > output in my Haskell program, but I couldn't find anything helpful about it. > Try looking in System.Process. runInteractiveProcess should work for you. -Jeff --- This e-mail may contain confidential and/o

Re[2]: [Haskell-cafe] runInteractiveCommand: program ends before writing or reading all the output

2008-05-15 Thread Bulat Ziganshin
Hello Olivier, Thursday, May 15, 2008, 11:06:19 PM, you wrote: > As I could not find a function to wait on a ThreadId I used a MVar to > synchronize both threads. > Is this normal or have I missed the `waitOnThreadId` function? yes, it's common idiom -- Best regards, Bulat

[Haskell-cafe] getting output from shell commands

2008-05-15 Thread Philip Müller
Hi, I would like to be able to run a shell command like curl and process the output in my Haskell program, but I couldn't find anything helpful about it. Something like main = do args <- getArgs inp <- exec "curl" args putStrLn (processInput inp) would be very helpful

Re: [Haskell-cafe] runInteractiveCommand: program ends before writing or reading all the output

2008-05-15 Thread Olivier Boudry
On Thu, May 15, 2008 at 2:42 PM, Ronald Guida <[EMAIL PROTECTED]> wrote: > It looks like a simple race condition to me. You are using > "waitForProcess pid" to wait for runInteractiveCommand to finish, but > you don't seem to have anything that waits for createDefFile to > finish. > Thanks Ronal

Re: [Haskell-cafe] Write Haskell as fast as C. [Was: Re: GHC predictability]

2008-05-15 Thread Mattias Bengtsson
On Thu, 2008-05-15 at 11:31 -0700, Don Stewart wrote: > I've written an extended post on how to understand and reliably optimise > code like this, looking at it all the way down to the assembly. > > The result are some simple rules to follow for generated code as good > as gcc -O2. > > Enjoy, >

Re: [Haskell-cafe] runInteractiveCommand: program ends before writing or reading all the output

2008-05-15 Thread Philip Weaver
On Thu, May 15, 2008 at 11:42 AM, Ronald Guida <[EMAIL PROTECTED]> wrote: > It looks like a simple race condition to me. You are using > "waitForProcess pid" to wait for runInteractiveCommand to finish, but > you don't seem to have anything that waits for createDefFile to > finish. > Whoops, sorry

Re: [Haskell-cafe] runInteractiveCommand: program ends before writing or reading all the output

2008-05-15 Thread Ronald Guida
It looks like a simple race condition to me. You are using "waitForProcess pid" to wait for runInteractiveCommand to finish, but you don't seem to have anything that waits for createDefFile to finish. > main :: IO () > main = do > (file:_) <- getArgs > (_, out, _, pid) <- runInteractiveComman

[Haskell-cafe] Write Haskell as fast as C. [Was: Re: GHC predictability]

2008-05-15 Thread Don Stewart
> I offer up the following example: > > mean xs = sum xs / length xs > > Now try, say, "mean [1.. 1e9]", and watch GHC eat several GB of RAM. (!!) > > If we now rearrange this to > > mean = (\(s,n) -> s / n) . foldr (\x (s,n) -> let s' = s+x; n' = n+1 > in s' `seq` n' `seq` (s', n')) (0,0)

Re: [Haskell-cafe] runInteractiveCommand: program ends before writing or reading all the output

2008-05-15 Thread Philip Weaver
2008/5/15 Olivier Boudry <[EMAIL PROTECTED]>: > Hi all, > > It's the first time I use the runInteractiveCommand and I was probably > bitten by laziness. > > When I run the following program and send its output to a file using '>' > redirection I get the full output of the called process. But if I r

[Haskell-cafe] runInteractiveCommand: program ends before writing or reading all the output

2008-05-15 Thread Olivier Boudry
Hi all, It's the first time I use the runInteractiveCommand and I was probably bitten by laziness. When I run the following program and send its output to a file using '>' redirection I get the full output of the called process. But if I run it in the console I get only half of the output. As con

[Haskell-cafe] Re: Endianess

2008-05-15 Thread Achim Schneider
"Claus Reinke" <[EMAIL PROTECTED]> wrote: > then again, Jane Austen was happy enough writing about her > characters not being "one and twenty", so perhaps that is just a > lost art?-) > I'm quite content as long as I'm not "four twenty nineteen". -- (c) this sig last receiving data processing

Re: [Haskell-cafe] Richer (than ascii) notation for haskell source?

2008-05-15 Thread Eric Stansifer
> As to your assertion of discrimination against Greek: my point was that > mathematical notation *already* discriminates against speakers of Greek by > appropriating their alphabet for its own purposes, so if you want to enable > a mathematical-notation language mode it's already difficult to sup

[Haskell-cafe] Re: GHC API GSoc project (was: ANN: Haddock version 2.1.0)

2008-05-15 Thread Thomas Schilling
Thanks a lot for your comprehensive response, Claus! Per your suggestion, I started a GHC wiki page at http:// hackage.haskell.org/trac/ghc/wiki/GhcApiStatus. I added your comments and I will continue to add more things as I find them. I am closely following the Yi project and I am aware t

Re: [Haskell-cafe] FFI: newbie linking problem

2008-05-15 Thread Olivier Boudry
Hi all, I found a solution to my linking problem, but it's a bit scary and I'm wondering if there is a simpler way to do this: The solution comes from the following article: http://www.emmestech.com/moron_guides/moron1.html To get ghc to link my dll properly I had to do the following: 1. Cr

Re: [Haskell-cafe] Re: Richer (than ascii) notation for haskell source?

2008-05-15 Thread Andy Smith
2008/5/15 Yitzchak Gale <[EMAIL PROTECTED]>: > So I think the best and simplest idea is to make > the letter lambda a keyword. True, you need a space after it > then. You already need spaces between the variables after the > lambda, so anyway you might say that would be more consistent. You could

Re: [Haskell-cafe] Short circuiting and the Maybe monad

2008-05-15 Thread Graham Fawcett
On Wed, May 14, 2008 at 1:38 AM, Janis Voigtlaender <[EMAIL PROTECTED]> wrote: > Graham Fawcett wrote: >> >> Yes, but that's still a 'quick' short-circuiting. In your example, if >> 'n' is Nothing, then the 'f >>= g >>= h' thunks will not be forced >> (thanks to lazy evaluation), regardless of asso

Re: [Haskell-cafe] saner shootout programs

2008-05-15 Thread Richard Kelsall
Bulat Ziganshin wrote: Hello Richard, Yes it was just a plausible guess, but not contradicted by the experts. And that was using the Windows version of GHC so other versions may have better optimisation. I don't know how to check, maybe the experts can illuminate the subject? note that my let

Re: [Haskell-cafe] Re: Richer (than ascii) notation for haskell source?

2008-05-15 Thread Brandon S. Allbery KF8NH
On 2008 May 15, at 4:33, Yitzchak Gale wrote: Brandon S. Allbery KF8NH wrote: Come to think of it, if you're after math notation, enough Greek letters are used as symbols that it might be necessary to just exclude them from use as letters. Yitz Gale wrote: While I have not yet noticed anyone

Re: [Haskell-cafe] Re: Richer (than ascii) notation for haskell source?

2008-05-15 Thread Brandon S. Allbery KF8NH
On 2008 May 15, at 3:25, Achim Schneider wrote: "Yitzchak Gale" <[EMAIL PROTECTED]> wrote: Brandon S. Allbery KF8NH wrote: Come to think of it, if you're after math notation, enough Greek letters are used as symbols that it might be necessary to just exclude them from use as letters. While

Re: [Haskell-cafe] Richer (than ascii) notation for haskell source?

2008-05-15 Thread Brandon S. Allbery KF8NH
On 2008 May 15, at 3:03, Yitzchak Gale wrote: Brandon S. Allbery KF8NH wrote: Adjacent different scripts in general is probably a reasonable token discriminator. A "token" combining LTR and RTL, for example, is just confusing. So you would like to ban identifiers that contain both letters a

Re: [Haskell-cafe] bottomless Top?

2008-05-15 Thread Conor McBride
Replying slap-foreheadedly to own post... On 15 May 2008, at 11:56, Conor McBride wrote: Folks I'm also wondering whether it makes sense to have a "bottomless Top" type, with constructor _ and lazy pattern _ (with (undefined :: Top) equal to _). Then the constant-time shape operator makes the

[Haskell-cafe] bottomless Top?

2008-05-15 Thread Conor McBride
Folks [statutory warning: functors, terminal objects, unsafeCoerce] I had a peculiar notion this morning to wonder whether I could get away with shape :: Functor f => f a -> f () shape fa = unsafeCoerce fa Sure enough, ghci gives me *Top> shape "moo" [(),(),()] *Top> shape [undefined] [**

Re: [Haskell-cafe] Two-iteration optimisation (was: GHC Predictability)

2008-05-15 Thread Yitzchak Gale
Don Stewart wrote: > You'd want a general fusion framework for this... > Stream fusion... at least does this for zips... > but for an arbitrary 'f' instead of zip, > seems harder. And of course, you wouldn't want that: f xs = xs : map expensiveCalculation xs Please don't fuse those two loops int

Re: [Haskell-cafe] GHC API GSoc project (was: ANN: Haddock version 2.1.0)

2008-05-15 Thread David Waern
2008/5/15, Claus Reinke <[EMAIL PROTECTED]>: > - is it possible to use standalone deriving to get a generic > programming framework over the ASTs without blowing > up GHC's code for its own use (deriving Data, etc.)? Speaking of generics, I'm working on deriving Data.Traversable for GHC's abst

Re: [Haskell-cafe] Re: GHC API GSoc project

2008-05-15 Thread Max Bolingbroke
> My own priority is to have the compilation phases exposed. One (selfish) > reason for this is that it will force a number of refactorings and cleanups > inside GHC, that we've had on the radar for some time. As soon as there's a > wiki page up I can start downloading some of the contents of my

Re: [Haskell-cafe] Re: Richer (than ascii) notation for haskell source?

2008-05-15 Thread Yitzchak Gale
Brandon S. Allbery KF8NH wrote: >>> Come to think of it, if you're after math notation, enough Greek >>> letters are used as symbols that it might be necessary to just >>> exclude them from use as letters. Yitz Gale wrote: >> While I have not yet noticed anyone from Greece on this list, >> I don't

[Haskell-cafe] Re: GHC API GSoc project

2008-05-15 Thread Simon Marlow
Claus, thanks for taking the time to articulate all this, speaking as the mentor for the project this material is invaluable. I'd particularly like to see a wiki page collecting issues, plans and priorities too. My own priority is to have the compilation phases exposed. One (selfish) reason

[Haskell-cafe] Re: Richer (than ascii) notation for haskell source?

2008-05-15 Thread Achim Schneider
"Yitzchak Gale" <[EMAIL PROTECTED]> wrote: > Brandon S. Allbery KF8NH wrote: > > Come to think of it, if you're after math notation, enough Greek > > letters are used as symbols that it might be necessary to just > > exclude them from use as letters. > > While I have not yet noticed anyone from G

Re: [Haskell-cafe] Richer (than ascii) notation for haskell source?

2008-05-15 Thread Yitzchak Gale
Brandon S. Allbery KF8NH wrote: > Come to think of it, if you're after math notation, enough Greek letters are > used as symbols that it might be necessary to just exclude them from use as > letters. While I have not yet noticed anyone from Greece on this list, I don't think it would be appropriat

Re: [Haskell-cafe] Richer (than ascii) notation for haskell source?

2008-05-15 Thread Yitzchak Gale
Brandon S. Allbery KF8NH wrote: > Adjacent different scripts in general is probably a reasonable token > discriminator. A "token" combining LTR and RTL, for example, is just > confusing. So you would like to ban identifiers that contain both letters and digits for those who happen to speak langua