[Haskell-beginners] Brainfuck interpreter stack overflow

Edgar Klerks edgar at goodforall.eu
Tue Jan 26 11:06:25 EST 2010


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100126/7fdc60fe/attachment.html


More information about the Beginners mailing list