add Database to ProgState
This commit is contained in:
parent
95d125973b
commit
72f9d51977
|
@ -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 ()
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user