Re: let vs. where [was: Re: more unsafePerformIO questions (is it safe to use with ReadMode Handles)?]

2003-08-20 Thread Andrew J Bromage
G'day all. On Wed, Aug 20, 2003 at 07:42:59AM +0200, Jan Scheffczyk wrote: I always thought that there is a tiny difference between let and where: They're semantically equivalent. See, for example: http://haskell.org/onlinereport/decls.html#sect4.4.3.2 Cheers, Andrew Bromage

RE: more unsafePerformIO questions (is it safe to use with ReadMode Handles)?

2003-08-19 Thread Simon Marlow
I'm finishing up my Haskell interface to WordNet (http://www.cogsci.princeton.edu/~wn/) and have a standard unsafePerformIO question :). Basically, the interface functions by first calling an initialization function, 'initializeWordNet :: IO WordNetEnv'. WordNetEnv is essentially just a

Re: more unsafePerformIO questions (is it safe to use with ReadMode Handles)?

2003-08-19 Thread Ganesh Sittampalam
On Tue, 19 Aug 2003 10:27:23 +0100, Simon Marlow [EMAIL PROTECTED] wrote: If the databases *do* change over time, then there are two possibilities: 1. the contents change due to external factors only 2. the contents change because this program doing the writing in (1), you can still pretend

RE: more unsafePerformIO questions (is it safe to use with ReadMode Handles)?

2003-08-19 Thread Simon Marlow
If the databases *do* change over time, then there are two possibilities: 1. the contents change due to external factors only 2. the contents change because this program doing the writing in (1), you can still pretend the interface is pure, by imagining that all the changes

Re: more unsafePerformIO questions (is it safe to use with ReadMode Handles)?

2003-08-19 Thread Ganesh Sittampalam
On Tue, 19 Aug 2003 10:52:57 +0100, Simon Marlow [EMAIL PROTECTED] wrote: Isn't there the possibility of inlining causing a read to happen twice even if it only appears to happen once? In theory that would be a valid transformation, but in practice no compiler would duplicate arbitrary

RE: more unsafePerformIO questions (is it safe to use with ReadMode Handles)?

2003-08-19 Thread Simon Marlow
Isn't there the possibility of inlining causing a read to happen twice even if it only appears to happen once? In theory that would be a valid transformation, but in practice no compiler would duplicate arbitrary computations. GHC certainly doesn't. I was thinking of a situation

Re: more unsafePerformIO questions ([...])

2003-08-19 Thread Wolfgang Jeltsch
On Tuesday, 2003-08-19, 13:18, Simon Marlow wrote: [...] Yes, I agree that one shouldn't rely on the no duplication of work property. However, folloing this argument we arrive at the conclusion that hGetContents is an invalid use of unsafePerformIO. (which is something I've been saying for

RE: more unsafePerformIO questions ([...])

2003-08-19 Thread Simon Marlow
On Tuesday, 2003-08-19, 13:18, Simon Marlow wrote: [...] Yes, I agree that one shouldn't rely on the no duplication of work property. However, folloing this argument we arrive at the conclusion that hGetContents is an invalid use of unsafePerformIO. (which is something I've

Re: more unsafePerformIO questions (is it safe to use with ReadMode Handles)?

2003-08-19 Thread Andrew J Bromage
G'day all. On Tue, Aug 19, 2003 at 11:11:23AM +0100, Ganesh Sittampalam wrote: I was thinking of a situation like let x = unsafePerformIO readFooFromDB in x+x I see from your Secrets of the GHC inliner paper that x wouldn't be inlined by GHC, but it seems to me like a serious abuse of

let vs. where [was: Re: more unsafePerformIO questions (is it safe to use with ReadMode Handles)?]

2003-08-19 Thread Jan Scheffczyk
Hi Andrew, let x = expensiveComputation foo in x + x I would certainly hope that expensiveComputation wasn't called twice, and even though the language doesn't guarantee it, I have already written code that assumed it. I always thought that there is a tiny difference between let and