Re: [Haskell-cafe] Dynamic thread management?

2007-08-13 Thread Mitar
Hi! I am thinking about a model where you would have only n threads on a n-core (or processor) machine. They would be your worker threads and you would spawn them only once (at the beginning of the program) and then just delegate work between them. On 8/13/07, Jan-Willem Maessen [EMAIL

Re: [Haskell-cafe] A few questions on primes generating.

2007-08-13 Thread Andrew Coppin
Stefan O'Rear wrote: Also, large numbers don't (this is arguably a bug...) have restricted types: [EMAIL PROTECTED]:~$ ghc -e '100 :: Int' -1486618624 So many other programming languages allow weird things to happen with numeric overflows... it would be nice if Haskell

[Haskell-cafe] out of core computing in haskell

2007-08-13 Thread Carter T Schonwald
Hello Everyone, I'm not quite sure if I'm posing this question correctly, but what facilities currently exist in haskell to nicely deal with datastructures that won't fit within a given machine's ram? And if there are no such facilities, what would it take to fix that? thanks -Carter

Re: [Haskell-cafe] out of core computing in haskell

2007-08-13 Thread Stefan O'Rear
On Mon, Aug 13, 2007 at 12:29:25PM -0700, Carter T Schonwald wrote: Hello Everyone, I'm not quite sure if I'm posing this question correctly, but what facilities currently exist in haskell to nicely deal with datastructures that won't fit within a given machine's ram? And if there are no

Re: [Haskell-cafe] out of core computing in haskell

2007-08-13 Thread Andrew Coppin
Carter T Schonwald wrote: Hello Everyone, I'm not quite sure if I'm posing this question correctly, but what facilities currently exist in haskell to nicely deal with datastructures that won't fit within a given machine's ram? And if there are no such facilities, what would it take to fix

Re: [Haskell-cafe] Dynamic thread management?

2007-08-13 Thread Jan-Willem Maessen
On Aug 13, 2007, at 2:53 PM, Mitar wrote: Hi! I am thinking about a model where you would have only n threads on a n-core (or processor) machine. They would be your worker threads and you would spawn them only once (at the beginning of the program) and then just delegate work between them.

Re: [Haskell-cafe] out of core computing in haskell

2007-08-13 Thread Carter T Schonwald
The main two use cases I have in mind are 1) really really really big abstract syntax trees or proof trees (a la compilers or theorem provers) 2) random access to numerical data does that help clarify what i'm asking about? In each case, is there a standard way of dealing with this? in the

[Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Benjamin Franksen
Brian Brunswick wrote: One thing that I keep seeing people say (not you), is that monads /sequence/ side effects. This is wrong, or at least a limited picture. /All/ of the above structures are about combining compatible things things together in a row. /None/ of them force any particular

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Brandon S. Allbery KF8NH
On Aug 13, 2007, at 16:29 , Benjamin Franksen wrote: Let's take the simplest example: Maybe. The effect in question is the premature abortion of a computation (when Nothing is returned). And of course Maybe sequences these effects, that's what you use it for: the _first_ action to be

[Haskell-cafe] Re: Help with a project design

2007-08-13 Thread Benjamin Franksen
Andrea Rossato wrote: The task this library should do is simple: given an xml object (representing a bibliographic reference), render it with rules stored in a different xml object (the citation style). While I think I can find solutions for this problem - the rendering -, what I find

Re: [Haskell-cafe] Re: Language support for imperative code. Was: Re: monad subexpressions

2007-08-13 Thread Brian Hulley
Brian Hulley wrote: apfelmus wrote: Brian Hulley schrieb: main = do buffer - createBuffer edit1 - createEdit buffer edit2 - createEdit buffer splitter - createSplitter (wrapWidget edit1) (wrapWidget edit2) runMessageLoopWith splitter

Re: [Haskell-cafe] out of core computing in haskell

2007-08-13 Thread David Roundy
In the second case, if your numerical data is just a big array, why not just mmap it? Unless you're running on a 32 bit machine, or have a *seriously* large amount of data, that seems like the easiest option. Although if you're talking about mutable data, that's a whole 'nother can of worms... but

Re: [Haskell-cafe] A few questions on primes generating.

2007-08-13 Thread Isaac Dupree
Andrew Coppin wrote: Stefan O'Rear wrote: Also, large numbers don't (this is arguably a bug...) have restricted types: [EMAIL PROTECTED]:~$ ghc -e '100 :: Int' -1486618624 So many other programming languages allow weird things to happen with numeric overflows... it would

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread David Roundy
On Mon, Aug 13, 2007 at 05:13:01PM -0400, Brandon S. Allbery KF8NH wrote: On Aug 13, 2007, at 16:29 , Benjamin Franksen wrote: Let's take the simplest example: Maybe. The effect in question is the premature abortion of a computation (when Nothing is returned). And of course Maybe sequences

Re: [Haskell-cafe] Re: Language support for imperative code. Was: Re: monad subexpressions

2007-08-13 Thread Isaac Dupree
Brian Hulley wrote: Thinking about this a bit more, and just so this thought is recorded for posterity (!) and for the benefit of anyone now or in a few hundred years time, trying to solve Fermat's last GUI, the object oriented solution allows the buffer object to do anything it wants, so that

[Haskell-cafe] Re: Re: Language support for imperative code. Was: Re: monad subexpressions

2007-08-13 Thread Benjamin Franksen
Brian Hulley wrote: Brian Hulley wrote: apfelmus wrote: Brian Hulley schrieb: main = do buffer - createBuffer edit1 - createEdit buffer edit2 - createEdit buffer splitter - createSplitter (wrapWidget edit1) (wrapWidget edit2)

[Haskell-cafe] Re: Re: Explaining monads

2007-08-13 Thread Benjamin Franksen
Brandon S. Allbery KF8NH wrote: On Aug 13, 2007, at 16:29 , Benjamin Franksen wrote: Let's take the simplest example: Maybe. The effect in question is the premature abortion of a computation (when Nothing is returned). And of course Maybe sequences these effects, that's what you use it for:

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Tillmann Rendel
David Roundy wrote: It's the *effect* of a monad, not the *side* effect. The type of = defines this dependency. And when you have a chain of dependencies, that is sometimes referred to as a sequence. True, it's not mystical, but it's still sequenced. How can a Haskell type define a data

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Brian Brunswick
On 13/08/07, David Roundy [EMAIL PROTECTED] wrote: Try executing: do { x - return 2; undefined; return (x*x); } in any monad you like, and you'll find that regardless of the *data* dependencies (the return value of this monadic action is unambiguous), the undefined is evaluated *before*

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Derek Elkins
On Mon, 2007-08-13 at 22:29 +0200, Benjamin Franksen wrote: Brian Brunswick wrote: One thing that I keep seeing people say (not you), is that monads /sequence/ side effects. This is wrong, or at least a limited picture. /All/ of the above structures are about combining compatible

Re: [Haskell-cafe] A few questions on primes generating.

2007-08-13 Thread Sebastian Sylvan
On 13/08/07, Pekka Karjalainen [EMAIL PROTECTED] wrote: On 8/13/07, L.Guo [EMAIL PROTECTED] wrote: Hi All: Hello, I am reading http://www.haskell.org/haskellwiki/Prime_numbers The code in sector 1 Bitwise prime sieve. I have 3 questions about it. 1) In function go, what does

RE: [Haskell-cafe] Explaining monads

2007-08-13 Thread Derek Elkins
On Mon, 2007-08-13 at 19:31 +0200, peterv wrote: When I read side-effects, I understand it as unwanted effects, like aliasing, and effects depending on the order of execution. I'm not sure if my understanding here is correct. I hope Haskell does not allow side-effects but only effects, meaning

Re: [Haskell-cafe] Re: Re: Language support for imperative code. Was: Re: monad subexpressions

2007-08-13 Thread Isaac Dupree
Benjamin Franksen wrote: I'd be careful. Introducing a network connection into the equation makes the object (its methods) susceptible to a whole new bunch of failure modes; think indefinite delays, connection loss, network buffer overflow, etc etc. It may be a mistake to abstract all that away;

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Dan Piponi
On 8/13/07, David Roundy [EMAIL PROTECTED] wrote: Try executing: do { x - return 2; undefined; return (x*x); } in any monad you like instance Monad M where return a = M a ~(M a) = f = f a Or is that cheating? -- Dan ___ Haskell-Cafe

Re: [Haskell-cafe] Re: Re: Language support for imperative code. Was: Re: monad subexpressions

2007-08-13 Thread Donn Cave
On Tue, 14 Aug 2007, Benjamin Franksen wrote: ... I'd be careful. Introducing a network connection into the equation makes the object (its methods) susceptible to a whole new bunch of failure modes; think indefinite delays, connection loss, network buffer overflow, etc etc. It may be a mistake

Re: [Haskell-cafe] Re: Explaining monads

2007-08-13 Thread Arie Peterson
On 8/13/07, David Roundy [EMAIL PROTECTED] wrote: | Try executing: | | do { x - return 2; undefined; return (x*x); } | | in any monad you like It's not just the identity monad: Prelude :m +Control.Monad.State Prelude Control.Monad.State flip evalState () $ do { x - return 2; undefined;

[Haskell-cafe] Re: Re: Explaining monads

2007-08-13 Thread Benjamin Franksen
Derek Elkins wrote: On Mon, 2007-08-13 at 22:29 +0200, Benjamin Franksen wrote: Brian Brunswick wrote: One thing that I keep seeing people say (not you), is that monads /sequence/ side effects. This is wrong, or at least a limited picture. /All/ of the above structures are about

Re: [Haskell-cafe] Explaining monads

2007-08-13 Thread Gregory Propf
I made this mistake myself at first too. It seems that the Monad = side effect machine error is common to Haskell newbies. Probably to do with the fact that the first thing every programmer wants to do is write a hello world program and for that you need the IO Monad which requires some

Re: [Haskell-cafe] Re: Re: Explaining monads

2007-08-13 Thread Dan Piponi
On 8/13/07, Benjamin Franksen [EMAIL PROTECTED] wrote: Ok, I admit defeat now ;-) Monads in general /allow/ sequencing of (certain) effects, but it is not necessary for a monad to do so. I'm sure I said that 300 or so posts ago :-) Here's an example that might help make some of this explicit.

[Haskell-cafe] Re: Re: Re: Language support for imperative code. Was: Re: monad subexpressions

2007-08-13 Thread Benjamin Franksen
Isaac Dupree wrote: Benjamin Franksen wrote: I'd be careful. Introducing a network connection into the equation makes the object (its methods) susceptible to a whole new bunch of failure modes; think indefinite delays, connection loss, network buffer overflow, etc etc. It may be a mistake to

Re: [Haskell-cafe] A few questions on primes generating.

2007-08-13 Thread ajb
G'day all. Quoting Andrew Coppin [EMAIL PROTECTED]: So many other programming languages allow weird things to happen with numeric overflows... it would be nice if Haskell didn't. It would nice if CPUs supported trapping integer arithmetic. Cheers, Andrew Bromage

[Haskell-cafe] Small proof intro

2007-08-13 Thread Tim Newsham
I put together a small intro lesson on proving haskell code using quickcheck, equational reasoning and Isabelle/HOL. Its very elementary, but might be of interest to some people here. http://www.thenewsh.com/%7Enewsham/formal/reverse/ Feedback is appreciated. Tim Newsham

Re: [Haskell-cafe] Explaining monads

2007-08-13 Thread Ronald Guida
Ronald Guida wrote: Given the question What is a Monad, I would have to say A Monad is a device for sequencing side-effects. peterv [EMAIL PROTECTED] wrote: Side-effects is a piece of linguistic cruft played fast-and-loose by too many people in this game. Sequencing suffers the same

Re: [Haskell-cafe] Suffix tree

2007-08-13 Thread Ketil Malde
On Sun, 2007-08-12 at 23:09 +0100, Jon Harrop wrote: Suffix trees are a data structure used to search for a substring of length m in a string of length n in O(m) time. Suffix trees can also be used for efficient approximate searches. This data structure is of particular importance in

Re: [Haskell-cafe] Suffix tree

2007-08-13 Thread ajb
G'day all. Quoting Jon Harrop [EMAIL PROTECTED]: Does anyone have any Haskell code implementing suffix trees? I'm particularly interested in high-performance construction. No, but I have this: http://citeseer.ist.psu.edu/giegerich95comparison.html First person to implement them gets the

Re: [Haskell-cafe] Explaining monads

2007-08-13 Thread Brian Brunswick
On 11/08/07, Ronald Guida [EMAIL PROTECTED] wrote: Here's my interpretation of the table: -- Structure | Subject | Action| Verb | Result +--+++-- function

Re: [Haskell-cafe] IO within parser

2007-08-13 Thread Sam Hughes
Malte Milatz wrote: Sam Hughes [EMAIL PROTECTED], Sun, 12 Aug 2007 20:12:55 -0400: [A parser like Parsec, with monad transformers:] $ darcs get http://samuelhughes.com/darcs/partran/ Is this related in any way to the following GSoC project?

[Haskell-cafe] Re: Language support for imperative code. Was: Re: monad subexpressions

2007-08-13 Thread apfelmus
Isaac Dupree schrieb: apfelmus wrote: Mutable data structures in the sense of ephemeral (= not persistent = update in-place) data structure indeed do introduce the need to work in ST since the old version is - by definition - not available anymore. Not in the quantum/information-theoretic

Re: [Haskell-cafe] Explaining monads

2007-08-13 Thread Kim-Ee Yeoh
Ronald Guida wrote: Given the question What is a Monad, I would have to say A Monad is a device for sequencing side-effects. There are side-effects and there are side-effects. If the only monad you use is Maybe, the only side-effect you get is a slight warming of the CPU. Dave Menendez

[Haskell-cafe] A few questions on primes generating.

2007-08-13 Thread L.Guo
Hi All: I am reading http://www.haskell.org/haskellwiki/Prime_numbers The code in sector 1 Bitwise prime sieve. I have 3 questions about it. 1) In function go, what does the number 46340 mean ? Is it sqrt(MAX_LONG) ? 2) We have this type definition : pureSieve :: Int - Int Why there is

[Haskell-cafe] Re: a regressive view of support for imperative programming in Haskell

2007-08-13 Thread apfelmus
Benjamin Franksen wrote: As has been already mentioned in this thread, in http://www.soi.city.ac.uk/~ross/papers/Applicative.html Conor McBride and Ross Paterson invent/explain a new type class that is now part of the base package (Control.Applicative). They also use/propose syntactic sugar for

Re: [Haskell-cafe] Dynamic thread management?

2007-08-13 Thread Jan-Willem Maessen
On Aug 11, 2007, at 12:35 PM, Brian Hurt wrote: You guys might also want to take a look at the Cilk programming language, and how it managed threads. If you know C, learning Cilk is about 2 hours of work, as it's C with half a dozen extra keywords and a few new concepts. I'd love to

Re: [Haskell-cafe] A few questions on primes generating.

2007-08-13 Thread Alexis Hazell
On Tuesday 14 August 2007 00:22, L.Guo wrote: 2) We have this type definition : pureSieve :: Int - Int Why there is no error (type mismatch) of this call in func main : pureSieve 1000 The Haskell Report says that an Int covers at least the range [- 2^29, 2^29 - 1], which that

Re: [Haskell-cafe] Re: a regressive view of support for imperative programming in Haskell

2007-08-13 Thread Stefan O'Rear
On Mon, Aug 13, 2007 at 04:35:12PM +0200, apfelmus wrote: My assumption is that we have an equivalence forall a,b . m (a - m b) ~ (a - m b) because any side effect executed by the extra m on the outside can well be delayed until we are supplied a value a. Well, at least when all arguments

Re: [Haskell-cafe] A few questions on primes generating.

2007-08-13 Thread L.Guo
Because 10,000,000 is too large for a Int, it is always in type of Integer or some higher level data type. -- L.Guo 2007-08-13 - From: Alexis Hazell At: 2007-08-13 22:46:46 Subject: Re:

Re: [Haskell-cafe] A few questions on primes generating.

2007-08-13 Thread Pekka Karjalainen
On 8/13/07, L.Guo [EMAIL PROTECTED] wrote: Hi All: Hello, I am reading http://www.haskell.org/haskellwiki/Prime_numbers The code in sector 1 Bitwise prime sieve. I have 3 questions about it. 1) In function go, what does the number 46340 mean ? Is it sqrt(MAX_LONG) ? Yes, it appears so.

Re: [Haskell-cafe] A few questions on primes generating.

2007-08-13 Thread Stefan O'Rear
On Mon, Aug 13, 2007 at 11:23:59PM +0800, L.Guo wrote: Because 10,000,000 is too large for a Int, it is always in type of Integer or some higher level data type. In Haskell, Int always supports at least -536,870,912 to 536,870,911. Also, large numbers don't (this is arguably a bug...) have

[Haskell-cafe] Re: a regressive view of support for imperative programming in Haskell

2007-08-13 Thread apfelmus
Stefan O'Rear schrieb: On Mon, Aug 13, 2007 at 04:35:12PM +0200, apfelmus wrote: My assumption is that we have an equivalence forall a,b . m (a - m b) ~ (a - m b) because any side effect executed by the extra m on the outside can well be delayed until we are supplied a value a. Well, at

Re: [Haskell-cafe] A few questions on primes generating.

2007-08-13 Thread Isaac Dupree
L.Guo wrote: Because 10,000,000 is too large for a Int On my pitiful system, maxBound::Int 2147483647 is certainly greater than 1000 . it is always in type of Integer or some higher level data type. Haskell doesn't do static checking like that. In GHC on my system (where 10,000,000,000

Re: [Haskell-cafe] Re: a regressive view of support for imperative programming in Haskell

2007-08-13 Thread Stefan O'Rear
On Mon, Aug 13, 2007 at 05:39:34PM +0200, apfelmus wrote: Stefan O'Rear schrieb: On Mon, Aug 13, 2007 at 04:35:12PM +0200, apfelmus wrote: My assumption is that we have an equivalence forall a,b . m (a - m b) ~ (a - m b) because any side effect executed by the extra m on the outside can

Re: [Haskell-cafe] Re: a regressive view of support for imperative programming in Haskell

2007-08-13 Thread Isaac Dupree
David Roundy wrote: The only cost is that this syntax relies on the do notation, and thus makes the desugaring of that do notation slightly more complicated when used. If I understand correctly, do blah f (do foo bar (- action) ) blah has an ambiguity: which

[Haskell-cafe] xpath types for SYB/generic haskell type system?

2007-08-13 Thread Alex Jacobson
The SYB papers provide really powerful functions for accessing and manipulating a values in arbitrary shaped containers. The cost of this capability appears to be loss of type checking. For example gfindtype x returns a maybe y. Given that the type checker actually has to know whether or

Re: [Haskell-cafe] Re: a regressive view of support for imperative programming in Haskell

2007-08-13 Thread David Roundy
On Mon, Aug 13, 2007 at 01:27:45PM -0300, Isaac Dupree wrote: David Roundy wrote: The only cost is that this syntax relies on the do notation, and thus makes the desugaring of that do notation slightly more complicated when used. If I understand correctly, do blah f (do

RE: [Haskell-cafe] Explaining monads

2007-08-13 Thread peterv
When I read side-effects, I understand it as unwanted effects, like aliasing, and effects depending on the order of execution. I'm not sure if my understanding here is correct. I hope Haskell does not allow side-effects but only effects, meaning the monads do not allow you to write the typical

[Haskell-cafe] GHC optimisations

2007-08-13 Thread Andrew Coppin
Does GHC do dead code elimination? I observe that if you take a module and edit it so that some function is now no longer exported or called by any exported function, the size of the *.o file seems to go down. This suggests that dead code within a single module is eliminated. However... how

Re: [Haskell-cafe] Re: zip3, zip4 ... - zipn?

2007-08-13 Thread Brent Yorgey
On 8/11/07, Per Vognsen [EMAIL PROTECTED] wrote: Applicative functors can indeed help: (,,,) $ [1,2,3] * [-1,0,1] * [1,1,1] * [0,2,6] You just use n-1 commas when you want the effect of zipn. Actually, that's not quite right, since that uses the applicative functor related to the list

Re: [Haskell-cafe] GHC optimisations

2007-08-13 Thread Stefan O'Rear
On Mon, Aug 13, 2007 at 07:05:03PM +0100, Andrew Coppin wrote: Does GHC do dead code elimination? Yes - all unused let-binders are removed. I observe that if you take a module and edit it so that some function is now no longer exported or called by any exported function, the size of the

Re: [Haskell-cafe] GHC optimisations

2007-08-13 Thread Andrew Coppin
Stefan O'Rear wrote: On Mon, Aug 13, 2007 at 07:05:03PM +0100, Andrew Coppin wrote: Does GHC do dead code elimination? Yes - all unused let-binders are removed. Not related to optimisation, but... is there some switch to warn you if something gets removed? (Presumably this means

Re: [Haskell-cafe] GHC optimisations

2007-08-13 Thread Stefan O'Rear
On Mon, Aug 13, 2007 at 07:35:31PM +0100, Andrew Coppin wrote: Not related to optimisation, but... is there some switch to warn you if something gets removed? (Presumably this means you forgot to export something, or you haven't coded the bit that calls it yet or something.)

Re: [Haskell-cafe] GHC optimisations

2007-08-13 Thread Andrew Coppin
Stefan O'Rear wrote: On Mon, Aug 13, 2007 at 07:35:31PM +0100, Andrew Coppin wrote: (I once compiled a program that used the GHC API. The final binary was several times larger than ghc.exe...) GHC is a particularly bad case because what it does is determined by the settings of a bunch