Haskell

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

GHC References

To understand the STG, read:

Blog

I wrote two articles about the language:

Conf

ZuriHac

Compositional Type Checking

Links to this page
#pl #hm #functional/pure