He Stephen
Thanks for the tip. I will test the performance of Data.Sequence against Immutable arrays.
I
also have another question about deriving monads. I have modified
Data.List.Zipper, so it supports 2 extra directions (up and down):
data Zipper a = Zip [a] [a] [a] [a]
Now I made a functor out of it:
instance Functor Zipper where
-- fmap :: (a -> b) -> f a -> f b
f `fmap` (Zip ls rs ds us) = Zip (f `fmap` ls) (f `fmap` rs) (f `fmap` ds) (f `fmap` us)
This works. Now I try to make an monad out of it:
instance Monad Zipper where
return a = Zip [a] [] [] []
(Zip ls rs ds us) >>= f = Zip (ls >>= f) (rs >>= f) (ds >>= f) (us >>= f)
This doesn't work like expected, but when using the newtype derive mechanism it works.
Thanks for all your help so far.
Best Wishes,
Edgar