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 -- | Initializes the progran
initState :: C.Curses ProgState initState :: C.Curses ProgState
initState = do initState = return newProgState
C.setEcho False
return ProgState
-- | Main program loop -- | Main program loop
mainLoop :: StateT ProgState C.Curses () mainLoop :: StateT ProgState C.Curses ()

View File

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