added password database to AppState

This commit is contained in:
Jonathan Lamothe 2024-09-10 19:03:19 -04:00
parent d049c40b7a
commit a872fcfd6c

View File

@ -33,6 +33,7 @@ module Password.App.Types (
-- * Lenses -- * Lenses
-- ** AppState -- ** AppState
randGen, randGen,
database,
appMode, appMode,
-- ** AppMode -- ** AppMode
initState, initState,
@ -51,11 +52,16 @@ import Lens.Micro (_1, _2)
import Lens.Micro.TH (makeLenses) import Lens.Micro.TH (makeLenses)
import System.Random (StdGen, initStdGen) import System.Random (StdGen, initStdGen)
import Password
-- | The application state -- | The application state
data AppState = AppState data AppState = AppState
{ _randGen :: StdGen { _randGen :: StdGen
-- ^ The random number generator -- ^ The random number generator
, _database :: PWDatabase
-- ^ The password database
, _appMode :: AppMode , _appMode :: AppMode
-- ^ The current operating mode
} }
-- | The applicaiton's mode -- | The applicaiton's mode
@ -88,6 +94,7 @@ concat <$> mapM makeLenses
mkInitialState :: MonadIO m => m AppState mkInitialState :: MonadIO m => m AppState
mkInitialState = AppState mkInitialState = AppState
<$> initStdGen <$> initStdGen
<*> return newPWDatabase
<*> return (InitMode newInitState) <*> return (InitMode newInitState)
-- | New `InitState` value -- | New `InitState` value