简体   繁体   中英

Am I using ghcjs correctly?

I'm quite new to Haskell and ghcjs. I'm starting with the very first "Hello, world!" program to learn.

Here is my Haskell program, copied from GHCJS wiki:

module Main where
main = putStrLn "Hello world!"

I use the command ghcjs -o hello hello.hs to compile it to javascript, and I tried to run it on my Terminal with the command node hello.jsexe/all.js , but when I tried to open the generated file "index.html":

<!DOCTYPE html>
  <html>
    <head>
      <script language="javascript" src="rts.js"></script>
      <script language="javascript" src="lib.js"></script>
      <script language="javascript" src="out.js"></script>
    </head>
    <body>
    </body>
    <script language="javascript" src="runmain.js" defer></script>
</html>

But when I open this in Chrome the page is blank. Does anyone know what's wrong here?

putStrLn outputs text to the Javascript console, which you can usually reach through the "developer tools" in your browser of choice. It does not generate any HTML.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM