[Haskell-cafe] Data.Foldable UArray

Carter Schonwald carter.schonwald at gmail.com
Thu Feb 20 21:27:39 UTC 2014


not every value can be unboxed. A good example for understanding this would
be looking at the Unboxed Modules in the Vector package


On Thu, Feb 20, 2014 at 4:12 PM, Marcus D. Gabriel <marcus at gabriel.name>wrote:

> Hello,
>
> I wanted to make a simple Data.Foldable UArray, and I naively modelled
> it on
>
> > instance Ix i => Foldable (Array i) where
> >  foldr f z = Prelude.foldr f z . elems
>
> with, of course,
>
> > instance Ix i => Foldable (UArray i) where
> > foldr f z = Prelude.foldr f z . elems
>
> which did not work yielding the following type message
>
>   Could not deduce (IArray UArray a) arising from a use of `elems'
>   from the context (Ix i) bound by the instance declaration at
>   ... Possible fix: add an instance declaration for (IArray UArray
>   a) In the second argument of `(.)', namely `elems' In the
>   expression: Data.List.foldr f z . elems In an equation for
>   `foldr': foldr f z = Data.List.foldr f z . elems
>
> I clearly do not understand something because I cannot make this work,
> and I am not sure why.
>
> With the Haskell type system or even with ghc extensions, can one even
> make a Data.Foldable UArray?  If so, how?
>
> Thanks in advance,
> - Marcus
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140220/af1c1841/attachment.html>


More information about the Haskell-Cafe mailing list