Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Put code in code block so it gets formatted properly by haddock.

  • Loading branch information...
commit 5a188d2bf3ec2b12cf6b09fb4a2a102fb50272d6 1 parent 0c64a14
Joe Edmonds authored committed
Showing with 40 additions and 40 deletions.
  1. +39 −39 Config/Dyre.hs
  2. +1 −1  dyre.cabal
View
78 Config/Dyre.hs
@@ -20,50 +20,50 @@ is used or not.
A full example of using most of Dyre's major features is as follows:
- -- DyreExample.hs --
- module DyreExample where
-
- import qualified Config.Dyre as Dyre
- import Config.Dyre.Relaunch
-
- import System.IO
-
- data Config = Config { message :: String, errorMsg :: Maybe String }
- data State = State { bufferLines :: [String] } deriving (Read, Show)
-
- defaultConfig :: Config
- defaultConfig = Config "Dyre Example v0.1" Nothing
-
- showError :: Config -> String -> Config
- showError cfg msg = cfg { errorMsg = Just msg }
-
- realMain Config{message = message, errorMsg = errorMsg } = do
- (State buffer) <- restoreTextState $ State []
- case errorMsg of
- Nothing -> return ()
- Just em -> putStrLn $ "Error: " ++ em
- putStrLn message
- mapM putStrLn . reverse $ buffer
- putStr "> " >> hFlush stdout
- input <- getLine
- case input of
- "exit" -> return ()
- "quit" -> return ()
- other -> relaunchWithTextState (State $ other:buffer) Nothing
-
- dyreExample = Dyre.wrapMain $ Dyre.defaultParams
- { Dyre.projectName = "dyreExample"
- , Dyre.realMain = realMain
- , Dyre.showError = showError
- }
+> -- DyreExample.hs --
+> module DyreExample where
+>
+> import qualified Config.Dyre as Dyre
+> import Config.Dyre.Relaunch
+>
+> import System.IO
+>
+> data Config = Config { message :: String, errorMsg :: Maybe String }
+> data State = State { bufferLines :: [String] } deriving (Read, Show)
+>
+> defaultConfig :: Config
+> defaultConfig = Config "Dyre Example v0.1" Nothing
+>
+> showError :: Config -> String -> Config
+> showError cfg msg = cfg { errorMsg = Just msg }
+>
+> realMain Config{message = message, errorMsg = errorMsg } = do
+> (State buffer) <- restoreTextState $ State []
+> case errorMsg of
+> Nothing -> return ()
+> Just em -> putStrLn $ "Error: " ++ em
+> putStrLn message
+> mapM putStrLn . reverse $ buffer
+> putStr "> " >> hFlush stdout
+> input <- getLine
+> case input of
+> "exit" -> return ()
+> "quit" -> return ()
+> other -> relaunchWithTextState (State $ other:buffer) Nothing
+>
+> dyreExample = Dyre.wrapMain $ Dyre.defaultParams
+> { Dyre.projectName = "dyreExample"
+> , Dyre.realMain = realMain
+> , Dyre.showError = showError
+> }
Notice that all of the program logic is contained in the 'DyreExample'
module. The main module of the program is absolutely trivial, being
essentially just the default configuration for the program:
- -- Main.hs --
- import DyreExample
- main = dyreExample defaultConfig
+> -- Main.hs --
+> import DyreExample
+> main = dyreExample defaultConfig
When reading the above program, notice that the majority of the
code is simply *program logic*. Dyre is designed to intelligently
View
2  dyre.cabal
@@ -1,5 +1,5 @@
name: dyre
-version: 0.8.1
+version: 0.8.2
category: Development, Configuration
synopsis: Dynamic reconfiguration in Haskell
Please sign in to comment.
Something went wrong with that request. Please try again.