John Carmack on Haskell: https://youtu.be/1PhArSujR_A?t=125
Notes on GHC
Given a program Foo.hs
:
module Foo (bar) where
bar x y = x + y + 42
Get the core representation with:
$ ghc Foo.hs -ddump-simpl -fmax-simplifier-iterations=0 -dsuppress-uniques -dsuppress-module-prefixes -dsuppress-idinfo
[1 of 1] Compiling Foo ( Foo.hs, Foo.o )
==================== Tidy Core ====================
Result size of Tidy Core
= {terms: 20, types: 17, coercions: 0, joins: 0/0}
-- RHS size: {terms: 13, types: 9, coercions: 0, joins: 0/0}
bar :: forall a. Num a => a -> a -> a
bar
= \ (@ a) ($dNum :: Num a) (x :: a) (y :: a) ->
+ @ a $dNum (+ @ a $dNum x y) (fromInteger @ a $dNum 42)
-- RHS size: {terms: 5, types: 0, coercions: 0, joins: 0/0}
$trModule :: Module
$trModule = Module (TrNameS "main"#) (TrNameS "Foo"#)
References
-
Why kind-level foralls don’t interact with ScopedTypeVariables - Great technical writing
-
Haskell supports Type Level Programing, see: https://vitez.me/hts-language
GHC References
To understand the STG, read:
- Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine
- Making a Fast Curry: Push/Enter vs. Eval/Apply for Higher-order Languages
- STG generated code wiki
Blog
I wrote two articles about the language: