I have also asked this question on stackoverflow where the full code snippet is listed. (https://stackoverflow.com/questions/45260173/proc-syntax-in-haskell-arrows-leads-to-severe-performance-penalty)
 
I am facing a weird digression when using the following code:
 
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
 
-------- Конец пересылаемого сообщения --------