
From the user's point of view, there is little difference between a class method and a class-constrained polymorphic function when the
I had looked into the source code of IArray a bit. Like you have found, (!) is not a class method. In fact, none of the claimed class methods in the doc is a class method, and no class method of IArray is documented. Instead, IArray class methods seem to pertain to implementation details (I mean, "unsafeAt"!), and user operations such as (!) are constrained polymorphic functions, e.g., (!) :: (IArray a e, Ix ix) => a ix e -> ix -> e provided instances are abstract types. So the documentation is telling a white lie. Of course, you see the difference when you roll your own IArray instance. I think the white lie is a balance between exposition simplicity and implementation tuning.

Albert Lai
I had looked into the source code of IArray a bit. Like you have found, (!) is not a class method. [...]
Right. Shouldn't they be, though? I'm probably falling into some put-everything-in-classes trap, but wouldn't it be nice to overload these functions (as well as the previously mentioned list operations)?
Of course, you see the difference when you roll your own IArray instance.
Yes, and given the class members, I'm not at all sure how to implement it. My instinct tells me not to mess with it, and invent a different operator for indexing (which I already did anyway) -kzm -- If I haven't seen further, it is by standing in the footprints of giants
participants (2)
-
Albert Lai
-
ketil@ii.uib.no