简体   繁体   English

我正确使用ghcjs吗?

[英]Am I using ghcjs correctly?

I'm quite new to Haskell and ghcjs. 我对Haskell和ghcjs很新。 I'm starting with the very first "Hello, world!" 我从第一个“Hello,world!”开始 program to learn. 程序学习。

Here is my Haskell program, copied from GHCJS wiki: 这是我的Haskell程序,复制自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": 我使用命令ghcjs -o hello hello.hs将其编译为javascript,我尝试使用命令node hello.jsexe/all.js在终端上运行它,但是当我尝试打开生成的文件“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. 但是当我在Chrome中打开此页面时,页面为空白。 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. putStrLn文本输出到Javascript控制台,您通常可以通过所选浏览器中的“开发人员工具”访问该控制台。 It does not generate any HTML. 它不会生成任何HTML。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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