Skip to content

Instantly share code, notes, and snippets.

@osa1
Created May 18, 2014 08:10
Show Gist options
  • Save osa1/319c64a38c93b57559a5 to your computer and use it in GitHub Desktop.
Save osa1/319c64a38c93b57559a5 to your computer and use it in GitHub Desktop.
{-# LANGUAGE LambdaCase #-}
fib :: Integer -> Integer
fib 0 = 1
fib 1 = 1
fib n = fib (n - 1) + fib (n - 2)
fib' :: Integer -> Integer
fib' = \case
0 -> 1
1 -> 1
n -> fib' (n - 1) + fib' (n - 2)
main = do
print $ fib 30
print $ fib' 30
➜ exception-test ghcjs -prof -fprof-auto exceptions.hs -O0
generating native
[1 of 1] Compiling Main ( exceptions.hs, exceptions.o )
generating JavaScript
[1 of 1] Compiling Main ( exceptions.hs, exceptions.js_o )
genToplevelDecl for id: fib
ignoring StgRhsClosure with free vars: [] with CCS: CCS_DONT_CARE
ignoring StgSCC with CC: fib
genToplevelDecl for id: fib'
ignoring StgRhsClosure with free vars: [] with CCS: CAF_ccs
ignoring StgSCC with CC: fib'
ignoring StgSCC with CC: fib'
ignoring StgSCC with CC: fib'.\
ignoring StgSCC with CC: fib'.\
ignoring StgSCC with CC: fib'.\
genToplevelDecl for id: Main.main
ignoring StgRhsClosure with free vars: [] with CCS: CAF_ccs
ignoring StgSCC with CC: main
genToplevelDecl for id: :Main.main
ignoring StgRhsClosure with free vars: [] with CCS: CAF_ccs
Linking exceptions.jsexe (Main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment