What is the error that you get?<br><br><br>Cheers,<br>Pedro<br><br><div class="gmail_quote">On Tue, Apr 16, 2013 at 8:07 PM, Anatoly Yakovenko <span dir="ltr"><<a href="mailto:aeyakovenko@gmail.com" target="_blank">aeyakovenko@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>-- ok, something in deriving NFData using Generics in a type that has a Vector in it.</div><div><br>
</div><div><br></div><div>{-# LANGUAGE DeriveGeneric #-}</div><div>import Control.DeepSeq</div>
<div>import System.IO</div><div>import GHC.Generics (Generic)</div><div>import qualified Data.Vector as V</div><div>import qualified Data.ByteString.Lazy.Char8 as BL</div><div><br></div><div>scanl' :: NFData a => (a -> b -> a) -> a -> [b] -> [a]</div>
<div>scanl' f q ls = q : (case ls of</div><div> [] -> []</div><div> x:xs -> let q' = f q x</div><div> in q' `deepseq` scanl' f q' xs)</div>
<div><br></div><div>-- this runs without blowing up</div><div>-- main = print $ last $ scanl' (+) (0::Int) [0..]</div><div><br></div><div>data Simple = Simple (V.Vector Double)</div><div> deriving (Show, Generic)</div>
<div><br></div><div>instance NFData Simple</div><div><br></div><div>--this blows up</div><div>main = do</div><div> let initial = Simple $ V.fromList (take 100 $ repeat 0)</div><div> sumvs (Simple a) (Simple b) = Simple $ V.zipWith (+) a b</div>
<div> print $ last $ scanl' sumvs initial $ repeat $ initial</div><div><br></div><div class="gmail_extra"><br></div></div>
<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>
<br></blockquote></div><br>