结构体
文件结构
一个简单的项目包含以下文件:
➜ helloworld ls
LICENSE Setup.hs helloworld.cabal src stack.yaml
在 src 文件夹中有一个名为 Main.hs 的文件。这是 helloworld 项目的起点。默认情况下,Main.hs 包含一个简单的 Hello World! 程序。
Main.hs
module Main where
main::IO ()
main = do
putStrLn "hello world"
运行程序
确保你在目录 helloworld 并运行:
stack build # Compile the program
stack exec helloworld # Run the program
# prints "hello world"