[Haskell-cafe] Mutable arrays

Don Stewart dons at galois.com
Wed Feb 6 14:55:35 EST 2008

>    On 2/6/08, Peter Verswyvelen <[1]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.

They solve a specific issue in the type system that goes statically
unchecked. Monads are a separate issue (and kind of a non-sequitor

Uniquness doesn't give you more than the IO monad.

More information about the Haskell-Cafe mailing list