Re: [Haskell-cafe] Ord (IORef a)?

2004-06-22 Thread ajb
G'day all. Quoting John Meacham [EMAIL PROTECTED]: would it be possible to provide an Ord instance for (IORef a)? It would, although then someone else would just want a hashable instance. Sounds to me like it might be worth coming up with a general IORef (and STRef) wrapper. Until then, this

Re: [Haskell-cafe] Ord (IORef a)?

2004-06-22 Thread ajb
G'day all. Quoting [EMAIL PROTECTED]: Until then, this is what I use. Second time lucky. Cheers, Andrew Bromage- -- | -- Module : Data.IOStableRef -- Copyright : (c) Andrew Bromage 2002 -- License :

RE: [Haskell-cafe] Ord (IORef a)?

2004-06-22 Thread Simon Peyton-Jones
| From: John Meacham | would it be possible to provide an Ord instance for (IORef a)? For | things like loop detection, one may need to make many IORef comparasions | and being able to use an efficient set would be a really big win. | | Since IORefs are created in the IO monad, the actual order

Re: [Haskell-cafe] Polymorphic algebraic type constructors

2004-06-22 Thread MR K P SCHUPKE
If I have a polymorphic algebraic type (T a) with several type data MyType a = A a | B String | C Int So how do you expect to get the contents of B and C outm when they are differenf Types - surely you mean: data MyType a = A a | B MyStrings Keean.

Re: [Haskell-cafe] Polymorphic algebraic type constructors

2004-06-22 Thread MR K P SCHUPKE
(I still think it's a bug though:-) It is definitely not a bug... you cannot assert that the types: Either String a Either String b are both equal ant not equal at the same time. You either mean: f :: (a-a) - Either String a - Either String a Or you mean f :: (a-b) - Either String a - Either

Re: [Haskell-cafe] Polymorphic algebraic type constructors

2004-06-22 Thread Tomasz Zielonka
On Tue, Jun 22, 2004 at 01:29:02PM +0100, MR K P SCHUPKE wrote: data E a b = L1 { r :: a } | L2 { r :: a } | L3 { r :: a } | L4 { r :: a } | R b deriving Show How is this different from: data E a b = L1 a | L2 a | R b f g (R a) = R (g a) f _

Re: [Haskell-cafe] Ord (IORef a)?

2004-06-22 Thread Fergus Henderson
On 22-Jun-2004, Simon Peyton-Jones [EMAIL PROTECTED] wrote: My own view is that this is fine -- IORefs shouldn't be in your inner loop, so an extra word in each is no big deal. I find that attitude rather extraordinary and I do not agree. For some applications, IORefs may well be a major

Re: [Haskell-cafe] Polymorphic algebraic type constructors

2004-06-22 Thread Tomasz Zielonka
On Tue, Jun 22, 2004 at 02:52:21PM +0200, Tomasz Zielonka wrote: Record update avoids this because of the way it is translated. Basically, the result of record update is a reconstructed record, but constructors not containing updated fields are not built/copied, so they don't constrain the

[Haskell-cafe] how to get started: a text application

2004-06-22 Thread Max Ischenko
Hi all, I'm going to try to implement a version of Markdown tool[1] in Haskell. The application is rather simple: take a text file with some (simple) mark-up embedded in it and turn it into another text file, this time with XHTML markup. I need some guidelines on how to get started. I'll have

Re: [Haskell-cafe] Polymorphic algebraic type constructors

2004-06-22 Thread Adrian Hey
On Tuesday 22 Jun 2004 1:50 pm, MR K P SCHUPKE wrote: (I still think it's a bug though:-) It is definitely not a bug... you cannot assert that the types: Either String a Either String b are both equal ant not equal at the same time. I wasn't. You either mean: f :: (a-a) - Either

Re: [Haskell-cafe] Polymorphic algebraic type constructors

2004-06-22 Thread Duncan Coutts
On Tue, 2004-06-22 at 20:52, Adrian Hey wrote: On Tuesday 22 Jun 2004 6:20 pm, MR K P SCHUPKE wrote: ahh but in this example: f :: [Int] - [Bool] f (i:is) = even i : f is f [EMAIL PROTECTED] = e e is an empty list of Ints not an empty list of Bools! If the difference is

[Haskell-cafe] How to use QSem?

2004-06-22 Thread S. Alexander Jacobson
The GHC documentation on QSem is very sparse. I would like to give a thread exclusive access to a resource. My *guess* based on the documentation is that I can create an exclusive lock using: logSem - newQSem 1 And then any thread that wants to lock the resource uses: withLogSem x = do

Re: [Haskell-cafe] Ord (IORef a)?

2004-06-22 Thread ajb
G'day all. Quoting Fergus Henderson [EMAIL PROTECTED]: I find that attitude rather extraordinary and I do not agree. Me too. I've written more than one Haskell program where hash consing is part of an inner loop. For this applciation the data structures weren't that big, but I can easily