Here's a trivial wai
/warp
program so I can learn how ghci
debugger actually works:-
{-# 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
In ghci
, I first load this program (e.g. with :load hellowai.hs
).
Then, I set my break points in line 9 and line 10 with
:break 9
:break 10
Then, in ghci
, I execute main
.
I then run localhost:3000
on my browser or with curl (doesn't matter of course) and my program breaks at line 9 as expected.
How do I print out (introspect) x
and how do I introspect req
?
I tried using :print
and ghci
simply complains "Not in scope".
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>