diff options
| author | pb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157> | 2010-03-14 14:12:17 +0000 |
|---|---|---|
| committer | pb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157> | 2010-03-14 14:12:17 +0000 |
| commit | a7865fd10582a9b710e96d2052a9ce90ced8020c (patch) | |
| tree | 00f7ce23717a4aca2352adb6346f5daa18411ec8 /State.hs | |
| parent | 3b090644f148acf856e925be59e6915ea524a3f8 (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.hs | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -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') + |
