Skip to content

Instantly share code, notes, and snippets.

@berdario berdario/foo2.hs
Created Jul 22, 2016

Embed
What would you like to do?
Constant Applicative Form sharing/evaluation (will get different output in ghci or when compiled)
foo :: String -> IO ()
foo dummy = do
let (x, y) = (1, 1)
(x, y) <- pure $ (trace "x" (x+1), (trace "y" y*3)
print $ show (y + y) <> dummy
print $ show (x + x) <> dummy
foo2 x = foo (trace "outerfoo" "foo")
foo3 xs dummy = print $ show (map (+1) xs) <> dummy
foo4 = foo3 [trace "1" 1,2,3]
foo5 dummy = print $ show (map (+1) [trace "1" 1,2,3]) <> dummy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.