Update fibonacci to the latest API

This commit is contained in:
yamadapc 2016-06-20 14:55:47 -03:00
parent d082f6c69c
commit 57d66afd31

View File

@ -1,18 +1,16 @@
module Main where
import qualified GHCJS.CommonJS as CommonJS
import GHCJS.CommonJS (exportMain, exports)
fibs :: [Int]
fibs = 1 : 1 : zipWith (+) fibs (tail fibs)
main :: IO ()
main = CommonJS.exportMain
[ CommonJS.pack ("fibs", \n -> take n fibs)
-- ^ We can "CommonJS.pack" pure functions!
, CommonJS.pack
("fibsIO", \n -> do
putStrLn ("HASKELL LAND - Calculating fibs of " ++ show n)
return (take n fibs)
)
main = exportMain
[ "fibs" `exports` \n -> take n fibs
-- ^ We can "exports" pure functions!
, "fibsIO" `exports` \n -> do
putStrLn ("HASKELL LAND - Calculating fibs of " ++ show n)
return (take n fibs)
-- ^ And IO still works as expected
]