Hi,<br><br>I&#39;m trying to extended the standard unboxed array types and array classes to my own product types, for now let&#39;s just say (,). So if the proper MArray and IArray instances exist for e and f, then I can make an instance for (e,f). The actual type of that array, something like (UArray i e, UArray i f), would be given by an associated type. This is how the uvector library does it, but that library defines its own array primitives and classes. I&#39;d like to reuse the standard ones if possible.<br>

<br>The problem I keep running into is the kind of the array, * -&gt; * -&gt; *, or &#39;a i e&#39;. The crucial type there is e, which is used to dispatch the instance to the proper associated type, so if e = (a,b) then the array type would be (UArray i a, UArray I b), and if e is (a,b,c) then (UArray i a, UArray i b, UArray i c). If IArray was instead expecting the array type to be &#39;a e i&#39; I could maybe do something like this:<br>

<br>class UArrClass e where<br>&nbsp; data UArr e :: * -&gt; *<br>instance (IArray UArray e, IArray UArray f) =&gt; UArrClass (e,f) where<br>&nbsp; data UArr (e,f) i = UArrPair (UArray i e) (UArray i f)<br><br>But as it stands, I can&#39;t do that. The &#39;i&#39; type parameter has to be bound as a parameter of UArrClass. So instead I tried this.<br>

<br>class UArrClass i e where<br>&nbsp; data UArr i e<br>&nbsp; unsafeAt_ :: UArr i e -&gt; Int -&gt; e<br>&nbsp; --mirror all IArray methods<br><br>instance <br>&nbsp;&nbsp;&nbsp; ( IArray UArray e&nbsp; <br>&nbsp;&nbsp;&nbsp; , IArray UArray f&nbsp; <br>&nbsp;&nbsp;&nbsp; , Ix i&nbsp; --needed for unsafeAt<br>

&nbsp;&nbsp;&nbsp; ) =&gt; UArrClass i (e,f) <br>&nbsp; where<br>&nbsp;&nbsp;&nbsp; newtype UArr i (e,f) = UArrPair (UArray i e) (UArray i f)<br>&nbsp;&nbsp;&nbsp; unsafeAt_ (UArrPair ea fa) i = (unsafeAt ea i , unsafeAt fa i)<br><br>and then the instance for IArray could be defined as follows, just a mapping from the methods of that class onto my own:<br>

<br>instance <br>&nbsp;&nbsp;&nbsp; ( IArray UArray e <br>&nbsp;&nbsp;&nbsp; , IArray UArray f <br>&nbsp;&nbsp;&nbsp; , UArrClass i (e,f)<br>&nbsp;&nbsp;&nbsp; ) =&gt; IArray UArr (e,f) <br>&nbsp; where<br>&nbsp;&nbsp;&nbsp; unsafeAt = unsafeAt_ <br><br>The problem I get now is from the &#39;Ix i&#39; context of the IArray methods. The &#39;i&#39; there is only mentioned in the context of the methods, not the class, so I have no &#39;handle&#39; onto that &#39;i&#39; that I can use to explicitly unify it with the &#39;i&#39; mentioned in UArrClass. The compiler keeps complaining about rigid type variables. It would be great if I could leave that type variable unbound in my class, and only bind it in the methods, as IArray does, but as far as I can tell, I can&#39;t. I need to bind &#39;i&#39; in my class because it&#39;s the first type-argument to the array type constructor, rather than the second. I don&#39;t care about the &#39;i&#39;, its the &#39;e&#39; I&#39;m after, but all applications of the associated type constructor need to be saturated. <br>

<br>Can anyone see a way to do this? I understand there&#39;s about a million other ways to accomplish what I&#39;m trying to do without IArray and MArray, but I&#39;m just wondering if I should abandon those classes altogether, and use my own array classes, using something like uvector or unsafeIO/ForeignPtr. That seems to be trend.<br>

<br>Thanks, <br>Scott<br>