3 ms·
How does Haskell fare with large projects that use APIs that are inherently stateful, like OpenGL? Don't things get messy and ugly as the pure world of Haskell
by codygman 10y ago
How does Haskell fare with large projects that use APIs that are inherently stateful, like OpenGL? Don't things get messy and ugly as the pure world of Haskell is being tainted?
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-haskell.html 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-optimization.html 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://www.haskellforall.com/2012/10/hello-core.html
http://blog.ezyang.com/2011/04/tracing-the-compilation-of-hello-factorial/ http://blog.ezyang.com/2011/04/tracing-the-compilation-of-he...
https://skillsmatter.com/skillscasts/6495-keynote-from-simon-peyton-jonesh(tp://blog.ezyang.com/2011/04/tracing-the-compilation-of-hello-factorial/ https://skillsmatter.com/skillscasts/6495-keynote-from-simon... (go back over after watching above)
http://www.stephendiehl.com/posts/ghc_03.html 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 http://stackoverflow.com/questions/6121146/reading-ghc-core
- codygman 10y agoA 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 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.