[Haskell-cafe] Mutable arrays

Jeff φ jeff1.61803 at gmail.com
Wed Feb 6 14:20:42 EST 2008

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
as Haskell.

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...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080206/063a27d3/attachment.htm

More information about the Haskell-Cafe mailing list