Re: [Haskell-cafe] operating on a hundred files at once

2007-04-10 Thread Chad Scherrer
Hi Jeff, I have a series of NxM numeric tables I'm doing a quick mean/variance/t-test etcetera on. The cell t1 [i,j] corresponds exactly to the cells t2..N [i,j], and so it's perfectly possible to read one item at a time from each of the 100 files and compute the mean/variance etcetera on all

Re: [Haskell-cafe] operating on a hundred files at once

2007-04-10 Thread Ketil Malde
On Tue, 2007-04-10 at 13:16 +1000, Duncan Coutts wrote: Note, that like in your original we read each file twice, once for the mean and once for the variance. As an aside, you can calculate both mean and variance in one pass (and constant space) by calculating the sum of elements 'x', the sum

Re: [Haskell-cafe] Compiling GHC

2007-04-10 Thread Chris Witte
HAVE_GETTIMEOFDAY is defined. I wrote a quick c program to check and I can use gettimeofday fine. I can't work out why ghc can't find it. How can I work out where ghc is searching to find it? Chris. On 3/30/07, Ian Lynagh [EMAIL PROTECTED] wrote: On Fri, Mar 30, 2007 at 04:36:32PM +1000, Chris

Re: [Haskell-cafe] Parsec: Help needed with simple parser

2007-04-10 Thread Joel Reymont
On Apr 10, 2007, at 3:42 AM, Albert Y. C. Lai wrote: Does option help? Like: It did, together with a couple of 'try's. Thanks, Joel -- http://wagerlabs.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] Prettyprinting infix expressions with HughesPJ

2007-04-10 Thread Alfonso Acosta
Hi all, I have to prettyprint infix expressions writing the least possible parenthesis (taking in account precedence and associativity). A simplified expression type could be: data Expr = Val String | -- Binary operators (using infix constructors) Expr :+: Expr

[Haskell-cafe] Re: Type error

2007-04-10 Thread Alfonso Acosta
Hi oleg, On 4/9/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Alfonso Acosta wrote: I have a type problem in my code which I dont know how to solve data HDSignal a = HDSignal class HDPrimType a where class PortIndex a where class SourcePort s where -- Plug an external signal to the

[Haskell-cafe] Re: What I learned from my first serious attempt low-level Haskell programming

2007-04-10 Thread Simon Marlow
Lennart Augustsson wrote: It's not that hard to figure out an order to permute the arguments on the stack before a tail call that minimizes that number of moves and temporary locations. Lmlc did this 20 years ago. :) Right, and that's what GHC does too, with a strongly-connected-component

Re: [Haskell-cafe] Re: [web-devel] A light-weight web framework

2007-04-10 Thread Marc Weber
Right now, you can largely do the same thing, but you have to write the XML representations of your data structures manually. -Alex- I'm not sure but doesn't use HAppS kind of stripped down HaXml ? DrIft can derive HaXml instances automatically. Where is the problem doing using DrIft? Marc

[Haskell-cafe] Re: Profiling makes memory leak go away? Is Haskell a practical language?

2007-04-10 Thread apfelmus
Oren Ben-Kiki wrote: The code is in http://hpaste.org/1314#a1 if anyone at all is willing to take pity on me and explain what I'm doing wrong. There is an important point to note about streaming, namely that it conflicts with knowing whether the input is syntactically correct or not. In other

[Haskell-cafe] Type level programming to eliminate array bound checking, a real world use

2007-04-10 Thread Vivian McPhail
Hi All,Inspired by Oleg's Eliminating Array Bound Checking through Non-dependent types http://okmij.org/ftp/Haskell/types.html#branding,I am attempting to write code that will receive an array from C land and convert it to a type safe representation. The array could have n dimensions where n

[Haskell-cafe] Type checking and locating token with Parsec

2007-04-10 Thread Joel Reymont
Folks, Imagine a language where Num + Num yields a Num and Str + Num yields a Str but Num + Str should not be allowed. I implemented parsing for such a language in OCaml with a yacc-based parser without an additional type-checking pass, entirely within the yacc grammar. I tried to take

[Haskell-cafe] A convenient way to deal with conditional function composition?

2007-04-10 Thread Maxime Henrion
Hello all, I have found myself writing instances of Show for some types of mine, and I did so by defining the showsPrec function, for performance reasons. I ended up with code that I find quite inelegant. Here's an example: data Move = Move { movePiece ::

Re: [Haskell-cafe] A convenient way to deal with conditional function composition?

2007-04-10 Thread Chris Kuklewicz
Maxime Henrion wrote: Hello all, I have found myself writing instances of Show for some types of mine, and I did so by defining the showsPrec function, for performance reasons. I ended up with code that I find quite inelegant. Here's an example: data Move = Move {

Re: [Haskell-cafe] A convenient way to deal with conditional function composition?

2007-04-10 Thread Stefan O'Rear
On Tue, Apr 10, 2007 at 02:33:41PM +0100, Chris Kuklewicz wrote: Well, since ((.) :: ShowS - ShowS - ShowS) is a Monoid, you can use Writer to create the result: Not portably. [EMAIL PROTECTED]:~$ ghc-6.4.2 -e '( (foo++) `Data.Monoid.mappend` (bar++) ) END' foobarEND [EMAIL PROTECTED]:~$

[Haskell-cafe] Checking for correct invocation of a command line / shell haskell program

2007-04-10 Thread Thomas Hartman
New wiki page: Checking for correct invocation of a command line haskell program at http://haskell.org/haskellwiki/Checking_for_correct_invocation_of_a_command_line_haskell_program This is a simple cookbook / boilerplate example I thought should go in a haskell wiki somewhere. I linked it

[Haskell-cafe] Re: Checking for correct invocation of a command line / shell haskell program

2007-04-10 Thread Thomas Hartman
there was a minor mistake in the above, fixed on the wiki page. 2007/4/10, Thomas Hartman [EMAIL PROTECTED]: New wiki page: Checking for correct invocation of a command line haskell program at http://haskell.org/haskellwiki/Checking_for_correct_invocation_of_a_command_line_haskell_program

Re: [Haskell-cafe] operating on a hundred files at once

2007-04-10 Thread Jefferson Heard
Thanks, Ketil. I knew I could calcuate the mean in constant space, but I didn't think about the variance. Much appreciated. On Tue, 2007-04-10 at 08:30 +0200, Ketil Malde wrote: On Tue, 2007-04-10 at 13:16 +1000, Duncan Coutts wrote: Note, that like in your original we read each file

Re: [Haskell-cafe] A convenient way to deal with conditional function composition?

2007-04-10 Thread Nicolas Frisby
Using the Endo newtype can avoid such ambiguities: http://darcs.haskell.org/packages/base/Data/Monoid.hs newtype Endo a = Endo { appEndo :: a - a } instance Monoid (Endo a) where mempty = Endo id Endo f `mappend` Endo g = Endo (f . g) Endo allows you to explicitly select the

Re: [Haskell-cafe] A convenient way to deal with conditional function composition?

2007-04-10 Thread Chris Kuklewicz
Nicolas Frisby wrote: Not portably. [EMAIL PROTECTED]:~$ ghc-6.4.2 -e '( (foo++) `Data.Monoid.mappend` (bar++) ) END' foobarEND [EMAIL PROTECTED]:~$ ghc-6.6 -e '( (foo++) `Data.Monoid.mappend` (bar++) ) END' fooENDbarEND -- 6.6 sources instance Monoid b = Monoid (a - b) where

[Haskell-cafe] hackage.haskell.org

2007-04-10 Thread David Waern
Hi, I'd like to set up a Trac for Haddock on hackage.haskell.org. Who should I contact? /David ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] hackage.haskell.org

2007-04-10 Thread Neil Mitchell
Hi I'd like to set up a Trac for Haddock on hackage.haskell.org. Who should I contact? Couldn't we use the bug tracker in Google Code? Its much better than the Trac one, much more useable, and they host it for us even. Think of it as Google giving us the gift of a perfectly formed bug tracker

[Haskell-cafe] Profiling makes memory leak go away? Is Haskell a practical language?

2007-04-10 Thread Oren Ben-Kiki
On Tue, 2007-04-10 at 12:14 +0200, apfelmus wrote: Oren Ben-Kiki wrote: The code is in http://hpaste.org/1314#a1 if anyone at all is willing to take pity on me and explain what I'm doing wrong. There is an important point to note about streaming, namely that it conflicts with knowing whether

[Haskell-cafe] Re: What I learned from my first serious attempt low-level Haskell programming

2007-04-10 Thread Lennart Augustsson
So then tail calls should be very cheap when most of the arguments don't change. On Apr 10, 2007, at 10:17 , Simon Marlow wrote: Lennart Augustsson wrote: It's not that hard to figure out an order to permute the arguments on the stack before a tail call that minimizes that number of

Re: [Haskell-cafe] Profiling makes memory leak go away? Is Haskell apractical language?

2007-04-10 Thread Claus Reinke
reply = parse ... -- Lazily evaluated tokens = rTokens reply -- Has some values immediately list = D.toList tokens -- Has some values immediately mapM_ list print -- Start printing immediately! .. reply = parse ... -- Lazily evaluated result = rResult reply -- Lazy; has value when parsing is

[Haskell-cafe] Weaving fun

2007-04-10 Thread Bas van Dijk
Hello, For my own exercise I'm writing a function 'weave' that weaves a list of lists together. For example: weave [[1,1,1], [2,2,2], [3,3]] == [1,2,3,1,2,3,1,2] weave [[1,1,1], [2,2], [3,3,3]] == [1,2,3,1,2,3,1] Note that 'weave' stops when a list is empty. Right now I have: weave ::

[Haskell-cafe] Re: What I learned from my first serious attempt low-level Haskell programming

2007-04-10 Thread Stefan O'Rear
On Tue, Apr 10, 2007 at 07:59:04PM +0100, Lennart Augustsson wrote: So then tail calls should be very cheap when most of the arguments don't change. On Apr 10, 2007, at 10:17 , Simon Marlow wrote: Lennart Augustsson wrote: It's not that hard to figure out an order to permute the

Re: [Haskell-cafe] Profiling makes memory leak go away? Is Haskell a practical language?

2007-04-10 Thread Brandon Michael Moore
On Tue, Apr 10, 2007 at 11:03:32AM -0700, Oren Ben-Kiki wrote: On Tue, 2007-04-10 at 12:14 +0200, apfelmus wrote: Oren Ben-Kiki wrote: The code is in http://hpaste.org/1314#a1 if anyone at all is willing to take pity on me and explain what I'm doing wrong. There is an important point to

Re: [Haskell-cafe] Weaving fun

2007-04-10 Thread Brandon Michael Moore
On Wed, Apr 11, 2007 at 12:13:10AM +0200, Bas van Dijk wrote: Hello, For my own exercise I'm writing a function 'weave' that weaves a list of lists together. For example: weave [[1,1,1], [2,2,2], [3,3]] == [1,2,3,1,2,3,1,2] weave [[1,1,1], [2,2], [3,3,3]] == [1,2,3,1,2,3,1] Note that

Re: [Haskell-cafe] Prettyprinting infix expressions with HughesPJ

2007-04-10 Thread Stefan O'Rear
On Tue, Apr 10, 2007 at 09:20:52AM +0200, Alfonso Acosta wrote: I have to prettyprint infix expressions writing the least possible parenthesis (taking in account precedence and associativity). A simplified expression type could be: Your use of 'have' is slightly suspicious here. That said,

Re: [Haskell-cafe] Weaving fun

2007-04-10 Thread Matthew Brecknell
Bas van Dijk: For my own exercise I'm writing a function 'weave' that weaves a list of lists together. For example: weave [[1,1,1], [2,2,2], [3,3]] == [1,2,3,1,2,3,1,2] weave [[1,1,1], [2,2], [3,3,3]] == [1,2,3,1,2,3,1] Note that 'weave' stops when a list is empty. This *almost* does

Re: [Haskell-cafe] Weaving fun

2007-04-10 Thread Dan Piponi
Here's a very different approach. I make no claim to increased elegance or efficiency, though I find it fairly readable and its made of reusable parts. (Of course that's how you always finds your own code!) import Prelude hiding (head,tail) -- Some would say this is how head and tail should

Re: [Haskell-cafe] Weaving fun

2007-04-10 Thread Dave Feustel
Talk about synchronicity! I was just wondering whether 'weaving' of infinite lists is possible. eg weave the infinite lists [2,4..], [3,6..], [5,10..] to get [2,3,4,5,6,8,9,10,..] Is this kind of lazy evaluation possible? Thanks, Dave Feustel -Original Message- From: Bas van Dijk

Re: [Haskell-cafe] Weaving fun

2007-04-10 Thread Ricardo Herrmann
This reminded me of interleaving as in: Backtracking, Interleaving, and Terminating Monad Transformers http://www.cs.rutgers.edu/~ccshan/logicprog/LogicT-icfp2005.pdf On 4/10/07, Dave Feustel [EMAIL PROTECTED] wrote: Talk about synchronicity! I was just wondering whether 'weaving' of infinite

Re: [Haskell-cafe] Weaving fun

2007-04-10 Thread Chris Mears
Bas van Dijk [EMAIL PROTECTED] writes: Hello, For my own exercise I'm writing a function 'weave' that weaves a list of lists together. For example: weave [[1,1,1], [2,2,2], [3,3]] == [1,2,3,1,2,3,1,2] weave [[1,1,1], [2,2], [3,3,3]] == [1,2,3,1,2,3,1] [...] So I'm wondering if 'weave'

Re: [Haskell-cafe] Weaving fun

2007-04-10 Thread Dave Feustel
I ask this question because I want to program a recently published algorithm for directly enumerating all prime numbers. The algorithm description uses infinite sets. The algorithm could possibly be programmed using lazy evaluation. -Original Message- From: Ricardo Herrmann [EMAIL

Re: [Haskell-cafe] Type checking and locating token with Parsec

2007-04-10 Thread Stefan O'Rear
On Tue, Apr 10, 2007 at 02:09:03PM +0100, Joel Reymont wrote: Folks, Imagine a language where Num + Num yields a Num and Str + Num yields a Str but Num + Str should not be allowed. I implemented parsing for such a language in OCaml with a yacc-based parser without an additional

Re: [Haskell-cafe] Prettyprinting infix expressions with HughesPJ

2007-04-10 Thread Alfonso Acosta
On 4/11/07, Stefan O'Rear [EMAIL PROTECTED] wrote: Your use of 'have' is slightly suspicious here. That said, the rest of your problem looks very un-homework-y, so I'll look at it. It's for my masters thesis (big piece of badly-specified homework if you want to think about it like that :)).

Re: [Haskell-cafe] Prettyprinting infix expressions with HughesPJ

2007-04-10 Thread Stefan O'Rear
On Wed, Apr 11, 2007 at 01:53:49AM +0200, Alfonso Acosta wrote: On 4/11/07, Stefan O'Rear [EMAIL PROTECTED] wrote: Your use of 'have' is slightly suspicious here. That said, the rest of your problem looks very un-homework-y, so I'll look at it. It's for my masters thesis (big piece of

Re: [Haskell-cafe] Weaving fun

2007-04-10 Thread Matthew Brecknell
Dave Feustel: Talk about synchronicity! I was just wondering whether 'weaving' of infinite lists is possible. eg weave the infinite lists [2,4..], [3,6..], [5,10..] to get [2,3,4,5,6,8,9,10,..] Is this kind of lazy evaluation possible? The base library version of (concat . transpose)

[Haskell-cafe] Re: Type error

2007-04-10 Thread oleg
Alfonso Acosta wrote: I tried the existential approach when it was previously suggested by Chris, but the problem is that, for some Source instances calling methods from HDPrimType within supplySig is not enough. Thus, it doesn't work with existentials due to their limitations. I see. The