diff --git a/src/Mtlstats.hs b/src/Mtlstats.hs index ac33699..f9baa66 100644 --- a/src/Mtlstats.hs +++ b/src/Mtlstats.hs @@ -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 () diff --git a/src/Mtlstats/Types.hs b/src/Mtlstats/Types.hs index 988c0a0..23307f4 100644 --- a/src/Mtlstats/Types.hs +++ b/src/Mtlstats/Types.hs @@ -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