Re: [Haskell-cafe] Lazy IO and closing of file handles

2007-03-15 Thread Ketil Malde
Donald Bruce Stewart wrote: pete-expires-20070513: When using readFile to process a large number of files, I am exceeding the resource limits for the maximum number of open file descriptors This is very annoying - I can't see any good reason why file descriptors should run out (before

Re: [Haskell-cafe] Lazy IO and closing of file handles

2007-03-15 Thread Brandon Michael Moore
On Wed, Mar 14, 2007 at 06:05:31PM -0700, David Brown wrote: Greg Fitzgerald wrote: What we need is a library for a readonly filesystem. That is, all the same functions but pure. I believe you could make this readonly library by wrapping each readonly I/O function with

Re: lazily handling exceptions in lazy sources (Re: [Haskell-cafe] Re:

2007-03-15 Thread oleg
the usual caveats about unsafePerformIO apply, so perhaps you wouldn't want to use this in a database library.. Indeed. This is quite problematic, from the practical point of view of making resources difficult to control (cf. another thread of file handle leakage), to the theoretical point

Re: [Haskell-cafe] N and R are categories, no?

2007-03-15 Thread Ulf Norell
On 3/15/07, Steve Downey [EMAIL PROTECTED] wrote: EOk, i'm trying to write down, not another monad tutorial, because I don't know that much yet, but an explication of my current understanding of monads. But before I write down something that is just flat worng, I thought I'd get a cross check.

Re: [Haskell-cafe] SYB vs HList (again)

2007-03-15 Thread Bas van Dijk
2007/3/15, S. Alexander Jacobson [EMAIL PROTECTED]: ... Any opinions on these issues would be very appreciated. ... Maybe the relational database system CoddFish which uses HList provides some insights: http://haskell.org/haskellwiki/Libraries_and_tools/Database_interfaces/CoddFish They also

Re: [Haskell-cafe] Lazy IO and closing of file handles

2007-03-15 Thread Matthew Brecknell
Ketil Malde: Perhaps this is an esoteric way, but I think the nicest approach is to parse into a strict structure. If you fully evaluate each Email (or whatever structure you parse into), there will be no unevaluated thunks linking to the file, and it will be closed. Not necessarily so,

Re: [Haskell-cafe] Lazy IO and closing of file handles

2007-03-15 Thread Bertram Felgenhauer
On 3/14/07, Pete Kazmier [EMAIL PROTECTED] wrote: When using readFile to process a large number of files, I am exceeding the resource limits for the maximum number of open file descriptors on my system. How can I enhance my program to deal with this situation without making significant changes?

Re: [Haskell-cafe] Lazy IO and closing of file handles

2007-03-15 Thread Ketil Malde
Matthew Brecknell wrote: Ketil Malde: Perhaps this is an esoteric way, but I think the nicest approach is to parse into a strict structure. If you fully evaluate each Email (or whatever structure you parse into), there will be no unevaluated thunks linking to the file, and it will be

Re: [Haskell-cafe] Lazy IO and closing of file handles

2007-03-15 Thread Claus Reinke
Not necessarily so, since you are making assumptions about the timeliness of garbage collection. I was similarly sceptical of Claus' suggestion: Claus Reinke: in order to keep the overall structure, one could move readFile backwards and parseEmail forwards in the pipeline, until the two meet.

Re: [Haskell-cafe] Lazy IO and closing of file handles

2007-03-15 Thread Donald Bruce Stewart
claus.reinke: Not necessarily so, since you are making assumptions about the timeliness of garbage collection. I was similarly sceptical of Claus' suggestion: Claus Reinke: in order to keep the overall structure, one could move readFile backwards and parseEmail forwards in the pipeline,

Re: [Haskell-cafe] Lazy IO and closing of file handles

2007-03-15 Thread Bertram Felgenhauer
Ketil Malde wrote: Bertram Felgenhauer wrote: type Subject = String data Email = Email {from :: From, subject :: Subject} deriving Show data Email = Email {from :: !From, subject :: !Subject} deriving Show ...except that From and Subject are Strings, and thus the strictness annotation

[Haskell-cafe] Make strict (IO String) lazy

2007-03-15 Thread Henning Thielemann
On the one hand, in the standard libraries there are functions like readFile, getContents, hGetContents which read a file lazily. This is often a nice feature, but sometimes lead to unexpected results, say when reading a file and overwriting it with modified contents. Unfortunately the standard

Re: [Haskell-cafe] Make strict (IO String) lazy

2007-03-15 Thread Björn Bringert
Henning Thielemann wrote: On the one hand, in the standard libraries there are functions like readFile, getContents, hGetContents which read a file lazily. This is often a nice feature, but sometimes lead to unexpected results, say when reading a file and overwriting it with modified contents.

Re: [Haskell-cafe] Make strict (IO String) lazy

2007-03-15 Thread Donald Bruce Stewart
lemming: On the one hand, in the standard libraries there are functions like readFile, getContents, hGetContents which read a file lazily. This is often a nice feature, but sometimes lead to unexpected results, say when reading a file and overwriting it with modified contents. Unfortunately

Re: [Haskell-cafe] Lazy IO and closing of file handles

2007-03-15 Thread Claus Reinke
http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html#t%3AHandle 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: the

[Haskell-cafe] Re: Foralls in records

2007-03-15 Thread Adde
Thanks! Serious food for thought. Ten years of object oriented brainwashing to undo :) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] N and R are categories, no?

2007-03-15 Thread Nicolas Frisby
That said, N and R are indeed categories; however, considering them as categories should be carefully interlaced with your intuitions about them as types. I haven't formally checked it, but I would bet that this endofunctor over N, called Sign, is a monad: Sign x = x + x Pos = injectLeft Neg

[Haskell-cafe] Haskell beginner

2007-03-15 Thread arnuld
i want to start learning Haskell and willing to master it :-) i have done some Common Lisp from http://www.gigamonkeys.com/book/. so i know what are functions, variables, etc. BUT i have never done any real life programmming or any kind of software development. in my country no Haskell books

Re: [Haskell-cafe] Haskell beginner

2007-03-15 Thread Scott Williams
Hi Arnuld, It's certainly possible. I'm new to the language too and learning it much the same way. It sounds like you don't have a lot of experience programming. I think this is an asset, not a liability. I would be interested in what concepts are the hardest to understand so the community can

Re: [Haskell-cafe] Haskell beginner

2007-03-15 Thread Jefferson Heard
Yet another Haskell Tutorial is the way I learned it. I find that subscribing to the mailing lists and reading the tutorial material is generally speaking enough. On Thursday 15 March 2007 14:30:03 arnuld wrote: i want to start learning Haskell and willing to master it :-) i have done some

Re: [Haskell-cafe] Haskell beginner

2007-03-15 Thread Paul Johnson
arnuld wrote: i want to start learning Haskell and willing to master it :-) Also check out the Wikibook at http://en.wikibooks.org/wiki/Programming:Haskell Do call back here if you need help. The Wikibook people would also appreciate feedback on what you found easy or difficult to

[Haskell-cafe] How do I avoid stack overflows?

2007-03-15 Thread DavidA
Hi. I'm trying to write some code which involves lots of matrix multiplications, but whenever I do too many, I get stack overflows (in both GHCi 6.4.2, and Hugs May 2006). The following code exhibits the problem. import List (transpose) u . v = sum $ zipWith (*) u v a * b = multMx a

[Haskell-cafe] Lack of expressiveness in kinds?

2007-03-15 Thread Andrew Wagner
Ok, so I'm inching closer to understanding monads, and this question popped up today. Consider the following 2 declarations: data Foo a = Bar a data (Ord a) = Baz a = Bah a Note that both of these have kind * - *. However, Baz could never be an instance of monad, because there is a restriction

Re: [Haskell-cafe] Haskell beginner

2007-03-15 Thread Sebastian Sylvan
On 3/15/07, arnuld [EMAIL PROTECTED] wrote: i want to start learning Haskell and willing to master it :-) i have done some Common Lisp from http://www.gigamonkeys.com/book/. so i know what are functions, variables, etc. BUT i have never done any real life programmming or any kind of software

Re: [Haskell-cafe] Haskell beginner

2007-03-15 Thread Andrew Wagner
This is all a good idea, but I've found that I've never learned nearly as much as when I started bashing out some code. So I highly recommend starting up some project that's interesting to you too. Hang out in #haskell in IRC (freenode). That's probably the best resource you'll ever find when

Re: [Haskell-cafe] N and R are categories, no?

2007-03-15 Thread Dominic Steinitz
I haven't formally checked it, but I would bet that this endofunctor over N, called Sign, is a monad: Just to be picky a functor isn't a monad. A monad is a triple consisting of a functor and 2 natural transformations which make certain diagrams commute. If you are looking for examples, I

Re[2]: [Haskell-cafe] Haskell beginner

2007-03-15 Thread Bulat Ziganshin
Hello Sebastian, Friday, March 16, 2007, 12:15:09 AM, you wrote: So here's the strategy: 1. Read tutorials 2. When you get stuck, ask on #haskell 3. Goto 1 (yes I deliberately wrote an imperative algorithm using gotos to describe how to learn Haskell, and I found it amusing) knowledge -

[Haskell-cafe] Generalised merge

2007-03-15 Thread Paul Johnson
The most common kind of primitive recursive function I find myself writing these days is a variation on the theme of merging two sorted lists. You can see some examples in my Ranged Sets library at http://ranged-sets.sourceforge.net/. For instance: -- | Set union for ranged sets. Infix

Re: [Haskell-cafe] How do I avoid stack overflows?

2007-03-15 Thread Claus Reinke
I'm trying to write some code which involves lots of matrix multiplications, but whenever I do too many, I get stack overflows (in both GHCi 6.4.2, and Hugs May 2006). The following code exhibits the problem. .. I tried to fix the problem using seq, as follows: iterate' f x = x : seq x'

Re: [Haskell-cafe] N and R are categories, no?

2007-03-15 Thread Nicolas Frisby
Thanks for keeping me honest ;) On 3/15/07, Dominic Steinitz [EMAIL PROTECTED] wrote: I haven't formally checked it, but I would bet that this endofunctor over N, called Sign, is a monad: Just to be picky a functor isn't a monad. A monad is a triple consisting of a functor and 2 natural

[Haskell-cafe] Lack of expressiveness in kinds?

2007-03-15 Thread oleg
Andrew Wagner wrote data Foo a = Bar a data (Ord a) = Baz a = Bah a Note that both of these have kind * - *. However, Baz could never be an instance of monad, because there is a restriction on the types it can operate on. There is a wide-spread opinion that one ought not to give context to

Re: [Haskell-cafe] Haskell beginner

2007-03-15 Thread Albert Y. C. Lai
Sebastian Sylvan wrote: So here's the strategy: 1. Read tutorials 2. When you get stuck, ask on #haskell 3. Goto 1 (yes I deliberately wrote an imperative algorithm using gotos to describe how to learn Haskell, and I found it amusing) It is just a standard transformation away from a

[Haskell-cafe] Re: Trouble trying to find packages for ubuntu linux

2007-03-15 Thread Chad Scherrer
Brian, I had this exact problem, and I found this approach to work wonderfully: http://pupeno.com/2006/12/17/unstable-packages-on-ubuntu/ Chad ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Hs-Generics] FW: [Haskell-cafe] SYB vs HList (again)

2007-03-15 Thread oleg
[Please follow-up to [EMAIL PROTECTED] S. Alexander Jacobson wrote: HLists require you to define Labels and basically only use label values that are themselves either scalar or HLists. ... With SYB you create field labels using newtype (or data) declarations e.g. data Salary = S

[Haskell-cafe] How do I avoid stack overflows?

2007-03-15 Thread oleg
DavidA wrote: I'm trying to write some code which involves lots of matrix multiplications, but whenever I do too many, I get stack overflows (in both GHCi 6.4.2, and Hugs May 2006). By placing a couple of strictness annotations, your test' gives the expected answer (given some time) on Hugs.