wai-handler-devel 0.4.3.1 → 0.4.4
raw patch · 2 files changed
+32/−18 lines, 2 filesdep ~bytestringdep ~cmdargsdep ~directory
Dependency ranges changed: bytestring, cmdargs, directory, enumerator, network
Files
Network/Wai/Handler/DevelServer.hs view
@@ -6,6 +6,8 @@ ( run , runQuit , runNoWatch+ , runWithReloadActions+ , runQuitWithReloadActions ) where import Language.Haskell.Interpreter hiding (typeOf)@@ -37,14 +39,18 @@ -> (FilePath -> IO [FilePath]) -> IO () runNoWatch port modu func extras = do ah <- initAppHolder- _ <- reload modu func extras Nothing ah+ _ <- reload modu func extras Nothing ah [] Warp.run port $ toApp ah runQuit :: Int -> ModuleName -> FunctionName -> (FilePath -> IO [FilePath]) -> IO ()-runQuit port modu func extras = do+runQuit port modu func extras = runQuitWithReloadActions port modu func extras []++runQuitWithReloadActions :: Int -> ModuleName -> FunctionName -> (FilePath -> IO [FilePath])+ -> [IO (IO ())] -> IO ()+runQuitWithReloadActions port modu func extras actions = do sig <- newEmptyMVar- _ <- forkIO $ run port modu func extras (Just sig)+ _ <- forkIO $ runWithReloadActions port modu func extras (Just sig) actions go sig where go sig = do@@ -57,13 +63,19 @@ go sig _ -> go sig -run :: Int -> ModuleName -> FunctionName -> (FilePath -> IO [FilePath]) -> Maybe (MVar ())- -> IO ()-run port modu func extras msig = do+runWithReloadActions :: Int -> ModuleName -> FunctionName -> (FilePath -> IO [FilePath]) + -> Maybe (MVar ()) -> [IO (IO ())] -> IO ()+runWithReloadActions port modu func extras msig initActions = do+ actions <- mapM id initActions ah <- initAppHolder- _ <- forkIO $ fillApp modu func extras ah msig+ _ <- forkIO $ fillApp modu func extras ah msig actions Warp.run port $ toApp ah+ return () +run :: Int -> ModuleName -> FunctionName -> (FilePath -> IO [FilePath]) -> Maybe (MVar ())+ -> IO ()+run port modu func extras msig = runWithReloadActions port modu func extras msig []+ {- startApp :: Queue -> Handler -> IO () startApp queue withApp = do@@ -93,8 +105,8 @@ constSE = const fillApp :: String -> String- -> (FilePath -> IO [FilePath]) -> AppHolder -> Maybe (MVar ()) -> IO ()-fillApp modu func dirs ah msig =+ -> (FilePath -> IO [FilePath]) -> AppHolder -> Maybe (MVar ()) -> [IO ()] -> IO ()+fillApp modu func dirs ah msig actions = go Nothing [] where go prevError prevFiles = do@@ -107,7 +119,7 @@ return $ times /= map snd prevFiles (newError, newFiles) <- if toReload- then reload modu func dirs prevError ah+ then reload modu func dirs prevError ah actions else return (prevError, prevFiles) threadDelay 1000000 go newError newFiles@@ -116,8 +128,9 @@ -> (FilePath -> IO [FilePath]) -> Maybe SomeException -> AppHolder+ -> [IO ()] -> IO (Maybe SomeException, [(FilePath, ClockTime)])-reload modu func extras prevError ah = do+reload modu func extras prevError ah actions = do case prevError of Nothing -> putStrLn "Attempting to interpret your app..." _ -> return ()@@ -136,6 +149,7 @@ E.handle onInitErr $ do swapApp (\f -> app $ f . debug) ah times <- getTimes files+ sequence_ actions return (Nothing, zip files times) where onInitErr e = do
wai-handler-devel.cabal view
@@ -1,5 +1,5 @@ Name: wai-handler-devel-Version: 0.4.3.1+Version: 0.4.4 Synopsis: WAI server that automatically reloads code after modification. Description: 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. .@@ -26,13 +26,13 @@ , wai-extra >= 0.4 && < 0.5 , http-types >= 0.6 && < 0.7 , warp >= 0.4 && < 0.5- , directory >= 1.0 && < 1.2- , network >= 2.2 && < 2.4- , bytestring >= 0.9 && < 0.10+ , directory >= 1.0.1 && < 1.2+ , network >= 2.2.1.5 && < 2.4+ , bytestring >= 0.9.1.4 && < 0.10 , hint >= 0.3.2.3 && < 0.4 , text >= 0.7 && < 0.12 , old-time >= 1.0 && < 1.1- , enumerator >= 0.4.6 && < 0.5+ , enumerator >= 0.4.8 && < 0.5 , transformers >= 0.2.2 && < 0.3 , attoparsec-text >= 0.8.2 && < 0.9 Exposed-modules: Network.Wai.Handler.DevelServer@@ -40,11 +40,11 @@ ghc-options: -Wall Executable wai-handler-devel- Build-Depends: cmdargs >= 0.4 && < 0.9+ Build-Depends: cmdargs >= 0.4 ghc-options: -Wall -O2 -threaded main-is: wai-handler-devel.hs Executable wai-handler-devel-unwatched- Build-Depends: cmdargs >= 0.4 && < 0.9+ Build-Depends: cmdargs >= 0.4 ghc-options: -Wall -O2 -threaded main-is: wai-handler-devel-unwatched.hs