-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from well-typed/edsko/ipe
Add demo of the use of the profiling callstack
- Loading branch information
Showing
9 changed files
with
199 additions
and
90 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
-- | Profiling version of the callback demo | ||
-- | ||
-- Requires the code to be built with profiling info. | ||
module Demo.Callback.Profiling (demo) where | ||
|
||
import GHC.Stack | ||
|
||
{------------------------------------------------------------------------------- | ||
Top-level | ||
-------------------------------------------------------------------------------} | ||
|
||
demo :: Maybe Int -> IO () | ||
demo Nothing = f1 (\x -> g1 x) | ||
demo (Just i) = f1 (\x -> g1 (x + i)) | ||
|
||
{------------------------------------------------------------------------------- | ||
Demo proper | ||
-------------------------------------------------------------------------------} | ||
|
||
f1 :: (Int -> IO ()) -> IO () | ||
f1 k = do | ||
cs <- whoCreated k | ||
putStrLn $ "f1: invoking callback defined at " ++ show (cs) | ||
f2 k | ||
|
||
f2 :: (Int -> IO ()) -> IO () | ||
f2 k = k 1 | ||
|
||
g1 :: Int -> IO () | ||
g1 n = g2 n | ||
|
||
g2 :: Int -> IO () | ||
g2 n = do | ||
cs <- currentCallStack | ||
putStrLn $ "n = " ++ show n ++ " at " ++ show cs |
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
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
Oops, something went wrong.