Created
March 31, 2012 08:51
-
-
Save yihuang/2260987 to your computer and use it in GitHub Desktop.
crazy ghc optimization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Test (test) where | |
test :: [Int] -> Bool | |
test l = all (==(-1)) $ zipWith (-) l (tail l) | |
{- | |
ghc -ddump-simpl -O ghc-optimization.hs | |
after clean up: | |
test1 :: Int -> Int -> Bool | |
test1 a b = (a-b) == (-1) | |
test :: [Int] -> Bool | |
test l = GHC.List.foldr2 test1 True l (case l of | |
[] -> GHC.List.tail1 | |
(x:xs) -> xs | |
) | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment