Skip to content

Instantly share code, notes, and snippets.

@chrissound
Created December 2, 2018 11:57
Show Gist options
  • Save chrissound/5e74c2f4efca494439a426b30a05668b to your computer and use it in GitHub Desktop.
Save chrissound/5e74c2f4efca494439a426b30a05668b to your computer and use it in GitHub Desktop.
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE Strict #-}
{-# LANGUAGE StrictData #-}
import Debug.Trace
import System.IO
import System.IO.Unsafe
main :: IO ()
main = do
hSetBuffering stderr NoBuffering
hSetBuffering stdout NoBuffering
let !b = (fff 2 10)
putStrLn $ "b: " ++ show b
let !c = (fff 3 15)
putStrLn $ "c: " ++ show c
print "---"
fff :: Int -> Int -> Int
fff = do
(-) . ff
hmm :: a -> a
hmm x = unsafePerformIO $! do
print "this only happens once"
pure x
ff :: Int -> Int
ff z = do
hmm (trace "x is: " . traceShowId) $ z
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment