結構體
檔案結構
一個簡單的專案包含以下檔案:
➜ 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"