summaryrefslogtreecommitdiff
path: root/State.hs
diff options
context:
space:
mode:
authorpb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157>2010-03-14 14:12:17 +0000
committerpb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157>2010-03-14 14:12:17 +0000
commita7865fd10582a9b710e96d2052a9ce90ced8020c (patch)
tree00f7ce23717a4aca2352adb6346f5daa18411ec8 /State.hs
parent3b090644f148acf856e925be59e6915ea524a3f8 (diff)
added environment
git-svn-id: https://ssl.buetow.org/repos/hsbot/trunk@26 9f8f72e9-4bf4-416e-b76e-7d4203597157
Diffstat (limited to 'State.hs')
-rw-r--r--State.hs15
1 files changed, 14 insertions, 1 deletions
diff --git a/State.hs b/State.hs
index 27fd11f..c31d410 100644
--- a/State.hs
+++ b/State.hs
@@ -5,7 +5,7 @@ import List
import User
data State = State {
- channel :: String,
+ currentChannel :: String,
line :: String,
users :: [User]
} deriving (Show, Read)
@@ -16,3 +16,16 @@ stateNumUsers state = length $ users state
stateSortedUsers :: State -> [User]
stateSortedUsers state = sort $ users state
+stateLoad :: String -> IO State
+stateLoad databaseFile = do
+ file <- readFile databaseFile
+ return ( read file :: State )
+
+stateSave :: String -> State -> IO ()
+stateSave databaseFile = writeFile databaseFile . show
+
+stateSaveIO :: String -> IO State -> IO ()
+stateSaveIO databaseFile state = do
+ state' <- state
+ writeFile databaseFile (show state')
+