Skip to content

Instantly share code, notes, and snippets.

@viercc
Created November 23, 2019 02:45
Show Gist options
  • Save viercc/a514e16724854eaa271226f1f8c142f7 to your computer and use it in GitHub Desktop.
Save viercc/a514e16724854eaa271226f1f8c142f7 to your computer and use it in GitHub Desktop.
Trying GHCJS
$ ghcjs -O2 test.hs
[1 of 1] Compiling Main ( test.hs, test.js_o )
Linking test.jsexe (Main)
$ (cd test.jsexe/ && node all.js)
(0,1)
(1,2)
(2,4)
(3,8)
(4,16)
(5,32)
(6,64)
(7,128)
(8,256)
(9,512)
(10,1024)
(11,2048)
(12,4096)
(13,8192)
(14,16384)
(15,32768)
(16,65536)
(17,131072)
(18,262144)
(19,524288)
(20,1048576)
(21,2097152)
(22,4194304)
(23,8388608)
(24,16777216)
(25,33554432)
(26,67108864)
(27,134217728)
(28,268435456)
(29,536870912)
(30,1073741824)
(31,-2147483648)
(32,0)
(33,0)
(34,0)
(35,0)
(36,0)
(37,0)
(38,0)
(39,0)
module Main where
import Data.List (unfoldr)
import Control.Monad (mapM_)
type I = Int
step :: (Int,I) -> Maybe ((Int,I), (Int,I))
step (i,x) = Just ((i,x), (1+i,2*x))
main :: IO ()
main = mapM_ print $ take 40 (unfoldr step (0,1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment