Re: [Haskell-cafe] Top Level -

2008-09-05 Thread Ganesh Sittampalam
On Fri, 5 Sep 2008, Ashley Yakeley wrote: Sittampalam, Ganesh wrote: Ashley Yakeley wrote: I really don't know enough about the RTS to know. The alternative would be to keep all initialised values when the module is unloaded. I'm guessing this is more feasible. Easier, but a guaranteed

RE: [Haskell-cafe] Top Level -

2008-09-02 Thread Sittampalam, Ganesh
John Meacham wrote: On Fri, Aug 29, 2008 at 04:33:50PM -0700, Dan Weston wrote: C++ faced this very issue by saying that with global data, uniqueness of initialization is guaranteed but order of evaluation is not. Assuming that the global data are merely thunk wrappers over some common data

Re: [Haskell-cafe] Top Level -

2008-09-02 Thread Adrian Hey
Sittampalam, Ganesh wrote: Can't you write two recursive modules with - that depend on each other, so that there's no valid initialisation order? Contrived example follows: module Module1 where glob1 :: IORef Int glob1 - mod2 = newIORef mod1 :: IO Int mod1 = readIORef glob1 module Module2

RE: [Haskell-cafe] Top Level -

2008-09-02 Thread Sittampalam, Ganesh
Contrived example follows: module Module1 (mod1) where import Module2 glob1 :: IORef Int glob1 - mod2 = newIORef mod1 :: IO Int mod1 = readIORef glob1 module Module2 (mod2) where import Module1 glob2 :: IORef Int glob2 - mod1 = newIORef mod2 :: IO Int mod2 =

Re: [Haskell-cafe] Top Level -

2008-09-02 Thread David Roundy
On Tue, Sep 02, 2008 at 10:10:31AM +0100, Sittampalam, Ganesh wrote: Contrived example follows: module Module1 (mod1) where import Module2 glob1 :: IORef Int glob1 - mod2 = newIORef mod1 :: IO Int mod1 = readIORef glob1 module Module2 (mod2) where import

RE: [Haskell-cafe] Top Level -

2008-09-02 Thread Sittampalam, Ganesh
David Roundy wrote: On Tue, Sep 02, 2008 at 10:10:31AM +0100, Sittampalam, Ganesh wrote: Arguably both of these cases are not ACIO simply because of the non-termination effects, but it's not obvious to me how you tell just by looking at either one's code together with the declared API of

Re: [Haskell-cafe] Top Level -

2008-09-01 Thread Brandon S. Allbery KF8NH
On 2008 Sep 1, at 1:33, Ganesh Sittampalam wrote: On Sun, 31 Aug 2008, Brandon S. Allbery KF8NH wrote: On 2008 Aug 31, at 13:20, Ganesh Sittampalam wrote: I'm afraid I don't see how this generalises to sharing something across an entire process where the things that want to do the sharing

Re: [Haskell-cafe] Top Level -

2008-08-31 Thread Ganesh Sittampalam
On Sun, 31 Aug 2008, Brandon S. Allbery KF8NH wrote: On 2008 Aug 31, at 12:01, Ganesh Sittampalam wrote: On Sun, 31 Aug 2008, Brandon S. Allbery KF8NH wrote: On 2008 Aug 31, at 11:20, Ganesh Sittampalam wrote: Where do the filehandle structures live in the latter case? The place you

Re: [Haskell-cafe] Top Level -

2008-08-31 Thread Brandon S. Allbery KF8NH
On 2008 Aug 31, at 13:20, Ganesh Sittampalam wrote: On Sun, 31 Aug 2008, Brandon S. Allbery KF8NH wrote: On 2008 Aug 31, at 12:01, Ganesh Sittampalam wrote: On Sun, 31 Aug 2008, Brandon S. Allbery KF8NH wrote: On 2008 Aug 31, at 11:20, Ganesh Sittampalam wrote: Where do the filehandle

Re: [Haskell-cafe] Top Level -

2008-08-31 Thread Ganesh Sittampalam
On Sun, 31 Aug 2008, Brandon S. Allbery KF8NH wrote: On 2008 Aug 31, at 13:20, Ganesh Sittampalam wrote: I'm afraid I don't see how this generalises to sharing something across an entire process where the things that want to do the sharing are not in or controlled by the same shared

RE: [Haskell-cafe] Top-level TVars

2005-12-15 Thread Simon Peyton-Jones
Yes, they do | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Joel | Reymont | Sent: 14 December 2005 20:39 | To: Tomasz Zielonka | Cc: Simon Marlow; Haskell-Cafe Cafe | Subject: Re: [Haskell-cafe] Top-level TVars | | | On Wed, Dec 14, 2005 at 02:17

RE: [Haskell-cafe] Top-level TVars

2005-12-15 Thread Simon Marlow
On 14 December 2005 20:39, Joel Reymont wrote: On Wed, Dec 14, 2005 at 02:17:17PM -, Simon Marlow wrote: Suppose you create two top-level IORefs with the same type, like this: var1 = unsafePerformIO $ newIORef 0 var2 = unsafePerformIO $ newIORef 0 GHC's CSE optimisation will

RE: [Haskell-cafe] Top-level TVars

2005-12-14 Thread Simon Peyton-Jones
] [mailto:[EMAIL PROTECTED] On Behalf Of Joel | Reymont | Sent: 13 December 2005 18:08 | To: Haskell-Cafe Cafe | Subject: [Haskell-cafe] Top-level TVars | | Can this be done now or is this a GHC 6.5 feature? | | My combination of unsafePerformIO with atomically $ newTVar does not | seem to be working

RE: [Haskell-cafe] Top-level TVars

2005-12-14 Thread Simon Marlow
On 13 December 2005 18:34, Tomasz Zielonka wrote: On Tue, Dec 13, 2005 at 06:08:23PM +, Joel Reymont wrote: Can this be done now or is this a GHC 6.5 feature? My combination of unsafePerformIO with atomically $ newTVar does not seem to be working. Here is an example how you can

Re: [Haskell-cafe] Top-level TVars

2005-12-14 Thread Tomasz Zielonka
On Wed, Dec 14, 2005 at 09:51:16AM -, Simon Marlow wrote: Here is an example how you can initialize a top-level STM variable. http://www.uncurry.com/repos/TimeVar/TimeVar.hs It just forks a new thread inside unsafePerformIO, it runs atomically in it and passes the result through

RE: [Haskell-cafe] Top-level TVars

2005-12-14 Thread Simon Marlow
On 14 December 2005 09:57, Tomasz Zielonka wrote: On Wed, Dec 14, 2005 at 09:51:16AM -, Simon Marlow wrote: Here is an example how you can initialize a top-level STM variable. http://www.uncurry.com/repos/TimeVar/TimeVar.hs It just forks a new thread inside unsafePerformIO, it runs

Re: [Haskell-cafe] Top-level TVars

2005-12-14 Thread Tomasz Zielonka
On Wed, Dec 14, 2005 at 10:03:42AM -, Simon Marlow wrote: Well sure, but it's only a temporary problem. And you also have to tell them to use {-# NOINLINE #-} and -fno-cse :-) -fno-cse is also neccesary? Oops, I didn't know that. Can I simply place it in {-# OPTIONS -fno-cse #-} ? Best

Re: [Haskell-cafe] Top-level TVars

2005-12-14 Thread Joel Reymont
I'm a bit lost in the discussion. Why do I need -fno-cse and how do I seq at the top-level? On Dec 14, 2005, at 10:05 AM, Tomasz Zielonka wrote: On Wed, Dec 14, 2005 at 10:03:42AM -, Simon Marlow wrote: Well sure, but it's only a temporary problem. And you also have to tell them to

RE: [Haskell-cafe] Top-level TVars

2005-12-14 Thread Simon Marlow
On 14 December 2005 10:11, Joel Reymont wrote: I'm a bit lost in the discussion. Why do I need -fno-cse and how do I seq at the top-level? On Dec 14, 2005, at 10:05 AM, Tomasz Zielonka wrote: On Wed, Dec 14, 2005 at 10:03:42AM -, Simon Marlow wrote: Well sure, but it's only a

Re: [Haskell-cafe] Top-level TVars

2005-12-14 Thread Tomasz Zielonka
On Wed, Dec 14, 2005 at 02:17:17PM -, Simon Marlow wrote: Suppose you create two top-level IORefs with the same type, like this: var1 = unsafePerformIO $ newIORef 0 var2 = unsafePerformIO $ newIORef 0 GHC's CSE optimisation will common these up - after all, it's the same

Re: [Haskell-cafe] Top-level TVars

2005-12-14 Thread Joel Reymont
On Wed, Dec 14, 2005 at 02:17:17PM -, Simon Marlow wrote: Suppose you create two top-level IORefs with the same type, like this: var1 = unsafePerformIO $ newIORef 0 var2 = unsafePerformIO $ newIORef 0 GHC's CSE optimisation will common these up - after all, it's the same

[Haskell-cafe] Top-level TVars

2005-12-13 Thread Joel Reymont
Can this be done now or is this a GHC 6.5 feature? My combination of unsafePerformIO with atomically $ newTVar does not seem to be working. Thanks, Joel P.S. What is the ETA for 6.5? On Mon, Dec 05, 2005 at 10:50:13AM -, Simon Peyton-Jones wrote: It turns out to be

Re: [Haskell-cafe] Top-level TVars

2005-12-13 Thread Tomasz Zielonka
On Tue, Dec 13, 2005 at 06:08:23PM +, Joel Reymont wrote: Can this be done now or is this a GHC 6.5 feature? My combination of unsafePerformIO with atomically $ newTVar does not seem to be working. Here is an example how you can initialize a top-level STM variable.

[Haskell-cafe] Top Level etc.

2005-01-19 Thread Ashley Yakeley
In article [EMAIL PROTECTED], Keean Schupke [EMAIL PROTECTED] wrote: Do you think implicit parameters could replace top-level-things-with-identity? I hadn't really thought of it before (and I don't use implicit parameters much). Yes, but I think people are clamouring for

Re: [Haskell-cafe] Top Level etc.

2005-01-19 Thread Benjamin Franksen
On Wednesday 19 January 2005 12:52, Ashley Yakeley wrote: I have been musing on the connection between data-types, modules, classes, and implicit parameters, and wondering if there might be some grand scheme to tie it all together. For instance, a module is very similar to class with no type

Re: [Haskell-cafe] Top Level etc.

2005-01-19 Thread Keean Schupke
I may have got this wrong, but I think you can do named instances without any extensions, by using datatypes and fundeps: data Instance0 data Instance1 instance0 :: Instance0 instance0 = undefined instance1 :: Instance1 instance1 = undefined class Named a b | a - b test :: a - b - b instance

Re: [Haskell-cafe] Top Level etc.

2005-01-19 Thread Jorge Adriano Aires
Perhaps one could have top-level implicit parameters (or top-level contexts in general): module (?myvar :: IORef Int) = Random where Hi! I suggested something very similar to this some months ago, syntax and all. Nice to see I'm not the only one thinking along this lines.

Re: [Haskell-cafe] Top Level etc.

2005-01-19 Thread Benjamin Franksen
On Wednesday 19 January 2005 14:31, Keean Schupke wrote: I may have got this wrong, but I think you can do named instances without any extensions, by using datatypes and fundeps: data Instance0 data Instance1 instance0 :: Instance0 instance0 = undefined instance1 :: Instance1 instance1

Re: [Haskell-cafe] Top Level etc.

2005-01-19 Thread Benjamin Franksen
On Wednesday 19 January 2005 21:20, Jorge Adriano Aires wrote: Perhaps one could have top-level implicit parameters (or top-level contexts in general): module (?myvar :: IORef Int) = Random where I suggested something very similar to this some months ago, syntax and all. Nice to see I'm

Re: [Haskell-cafe] Top Level etc.

2005-01-19 Thread Keean Schupke
Benjamin Franksen wrote: Neither I nor the authors claim that their proposal is the ultimate grand scheme, yet. Still I think there are very interesting ideas in there that should be considered for experimental implementation or further research. But thats interesting isn't it. If one

Re: [Haskell-cafe] Top Level etc.

2005-01-19 Thread Benjamin Franksen
On Wednesday 19 January 2005 21:48, Keean Schupke wrote: Benjamin Franksen wrote: Neither I nor the authors claim that their proposal is the ultimate grand scheme, yet. Still I think there are very interesting ideas in there that should be considered for experimental implementation or further

Why does RandomIO need the unsafePerformIO hack? (was: [Haskell-cafe] Top-level state debate on the wiki)

2004-12-03 Thread Graham Klyne
Looking at the wiki summary [1] (very good, BTW), I have a question (I've skipped much of the debate, so please just give a message pointer if I missed something). Why does RandomIO need to use the unsafePerformIO hack if its already in the IO monad? BTW, if the goal is to have a random

Re: Why does RandomIO need the unsafePerformIO hack? (was: [Haskell-cafe] Top-level state debate on the wiki)

2004-12-03 Thread John Meacham
On Fri, Dec 03, 2004 at 10:05:08AM +, Graham Klyne wrote: Looking at the wiki summary [1] (very good, BTW), I have a question (I've skipped much of the debate, so please just give a message pointer if I missed something). Why does RandomIO need to use the unsafePerformIO hack if its

Re: [Haskell-cafe] Top-level state debate on the wiki

2004-12-02 Thread John Meacham
On Thu, Dec 02, 2004 at 09:08:21AM +, Keean Schupke wrote: Ben Rudiak-Gould wrote: Just a small comment on the Wiki page... it says Several real-life examples of pure haskell code which needs fast global variables to either be implemented efficiently or statically guarantee their

Re: [Haskell-cafe] Top-level state debate on the wiki

2004-12-02 Thread Keean Schupke
Hi John, I am not objecting to the top-level TWIs anymore - since I realised contexts can be provided by wrapping the MVar or IORef modules. I just thought the wiki misrepresented the calims of your examples (or maybe the claims are a little exaggerated)... As far as I can tell adding top

Re: [Haskell-cafe] Top-level state debate on the wiki

2004-12-02 Thread Keith Wansbrough
Nice summary. What I think is missing is an explanation of when you would want this feature (and when you wouldn't, more importantly). Here is the kind of platonic dialogue that summarises my limited understanding: [..dialogue snipped..] This is good, and is the sort of thing that should

Re: [Haskell-cafe] Top-level state debate on the wiki

2004-12-02 Thread Keean Schupke
With regards to the following... There are cases in which this parameterization costs convenience and gains nothing -- for example, the standard library function (randomIO :: Random a = IO a) cannot be implemented in Haskell without the unsafePerformIO hack, yet there's nothing semantically

Re: [Haskell-cafe] Top-level state debate on the wiki

2004-12-02 Thread John Meacham
On Thu, Dec 02, 2004 at 10:53:57AM +, Keean Schupke wrote: Hi John, I am not objecting to the top-level TWIs anymore - since I realised contexts can be provided by wrapping the MVar or IORef modules. I just thought the wiki misrepresented the calims of your examples (or maybe the

Re: [Haskell-cafe] Top-level state debate on the wiki

2004-12-02 Thread Keean Schupke
Just a few minor nitpicks... mainly about the necessity of using certain APIs, however I think we are in general agreement... Keean. John Meacham wrote: That example solves a different problem, I was never claiming that there wern't efficient ways to solve the unique producer problem in

Re: [Haskell-cafe] Top-level state debate on the wiki

2004-12-02 Thread Ben Rudiak-Gould
Keean Schupke wrote: Ben Rudiak-Gould wrote: [...] Just a small comment on the Wiki page... it says Several real-life examples of pure haskell code which needs fast global variables to either be implemented efficiently or statically guarantee their invariants are given in

[Haskell-cafe] Top-level state debate on the wiki

2004-12-01 Thread Ben Rudiak-Gould
I put up a wiki page summarizing the main proposals for top-level mutable state. The type-dictionary approach isn't there yet, but there's a space for it; I'll probably fill it in within the next 24 hours unless someone else feels like doing it first. Please add more detail, objections,

Re: [Haskell-cafe] Top-level state debate on the wiki

2004-12-01 Thread Adrian Hey
On Wednesday 01 Dec 2004 6:29 pm, Ben Rudiak-Gould wrote: I put up a wiki page summarizing the main proposals for top-level mutable state. The type-dictionary approach isn't there yet, but there's a space for it; I'll probably fill it in within the next 24 hours unless someone else feels like

Re: [Haskell-cafe] Top-level state debate on the wiki

2004-12-01 Thread Jules Bean
On 1 Dec 2004, at 18:29, Ben Rudiak-Gould wrote: Here's the page: http://haskell.org/hawiki/GlobalMutableState Nice summary. What I think is missing is an explanation of when you would want this feature (and when you wouldn't, more importantly). Here is the kind of platonic dialogue that