mirror of
https://github.com/beijaflor-io/ghcjs-commonjs.git
synced 2024-09-11 16:25:25 +03:00
Update fibonacci to the latest API
This commit is contained in:
parent
d082f6c69c
commit
57d66afd31
@ -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
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user