【发布时间】:2015-01-05 19:14:16
【问题描述】:
这是一个简单的wai/warp 程序,因此我可以了解ghci 调试器的实际工作原理:-
{-# LANGUAGE OverloadedStrings #-}
import Network.Wai
import Network.HTTP.Types (status200)
import Network.Wai.Handler.Warp (run)
import Debug.Trace (trace)
myApp req respond = do
let x = 1 {- line 8 -}
putStrLn "processing request" {- line 9 -}
putStrLn "Hoooray!" {- line 10 -}
respond $ responseLBS status200 [("Content-Type", "text/plain")] "Hello World"
main = run 3000 myApp
在ghci,我首先加载这个程序(例如:load hellowai.hs)。
然后,我在第 9 行和第 10 行设置断点
:break 9
:break 10
然后,在ghci 中,我执行main。
然后我在浏览器上或使用 curl(当然没关系)运行 localhost:3000,我的程序在第 9 行按预期中断。
如何打印(内省)x 以及如何内省 req?
我尝试使用 :print 和 ghci 只是抱怨“不在范围内”。
Stopped at hellowai.hs:9:5-33
_result :: IO () = _
[hellowai.hs:9:5-33] *Main> :print x
Top level: Not in scope: ‘x’
[hellowai.hs:9:5-33] *Main> :print req
Top level:
Not in scope: ‘req’
Perhaps you meant one of these:
‘rem’ (imported from Prelude), ‘seq’ (imported from Prelude)
[hellowai.hs:9:5-33] *Main>
【问题讨论】:
标签: haskell ghci haskell-warp