[Haskell-cafe] Mutable arrays
bf3 at telenet.be
Wed Feb 6 15:45:43 EST 2008
I see. Unfortunately I did not spent enough time playing with Clean, and I'm
still learning Haskell, so I can't give any feedback on your questions J
Now from the little time I've spent in the company of Clean, I must say
there's another advantage of uniqueness typing: it is very easy to
understand. While monads are a tiny bit more demanding! But monads give such
a mental satisfaction once you see the light ;-)
So you say uniqueness typing might be more general. Can one make list monads
and all the other funky Haskell monads with Clean's uniqueness typing then?
From: Jeff φ [mailto:jeff1.61803 at gmail.com]
Sent: woensdag 6 februari 2008 20:21
To: Peter Verswyvelen; Neil Mitchell; Don Stewart
Cc: haskell-cafe at haskell.org
Subject: Re: [Haskell-cafe] Mutable arrays
On 2/6/08, Peter Verswyvelen <bf3 at telenet.be> wrote:
Yeah, I also believed that, but then I'm confused:
So monads *do* enforce uniqueness... So what is the difference between
Haskell's monad approach and Clean's uniqueness typing? I always thought
these were just two different ways to tackle the same problem, and I had the
feeling Haskell's approach was actually more general.
IO and mutable array monads could be implemented on top of Clean's unique
arrays and world objects. So, I'd argue that Clean is at least as general
On the other hand, I've posted two similar problems to this list. In Haskell
I want to . . .
1) turn a mutable array into a lazy list
2) turn the contents of a file into a lazy list
The responses I've received are typically:
1) Use unsafeFreeze / unsafeThaw
2) Use hGetContents. (which uses unsafePeformIO under the hood.)
3) Don't use a lazy list. Rewrite the code to break the data up into
smaller chunks and process the chunks in a loop.
I have solved both of these problems in Clean using a lazy list without
resorting to unsafe operations. So, it seems to me that uniqueness types
are more general than monads.
By the way, I'm not good enough to use unsafe functions. My code would
crash for sure. :-)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe