usersStateComponent :: FilePath -> IO (StateComponent AcidState Users.Users)
usersStateComponent stateDir = do
  st <- openLocalStateFrom (stateDir </> "db" </> "Users") initialUsers
  return StateComponent {
      stateDesc    = "List of users"
    , stateHandle  = st
    , getState     = query st GetUserDb
    , putState     = update st . ReplaceUserDb
    , backupState  = \backuptype users ->
        [csvToBackup ["users.csv"] (usersToCSV backuptype users)]
    , restoreState = userBackup
    , resetState   = usersStateComponent
    }
usersStateComponent :: FilePath -> IO (StateComponent AcidState Users.Users)
usersStateComponent stateDir = do
  st <- openLocalStateFrom (stateDir </> "db" </> "Users") initialUsers
  return StateComponent {
      stateDesc    = "List of users"
    , stateHandle  = st
    , getState     = query st GetUserDb
    , putState     = update st . ReplaceUserDb
    , backupState  = \backuptype users ->
        [csvToBackup ["users.csv"] (usersToCSV backuptype users)]
    , restoreState = userBackup
    , resetState   = usersStateComponent
    }
usersStateComponent stateDir = do
  st <- openLocalStateFrom (stateDir </> "db" </> "Users") initialUsers
  return StateComponent {
      stateDesc    = "List of users"
    , stateHandle  = st
    , getState     = query st GetUserDb
    , putState     = update st . ReplaceUserDb
    , backupState  = \backuptype users ->
        [csvToBackup ["users.csv"] (usersToCSV backuptype users)]
    , restoreState = userBackup
    , resetState   = usersStateComponent
    }