sumArr = scan (\acc x -> let !newAcc = acc + x in newAcc) 0
sumArr' = proc v -> do sumArr -< v
testData :: [Int]
testData = [1..1000000]
main = print $ L.last $ evalList sumArr' testData
Running time for main with sumArr (i.e. no proc notation) is 0.087 sec, while for sumArr' it is 3.2 seconds (and around 300mb memory usage), although sumArr' is just sumArr called within a proc block.
Can some body explain what is causing this difference? Is there some laziness induced by the use of proc? And how and when proc gets desugared?
Thank you.
Artem