on master help sign in
q for quit
commit7e14cfb8d39632cb40bd552ddd8fd5c20b3f35d6 authorMichael Snoyman <michael@snoyman.com> dateWed 15 Sep 2010, 09:45 (16 years ago) parent60407d9
3 files changed+12−2
.gitignore+2 wai-handler-devel.cabal+1−1 wai-handler-devel.hs+9−1
.gitignorenew file+2
@@ -0,0 +1,2 @@
1+*.swp
2+/dist/
wai-handler-devel.cabal+1−1
@@ -1,5 +1,5 @@
11Name: wai-handler-devel
2−Version: 0.0.0
2+Version: 0.0.1
33Synopsis: WAI server that automatically reloads code after modification.
44Description: This handler automatically reloads your source code upon any changes. It works by using the hint package, essentially embedding GHC inside the handler. The handler (both the executable and library) takes three arguments: the port to listen on, the module name containing the application function, and the name of the function.
55 .
wai-handler-devel.hs+9−1
@@ -1,6 +1,7 @@
11{-# LANGUAGE DeriveDataTypeable #-}
22import Network.Wai.Handler.DevelServer (run)
33import System.Console.CmdArgs
4+import Control.Concurrent (forkIO)
45
56data Devel = Devel
67 { port :: Int
@@ -16,4 +17,11 @@ main = do
1617 , moduleName = "" &= argPos 1 &= typ "MODULE"
1718 , function = "" &= argPos 2 &= typ "FUNCTION"
1819 } &= summary "WAI development web server"
19− run p m f
20+ forkIO $ run p m f
21+ go
22+ where
23+ go = do
24+ x <- getLine
25+ case x of
26+ 'q':_ -> putStrLn "Quitting, goodbye!"
27+ _ -> go