Skip to content

Instantly share code, notes, and snippets.

@mstksg
Forked from anonymous/dead-code-tests.hs
Created November 13, 2013 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mstksg/7456610 to your computer and use it in GitHub Desktop.
Save mstksg/7456610 to your computer and use it in GitHub Desktop.
Three files, one with only main, one with main + non-referenced IO object, one with main + referenced IO object (technically, one with a larger main IO object). The non-referenced IO object is never compiled, as the resulting object files have the same md5sum.
-- test1.hs
-- No dead code: compiles to 1.22M executable
-- with stripped .o 1320 byes
-- .o file md5sum: 35ccd1647c772a5757fba3ae8bfa6542
main :: IO ()
main = getLine >>= print
-- test2.hs
-- With dead code: compiles to 1.22M executable
-- with stripped .o 1320 byes
-- .o file md5sum: 35ccd1647c772a5757fba3ae8bfa6542
main :: IO ()
main = getLine >>= print
unreached :: IO ()
unreached = putStrLn "What are you doing here?"
-- test3.hs
-- "Control": compiles to 1.23M executable
-- with stripped .o 1448 byes
-- .o file md5sum: 09b15c76ecae08c9b5be7564808602f1
main :: IO ()
main = getLine >>= reached
reached :: String -> IO ()
reached s = print (tail s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment