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

2004-06-22 Thread John Meacham
On Tue, Jun 22, 2004 at 11:54:17AM +0100, Simon Marlow wrote: > I'm torn. If it were free, it would be a no-brainer. But I know of > several cases where IORefs are performance-critical (or at least > performance-important). We should implement & measure. Yeah, i forgot about the GC moving thing

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

Re: [Haskell-cafe] Polymorphic algebraic type constructors

2004-06-22 Thread Adrian Hey
On Tuesday 22 Jun 2004 9:09 pm, Duncan Coutts wrote: > I think the point is that [] (or e in your example) has type > forall a.[a] > where as in the original example e was bound to an argument with the > type [Int], so e could not be used where something of type [Bool] was > required. On the other

[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] 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 d

Re: [Haskell-cafe] Polymorphic algebraic type constructors

2004-06-22 Thread Adrian Hey
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 significant (I don't believe it is) then consistency d

Re: [Haskell-cafe] Polymorphic algebraic type constructors

2004-06-22 Thread MR K P SCHUPKE
>to be [] in each case. 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! you mean: f :: [Int] -> [Bool] f (i:is) = even i : f is f _ = [] Keean. ___

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) ->

[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 t

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 t

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

2004-06-22 Thread Jan-Willem Maessen - Sun Labs East
Simon Peyton-Jones wrote: ... There is an efficiency cost though. Each IORef would need to have an extra field, to record its allocation ID. (Address is not enough -- the garbage collector can mangle them.) My own view is that this is fine -- IORefs shouldn't be in your inner loop, so an extr

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 co

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)

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 ->

Re: [Haskell-cafe] Polymorphic algebraic type constructors

2004-06-22 Thread Adrian Hey
I think this was the topic of my very first post to Haskell mailing list, many years ago.. http://www.dcs.gla.ac.uk/mail-www/haskell/msg00452.html I think the answer is no. Apparently this is feature (I still think it's a bug though:-) Regards -- Adrian Hey On Monday 21 Jun 2004 6:03 pm, Graha

Re: [Haskell-cafe] Polymorphic algebraic type constructors

2004-06-22 Thread MR K P SCHUPKE
>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 _ other = other Isn't this more or less what was in the original... The pro

Re: [Haskell-cafe] Polymorphic algebraic type constructors

2004-06-22 Thread Tomasz Zielonka
On Mon, Jun 21, 2004 at 06:03:21PM +0100, Graham Klyne wrote: > If I have a polymorphic algebraic type (T a) with several type > constructors, only one of which actually references the type parameter, is > there any way to express type conversion for the type-parameter-independent > constructors

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] Ord (IORef a)?

2004-06-22 Thread Simon Marlow
On 22 June 2004 10:38, Simon Peyton-Jones wrote: >> 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. >> >> S

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

2004-06-22 Thread Tom Pledger
John Meacham wrote: 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 can be arbitra

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 ca

[Haskell-cafe] Polymorphic algebraic type constructors

2004-06-22 Thread Graham Klyne
If I have a polymorphic algebraic type (T a) with several type constructors, only one of which actually references the type parameter, is there any way to express type conversion for the type-parameter-independent constructors without actually mentioning all the constructors? Here's a simple ex

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 : BSD-

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, thi