list-fusion-probe-0.1.0.7: testing list fusion for success

CopyrightCopyright (C) 2014 Joachim Breitner
LicenseBSD3
MaintainerJoachim Breitner <mail@joachim-breitner.de>
Stabilitystable
PortabilityGHCspecific
Safe HaskellNone
LanguageHaskell98

Data.List.Fusion.Probe

Description

 

Synopsis

Documentation

fuseThis :: [a] -> [a] Source #

This function can be wrapped around a list that should be compiled away by list fusion. If it does, this function will disappear. If not, it will throw an error at runtime.

main = print $ foldl (+) 0 (fuseThis [0..1000])

Will print Test: fuseList: List did not fuse, while

main = print $ foldr (+) 0 (fuseThis [0..1000])

will print 500500.

(These examples are from the time before GHC-7.10. Since then, foldl fuses as well.)