add Database to ProgState

This commit is contained in:
Jonathan Lamothe 2019-08-19 23:58:18 -04:00
parent 95d125973b
commit 72f9d51977
2 changed files with 14 additions and 4 deletions

View File

@ -28,9 +28,7 @@ import Mtlstats.Types
-- | Initializes the progran
initState :: C.Curses ProgState
initState = do
C.setEcho False
return ProgState
initState = return newProgState
-- | Main program loop
mainLoop :: StateT ProgState C.Curses ()

View File

@ -30,6 +30,8 @@ module Mtlstats.Types (
Goalie (..),
GoalieStats (..),
-- * Lenses
-- ** ProgState Lenses
database,
-- ** Database Lenses
dbPlayers,
dbGoalies,
@ -58,6 +60,7 @@ module Mtlstats.Types (
gsLosses,
gsTies,
-- * Constructors
newProgState,
newDatabase,
newPlayer,
newPlayerStats,
@ -83,7 +86,9 @@ import Lens.Micro ((^.))
import Lens.Micro.TH (makeLenses)
-- | Represents the program state
data ProgState = ProgState
newtype ProgState = ProgState
{ _database :: Database
} deriving (Eq, Show)
-- | Represents the database
data Database = Database
@ -255,12 +260,19 @@ instance ToJSON GoalieStats where
"losses" .= l <>
"ties" .= t
makeLenses ''ProgState
makeLenses ''Database
makeLenses ''Player
makeLenses ''PlayerStats
makeLenses ''Goalie
makeLenses ''GoalieStats
-- | Constructor for a new 'ProgState'
newProgState :: ProgState
newProgState = ProgState
{ _database = newDatabase
}
-- | Constructor for a 'Database'
newDatabase :: Database
newDatabase = Database