summaryrefslogtreecommitdiff
path: root/Main.hs
diff options
context:
space:
mode:
authorJulien Dessaux2010-02-04 20:27:22 +0100
committerJulien Dessaux2010-02-04 20:27:22 +0100
commit57f559f3a119b400e4f6288d3b5753185b8f19a7 (patch)
tree76bcd9a7e3980b8a79f64d46e5ae75a362dcd486 /Main.hs
parentRebooting now works great, thanks to the communication channel preservation. (diff)
downloadhsbot-57f559f3a119b400e4f6288d3b5753185b8f19a7.tar.gz
hsbot-57f559f3a119b400e4f6288d3b5753185b8f19a7.tar.bz2
hsbot-57f559f3a119b400e4f6288d3b5753185b8f19a7.zip
Rewrote the whole architecture.
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs43
1 files changed, 2 insertions, 41 deletions
diff --git a/Main.hs b/Main.hs
index 617468a..982c699 100644
--- a/Main.hs
+++ b/Main.hs
@@ -1,48 +1,9 @@
module Main where
-import System.Exit
-import System.Plugins
-
-ghcargs :: [String]
-ghcargs = ["-XPatternGuards"]
+import Hsbot
-- | Dynamic launching function
main :: IO ()
main = do
- putStrLn "hsbot starting..."
- m <- makeAll "Hsbot.hs" ghcargs
- (modul', imain) <- case m of
- MakeSuccess _ _ -> do
- ldstat <- load_ "Hsbot/Main.o" [".","Hsbot","Hsbot/Plugins"] "imain"
- case ldstat of
- LoadSuccess v m' -> return (v,m')
- LoadFailure e -> do
- putStrLn "Couldn't load Hsbot.Main.imain:"
- mapM_ putStrLn e
- exitWith $ ExitFailure 127
- MakeFailure e -> do
- putStrLn "FATAL: Couldn't compile Hsbot.hs:"
- mapM_ putStrLn e
- exitWith $ ExitFailure 127
- putStrLn "Compiled & Loaded Hsbot.Main.imain..."
- imain modul' reboot
-
--- | Dynamic rebooting function
-reboot :: Module -> a -> b -> IO ()
-reboot modul' state chan = do
- mkstat <- makeAll "Hsbot.hs" ghcargs
- case mkstat of
- MakeSuccess _ _ -> do
- unloadAll modul'
- ldstat <- load_ "Hsbot/Main.o" [".","Hsbot","Hsbot/Plugins"] "imain'"
- case ldstat of
- LoadSuccess modul'' imain' -> do
- putStrLn "REBOOT: Successful recompilation & reloading, rebooting..."
- imain' modul'' reboot state chan
- LoadFailure e -> fatality e
- MakeFailure e -> fatality e
- where
- fatality errs = do
- putStrLn $ "REBOOT: FATAL: Couldn't reboot thread, err:"
- mapM_ putStrLn errs
+ imain