Re: [Haskell-cafe] Literal programming in Haskell with rst-literals

2008-06-23 Thread Abhay Parvate
Hello, You might already know this, but in case you don't: there is another literate style: ... non-code ... \begin{code} ... code ... \end{code} ... non-code ... in which you do not put prefixes to each line. (In fact the standard says somewhere it is not recommended to mix the two styles if I

Re: [Haskell-cafe] Lazy IO.

2008-06-16 Thread Abhay Parvate
hGetContents reads the entire contents of the stream till the end (although lazily). The return value of hGetContents is logically the entire contents of the stream. That it has not read it completely is only a part of its laziness, so the result does not depend upon when the caller stops

Re: [Haskell-cafe] Re: appending an element to a list

2008-06-01 Thread Abhay Parvate
on this problem. Abhay On Sun, Jun 1, 2008 at 1:07 PM, apfelmus [EMAIL PROTECTED] wrote: Tillmann Rendel wrote: Abhay Parvate wrote: I think I would like to make another note: when we talk about the complexity of a function, we are talking about the time taken to completely evaluate

Re: [Haskell-cafe] Re: appending an element to a list

2008-05-30 Thread Abhay Parvate
I think I would like to make another note: when we talk about the complexity of a function, we are talking about the time taken to completely evaluate the result. Otherwise any expression in haskell will be O(1), since it just creates a thunk. And then the user of the program is to be blamed for

Re: [Haskell-cafe] appending an element to a list

2008-05-29 Thread Abhay Parvate
On Thu, May 29, 2008 at 11:48 PM, Tillmann Rendel [EMAIL PROTECTED] wrote: Adrian Neumann wrote: Hello, I was wondering how expensive appending something to a list really is. Say I write I'd say longList ++ [5] stays unevaluated until I consumed the whole list and then appending should

Re: [Haskell-cafe] Type Coercion

2008-05-28 Thread Abhay Parvate
To add to this: There are other constants which are polymorphic, not only numbers. Examples where you could add type signatures to make the type explicit are the empty list '[]' and the 'Nothing' constructor of 'Maybe a'. Adding type signatures to these will not be type casts, but telling the

Re: [Haskell-cafe] elem of infinite set of tuple

2008-05-16 Thread Abhay Parvate
It's not exactly a question of Haskell's behaviour. The list [ (a,b) | a - [0..], b - [0..] ] is such that apart from pairs starting with zero, no other pair is associated with a finite index. In other words, [ (a,b) | a - [0..], b - [0..] ] is not a correct 'enumeration' of all pairs of

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

2008-05-13 Thread Abhay Parvate
Yes, I had always desired that the operator = should have been right associative for this short cut even when written without the 'do' notation. On Tue, May 13, 2008 at 3:39 AM, John Hamilton [EMAIL PROTECTED] wrote: I'm trying to understand how short circuiting works with the Maybe monad.

Re: [Haskell-cafe] GHC predictability

2008-05-13 Thread Abhay Parvate
I don't know why, but perhaps beginners may expect too much from the laziness, almost to the level of magic (me too, in the beginning!). In an eager language, a function like mean :: (Fractional a) = [a] - a expects the *whole* list before it can calculate the mean, and the question of the

Re: [Haskell-cafe] GHC predictability

2008-05-12 Thread Abhay Parvate
As a beginner, I had found the behaviour quite unpredictable. But with time I found that I could reason out the behaviour with my slowly growing knowledge of laziness. I don't spot all the places in my program that will suck while writing a program, but post facto many things become clear. (And

Re: [Haskell-cafe] Re: Control.Exception.evaluate - 'correct definition' not so correct

2008-05-08 Thread Abhay Parvate
Thanks both for the the explanation and the link. The wikibook is really growing fast! Abhay On Wed, May 7, 2008 at 5:05 PM, apfelmus [EMAIL PROTECTED] wrote: Abhay Parvate wrote: Just for curiocity, is there a practically useful computation that uses 'seq' in an essential manner, i.e

Re: [Haskell-cafe] Re: Control.Exception.evaluate - 'correct definition' not so correct

2008-05-07 Thread Abhay Parvate
Just for curiocity, is there a practically useful computation that uses 'seq' in an essential manner, i.e. apart from the efficiency reasons? Abhay On Wed, May 7, 2008 at 2:48 PM, apfelmus [EMAIL PROTECTED] wrote: Luke Palmer wrote: It seems that there is a culture developing where people

Re: [Haskell-cafe] A common pattern

2008-05-05 Thread Abhay Parvate
Hi Andrew, I don't know whether it's intentional, but the patterns for case line of are not exaustive. Are you sure you do not expect anything else apart from a single . or a line starting with '#'? More below: On Mon, May 5, 2008 at 1:45 PM, Andrew Coppin [EMAIL PROTECTED] wrote: Neil

Re: Re[2]: [Haskell-cafe] GC'ing file handles and other resources

2008-04-16 Thread Abhay Parvate
management techniques that have the flexibility, efficiency, and accuracy of GC that I could be using for these other resources? Thanks, - Conal 2008/4/14 Abhay Parvate [EMAIL PROTECTED]: Hello, In describing the Handle type, the GHC documentation says (in the System.IO

Re: Re[4]: [Haskell-cafe] GC'ing file handles and other resources

2008-04-16 Thread Abhay Parvate
like video memory, file descriptors, etc? * Are there resource management techniques that have the flexibility, efficiency, and accuracy of GC that I could be using for these other resources? Thanks, - Conal 2008/4/14 Abhay Parvate [EMAIL PROTECTED]: Hello

Re: [Haskell-cafe] semi-closed handles

2008-04-15 Thread Abhay Parvate
Thanks! I was worried about how/where would I place hClose! On Mon, Apr 14, 2008 at 10:58 PM, Brent Yorgey [EMAIL PROTECTED] wrote: 2008/4/14 Abhay Parvate [EMAIL PROTECTED]: Hello, In describing the Handle type, the GHC documentation says (in the System.IO documentation): GHC note

Re: [Haskell-cafe] semi-closed handles

2008-04-15 Thread Abhay Parvate
1 byte per character + fixed overhead. Then, assuming the function consuming the String doesn't leak, you'll end up with a much smaller space requirement. -- ryan 2008/4/14 Abhay Parvate [EMAIL PROTECTED]: Thanks! I was worried about how/where would I place hClose! On Mon, Apr 14

Re: [Haskell-cafe] GC'ing file handles and other resources

2008-04-15 Thread Abhay Parvate
/14 Abhay Parvate [EMAIL PROTECTED]: Hello, In describing the Handle type, the GHC documentation says (in the System.IO documentation): GHC note: a Handle will be automatically closed when the garbage collector detects that it has become unreferenced by the program. However, relying

[Haskell-cafe] semi-closed handles

2008-04-14 Thread Abhay Parvate
Hello, In describing the Handle type, the GHC documentation says (in the System.IO documentation): GHC note: a Handle will be automatically closed when the garbage collector detects that it has become unreferenced by the program. However, relying on this behaviour is not generally recommended:

Re: [Haskell-cafe] Re: Embedding newlines into a string?

2008-04-14 Thread Abhay Parvate
] wrote: Abhay Parvate, Thank you; that answered my question. Then, the following two lines of code should be equivalent: In hanoi.hs: hanoi n = mapM_ putStrLn (hanoi_helper 'a' 'b' 'c' n) In hanoi_unlines.hs: hanoi n = putStr (unlines(hanoi_helper 'a' 'b' 'c' n)) I tested them both

Re: [Haskell-cafe] do construct in wxhaskell

2008-04-12 Thread Abhay Parvate
The indentation is not right; all the statements after the 'do' keyword need to start exactly at the same column. In particular, the 'f' in fileContent and 's' in set should be one below the other. And the 'return ()' also seems to be displaced; perhaps you want that also exactly below the last

[Haskell-cafe] Why does GHC limit stack size?

2007-11-03 Thread Abhay Parvate
Hello all, Why is there a limitation on the stack size in GHC? Like heap where we can limit the size by -M RTS option but the default is unlimited, why not let the program use as big a stack as required? If not by default, then by a separate option? Some of the functions that we write in