Haskell語言學習筆記(69)Yesod
阿新 • • 發佈:2018-01-10
log class core sta hello 安裝失敗 platform gpo info
Yesod
Yesod 是一個使用 Haskell 語言的 Web 框架。
安裝 Yesod
首先更新 Haskell Platform 到最新版
(Yesod 依賴的庫非常多,版本不一致的話很容易安裝失敗)
$ cabal install yesod
Installed yesod-1.4.5
Hello World
-- helloworld.hs {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} import Yesod data HelloWorld = HelloWorld mkYesod "HelloWorld" [parseRoutes| / HomeR GET |] instance Yesod HelloWorld getHomeR :: Handler Html getHomeR = defaultLayout [whamlet|Hello World!|] main :: IO () main = warp 3000 HelloWorld
$ runhaskell helloworld.hs
[Info#yesod-core] Application launched @(yesod-core...
在Web Browser裏面鍵入
http://localhost:3000
得到如下網頁
<!DOCTYPE html>
<html><head><title></title></head><body>Hello World!</body></html>
Haskell語言學習筆記(69)Yesod