initialize random number generator
This commit is contained in:
@@ -36,8 +36,10 @@ import Brick
|
||||
, style
|
||||
)
|
||||
|
||||
import Password.App.Types
|
||||
|
||||
-- | The main application
|
||||
passmanApp :: App () () ()
|
||||
passmanApp :: App AppState () ()
|
||||
passmanApp = App
|
||||
{ appDraw = drawFunc
|
||||
, appChooseCursor = neverShowCursor
|
||||
@@ -46,10 +48,10 @@ passmanApp = App
|
||||
, appAttrMap = const $ attrMap (style 0) []
|
||||
}
|
||||
|
||||
drawFunc :: () -> [Widget ()]
|
||||
drawFunc :: AppState -> [Widget ()]
|
||||
drawFunc = const [emptyWidget]
|
||||
|
||||
eventHandler :: BrickEvent () () -> EventM () () ()
|
||||
eventHandler :: BrickEvent () () -> EventM () AppState ()
|
||||
eventHandler = const halt
|
||||
|
||||
--jl
|
||||
|
||||
43
src/Password/App/Types.hs
Normal file
43
src/Password/App/Types.hs
Normal file
@@ -0,0 +1,43 @@
|
||||
{-|
|
||||
|
||||
Module: Password.App.Types
|
||||
Description: data types used by the application
|
||||
Copyright: (C) Jonathan Lamothe
|
||||
License: LGPLv3 (or later)
|
||||
Maintainer: jonathan@jlamothe.net
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this program. If not, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
-}
|
||||
|
||||
module Password.App.Types (
|
||||
AppState (..),
|
||||
mkInitialState
|
||||
) where
|
||||
|
||||
import Control.Monad.IO.Class (MonadIO)
|
||||
import System.Random (StdGen, initStdGen)
|
||||
|
||||
-- | The application state
|
||||
newtype AppState = AppState
|
||||
{ _randGen :: StdGen
|
||||
-- ^ The random number generator
|
||||
} deriving (Eq, Show)
|
||||
|
||||
-- | Builds an initial state
|
||||
mkInitialState :: MonadIO m => m AppState
|
||||
mkInitialState = AppState <$> initStdGen
|
||||
|
||||
--jl
|
||||
Reference in New Issue
Block a user