For the record, Michael's suggestion
worked for me, and it was quite space and time efficient.
Here is a code fragment in case someone like me is looking for
this:
> {-# LANGUAGE FlexibleContexts, TypeFamilies #-}
> import Data.Array.IArray (IArray)
> import Data.Array.Unboxed (UArray, (!), array, elems, bounds)
> import Data.Ix (Ix)
> import qualified Data.List as L
> import qualified Data.Foldable.Mono as F
> instance (Ix i, IArray UArray e) => F.MFoldable (UArray i
e) where
> type Elem (UArray i e) = e
> foldl f z = L.foldl f z . elems
> foldl' f z = L.foldl' f z . elems
> foldl1 f = L.foldl1 f . elems
> foldr f z = L.foldr f z . elems
> foldr1 f = L.foldr1 f . elems
To be honest, I was aware of TypeFamilies, but they are new to me
so I need a little study.
Cheers,
- Marcus
On 21/02/2014 07:06, Michael Snoyman wrote: