initialize random number generator
This commit is contained in:
parent
11870423ed
commit
76d2600fcf
|
@ -26,8 +26,9 @@ import Brick (defaultMain)
|
|||
import Control.Monad (void)
|
||||
|
||||
import Password.App
|
||||
import Password.App.Types
|
||||
|
||||
main :: IO ()
|
||||
main = void $ defaultMain passmanApp ()
|
||||
main = void $ mkInitialState >>= defaultMain passmanApp
|
||||
|
||||
--jl
|
||||
|
|
|
@ -4,7 +4,7 @@ cabal-version: 2.2
|
|||
--
|
||||
-- see: https://github.com/sol/hpack
|
||||
--
|
||||
-- hash: 235d7c20ee589946f5e0cd199cca106191a300f9f24b023a6ef074c197c9861b
|
||||
-- hash: d742af1f90e36896cfb5979f267f1ef87b81fb7e603c8c72ccc0c8e7a382a408
|
||||
|
||||
name: passman
|
||||
version: 0.3.1.1
|
||||
|
@ -27,6 +27,7 @@ library
|
|||
exposed-modules:
|
||||
Password
|
||||
Password.App
|
||||
Password.App.Types
|
||||
other-modules:
|
||||
Paths_passman
|
||||
autogen-modules:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue
Block a user