Re:Why hasn't Haskell taken over the world? And the curious ...
by codygman on Sunday January 22, 2017 @04:41AM
(#13454451)
A bug report that is a good example of how to read core, at least it seemed easy to tie the very simplistic code to the expanded core in combination with the commentary.
https://ghc.haskell.org/trac/ghc/ticket/11710
Another good tip is to use the ghc option `-ddump-rule-firings` to see if code gets inlined or otherwise optimized.
The pure world of Haskell does not get tainted. Monads help manage the inherent messiness better. As for your question, perhaps this glut example I quickly found and skimmed will help:
http://www.arcadianvisions.com/blog/2011/modern-opengl-with-...
- How do I optimise Haskell code without having studied the language for decades?
Optimizing is where I've been having trouble with lately. You need to understand laziness, inlining, and reading basic core imo.
For understanding laziness, read a few tutorials. Then use the ghci debugger as described in the ghc manual. Play around by adding BangPatterns based on educated guesses from any intuition you formed on how laziness works.
For understanding basic optimization (Space and time):
http://book.realworldhaskell.org/read/profiling-and-optimiza...
For understanding core, read/watch in this order:
http://www.haskellforall.com/2012/10/hello-core.html
http://blog.ezyang.com/2011/04/tracing-the-compilation-of-he...
https://skillsmatter.com/skillscasts/6495-keynote-from-simon... (go back over after watching above)
http://www.stephendiehl.com/posts/ghc_03.html
Try generating core for some Haskell code you want to know about. Tie what you've learned to core generated from Haskell code that solves one of your real world problems.
http://stackoverflow.com/questions/6121146/reading-ghc-core