Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 784
Yiyue Wang Avatar asked Apr 18 '15 08:04

Yiyue Wang


1 Answers

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.

like image 74
kqr Avatar answered Sep 19 '22 14:09

kqr