Re: [Haskell-cafe] Space questions about intern and sets

2005-06-09 Thread Gracjan Polak
Udo Stenzel wrote: Gracjan Polak wrote: iorefset :: Ord a = IORef(Map.Map a a) iorefset = unsafePerformIO $ do newIORef $ Map.empty I could have as many dictionaries as there are types. The problem is I get one dictionary for each object which defeats the idea. I believe the (Ord a)

Re: [Haskell-cafe] Space questions about intern and sets

2005-06-08 Thread Bjorn Bringert
Gracjan Polak wrote: Hello all, I've got two questions, both are space related so I'll put them in one e-mail. 1. I'd like to have function intern, that behaves essentially like id, but with the following constraint: if x==y then makeStableName(intern x)==makeStableName(intern y)

Re: [Haskell-cafe] Space questions about intern and sets

2005-06-08 Thread Gracjan Polak
Bjorn Bringert wrote: memory. Here is something I wrote, but it doesn't work :( I must have been doing something really wrong that day, because today it works smoothly... :) The code below seems to work for strings, and should be generalizable to any type for which you have a hash

Re: [Haskell-cafe] Space questions about intern and sets

2005-06-08 Thread Udo Stenzel
Gracjan Polak wrote: iorefset :: Ord a = IORef(Map.Map a a) iorefset = unsafePerformIO $ do newIORef $ Map.empty I could have as many dictionaries as there are types. The problem is I get one dictionary for each object which defeats the idea. I believe the (Ord a) constraint acts

Re: [Haskell-cafe] Space questions about intern and sets

2005-06-05 Thread Gracjan Polak
Duncan Coutts wrote: On Fri, 2005-06-03 at 10:53 +0200, Gracjan Polak wrote: As intern behaves like id and does not have any side effects, I thought its interface should be purely functional. But I do not see any way to do it :( I'll end up with a monad, probably. In related question: does

Re: [Haskell-cafe] Space questions about intern and sets

2005-06-03 Thread Gracjan Polak
Scott Turner wrote: On 2005 June 02 Thursday 04:38, Gracjan Polak wrote: iorefset :: Ord a = IORef(Map.Map a a) iorefset = unsafePerformIO $ do newIORef $ Map.empty I could have as many dictionaries as there are types. The problem is I get one dictionary for each object which defeats

Re: [Haskell-cafe] Space questions about intern and sets

2005-06-03 Thread Duncan Coutts
On Fri, 2005-06-03 at 10:53 +0200, Gracjan Polak wrote: As intern behaves like id and does not have any side effects, I thought its interface should be purely functional. But I do not see any way to do it :( I'll end up with a monad, probably. In related question: does anybody here have

Re: [Haskell-cafe] Space questions about intern and sets

2005-06-03 Thread Donn Cave
On Fri, 3 Jun 2005, Gracjan Polak wrote: ... In related question: does anybody here have experience/benchmarks/tests how/if is PackedString better (uses less memory) than String in parsing tasks? I don't have that information, but in case it helps, look out for splitPS - it makes the fairly

Re: [Haskell-cafe] Space questions about intern and sets

2005-06-03 Thread John Meacham
On Fri, Jun 03, 2005 at 04:02:09PM +0100, Duncan Coutts wrote: On Fri, 2005-06-03 at 10:53 +0200, Gracjan Polak wrote: As intern behaves like id and does not have any side effects, I thought its interface should be purely functional. But I do not see any way to do it :( I'll end up with a

Re: [Haskell-cafe] Space questions about intern and sets

2005-06-02 Thread Gracjan Polak
Marcin 'Qrczak' Kowalczyk wrote: Gracjan Polak [EMAIL PROTECTED] writes: intern :: Ord a = a - a intern x = unsafePerformIO $ internIO x iorefset :: Ord a = IORef(Map.Map a a) iorefset = unsafePerformIO $ do newIORef $ Map.empty It will not work because you can't put values of

Re: [Haskell-cafe] Space questions about intern and sets

2005-06-02 Thread Scott Turner
On 2005 June 02 Thursday 04:38, Gracjan Polak wrote: iorefset :: Ord a = IORef(Map.Map a a) iorefset = unsafePerformIO $ do newIORef $ Map.empty I could have as many dictionaries as there are types. The problem is I get one dictionary for each object which defeats the idea. To avoid

Re: [Haskell-cafe] Space questions about intern and sets

2005-06-01 Thread Marcin 'Qrczak' Kowalczyk
Gracjan Polak [EMAIL PROTECTED] writes: intern :: Ord a = a - a intern x = unsafePerformIO $ internIO x iorefset :: Ord a = IORef(Map.Map a a) iorefset = unsafePerformIO $ do newIORef $ Map.empty It will not work because you can't put values of different types as keys of the same