Re: Instances of IArray
Albert Lai <[EMAIL PROTECTED]> writes: > 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 ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Instances of IArray
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 >From the user's point of view, there is little difference between a class method and a class-constrained polymorphic function when the 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. ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Instances of IArray
Hi, from the GHC documentation (5.17.1 in the libraries section), I get the impression that (!) is a member of the IArray class. While I'm messing about with kinds and stuff getting this properly instantiated, I get an error claiming that EST.lhs:44: Class `IArray' does not have a method `!' In the instance declaration for `IArray EST n' Experimenting with GHCi, I finally worked out Prelude> :i IArray.IArray -- ArrayBase.IArray is a class class (ArrayBase.HasBounds a) => ArrayBase.IArray a :: (* -> * -> *) e where { ArrayBase.unsafeArray :: forall i. (PrelArr.Ix i) => (i, i) -> [(Int, e)] -> a i e; ArrayBase.unsafeAt :: forall i. (PrelArr.Ix i) => a i e -> Int -> e; ArrayBase.unsafeReplace :: forall i. (PrelArr.Ix i) => a i e -> [(Int, e)] -> a i e {- has default method -}; ArrayBase.unsafeAccum :: forall e' i. (PrelArr.Ix i) => (e -> e' -> e) -> a i e -> [(Int, e')] -> a i e {- has default method -}; ArrayBase.unsafeAccumArray :: forall e' i. (PrelArr.Ix i) => (e -> e' -> e) -> e -> (i, i) -> [(Int, e')] -> a i e {- has default method -}; } So, unless I'm misinterpreting something, the documentation is incorrect? What I'd like to have, is Int-indexed access to my classes. ATM, I've solved it with my own class "Indexed" providing a (?) operator. This is (obviously) not consistent with the standard types, and in addition collides slightly with the implicit parameters syntax (works if I leave a space between the ? and the index) -kzm -- If I haven't seen further, it is by standing in the footprints of giants ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users