[Haskell-cafe] unsafeDestructiveAssign?

John Lato jwlato at gmail.com
Wed Aug 12 13:48:33 EDT 2009


On Wed, Aug 12, 2009 at 2:39 PM, Derek Elkins<derek.a.elkins at gmail.com> wrote:
>
> (To Alberto as well.)
>
> Unsurprisingly, Lennart stated the real issue, but I'll re-emphasize
> it.  As much trouble as such a profound violation of purity would
> cause, it's not the biggest problem.  If that were all, you could
> easily write a C/assembly function that would do what was desired.
> The real problem is that there isn't necessarily any "data chunk" at
> all, i.e. there may not be anything to mutate.
>

Lennart is right of course, but wouldn't his example just be a
specific case of my argument?  That is, the compiler decided to
evaluate the data at compile time by replacing it with the primitive
value and inlining it?  It seems to me that in the absence of putting
some scope or sequencing upon the mutating function, there's no way
for such an unsafeMutate* to have any defined meaning in Haskell.  And
once you have provided either scope or evaluation order, it would be
equivalent to just using a monad (although not necessarily IO).

Which leads to the point I really want to make.  Would a monad other
than IO be acceptable?  You could provide this functionality with a
Reader's 'local' function for example, or with State.

Cheers,
John


More information about the Haskell-Cafe mailing list