<div dir="ltr">not every value can be unboxed. A good example for understanding this would be looking at the Unboxed Modules in the Vector package</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 20, 2014 at 4:12 PM, Marcus D. Gabriel <span dir="ltr"><<a href="mailto:marcus@gabriel.name" target="_blank">marcus@gabriel.name</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I wanted to make a simple Data.Foldable UArray, and I naively modelled<br>
it on<br>
<br>
> instance Ix i => Foldable (Array i) where<br>
>  foldr f z = Prelude.foldr f z . elems<br>
<br>
with, of course,<br>
<br>
> instance Ix i => Foldable (UArray i) where<br>
> foldr f z = Prelude.foldr f z . elems<br>
<br>
which did not work yielding the following type message<br>
<br>
  Could not deduce (IArray UArray a) arising from a use of `elems'<br>
  from the context (Ix i) bound by the instance declaration at<br>
  ... Possible fix: add an instance declaration for (IArray UArray<br>
  a) In the second argument of `(.)', namely `elems' In the<br>
  expression: Data.List.foldr f z . elems In an equation for<br>
  `foldr': foldr f z = Data.List.foldr f z . elems<br>
<br>
I clearly do not understand something because I cannot make this work,<br>
and I am not sure why.<br>
<br>
With the Haskell type system or even with ghc extensions, can one even<br>
make a Data.Foldable UArray?  If so, how?<br>
<br>
Thanks in advance,<br>
- Marcus<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br></div>