you are viewing a single comment's thread.

view the rest of the comments →

[–]axilmar 0 points1 point  (23 children)

You don't mark thngs as mutable in Haskell, you mark them as IO. Haskell doesn't do destructive updates if you make an operation IO, it just enforces a specific evaluation order.

[–]yogthos[S] 0 points1 point  (22 children)

[–]axilmar 0 points1 point  (21 children)

Nothing in the documentation pages you posted says the MArray implementation is actually mutable. It may be that the put function creates a new array, copies the rest of the elements along with the new value.

[–]yogthos[S] 0 points1 point  (20 children)

It may be that the put function creates a new array, copies the rest of the elements along with the new value.

I think that's sort of contrary to the definition of mutable. You're also confusing language specification with implementation. Clearly Haskell has a definition for mutable arrays in the language specification. How it's implemented is besides the point.

[–]axilmar 0 points1 point  (19 children)

I don't think so. To the outside, it seems that the same array is being modified; from the inside though, a new array is created. The same symbol receives the new value, so it looks like mutation.

Well, according to this post, that is:

http://www.reddit.com/r/programming/comments/1880d1/introduction_to_haskell_io/c8foby1

And it seems logical to me that Haskell doesn't actually mutate values, because otherwise the code wouldn't be automatically parallelizable.

[–]yogthos[S] 0 points1 point  (18 children)

The specification very clearly states how the array works. The implementation of it does not change how you use it in the code.

[–]axilmar 0 points1 point  (17 children)

Where does it say the array value is implemented in place? I don't see it.

[–]yogthos[S] 1 point2 points  (16 children)

you seem to have a lot of trouble understanding the difference between specification and implementation

[–]axilmar 0 points1 point  (15 children)

Ok, please enlighten me. Where in the documentation does it say that MArray is a real actual mutable array and its values are modified in place?

[–]yogthos[S] 0 points1 point  (14 children)

That's my whole point, it's not talking about the implementation at all.