removed unnecessary lenses
This commit is contained in:
parent
d7dd682532
commit
2854c54474
|
@ -75,7 +75,7 @@ newSeasonMenu = Menu "*** SEASON TYPE ***" ()
|
|||
gameTypeMenu :: Menu ()
|
||||
gameTypeMenu = Menu "*** GAME TYPE ***" ()
|
||||
[ MenuItem '1' "Home Game" $
|
||||
modify $ progMode . gameTypeL ?~ HomeGame
|
||||
modify $ progMode . gameStateL . gameType ?~ HomeGame
|
||||
, MenuItem '2' "Away Game" $
|
||||
modify $ progMode . gameTypeL ?~ AwayGame
|
||||
modify $ progMode . gameStateL . gameType ?~ AwayGame
|
||||
]
|
||||
|
|
|
@ -95,15 +95,15 @@ numPrompt pStr act = Prompt
|
|||
|
||||
otherTeamPrompt :: Prompt
|
||||
otherTeamPrompt = strPrompt "Other team: " $
|
||||
modify . (progMode . otherTeamL .~)
|
||||
modify . (progMode . gameStateL . otherTeam .~)
|
||||
|
||||
homeScorePrompt :: Prompt
|
||||
homeScorePrompt = numPrompt "Home score: " $
|
||||
modify . (progMode . homeScoreL ?~)
|
||||
modify . (progMode . gameStateL . homeScore ?~)
|
||||
|
||||
awayScorePrompt :: Prompt
|
||||
awayScorePrompt = numPrompt "Away score: " $
|
||||
modify . (progMode . awayScoreL ?~)
|
||||
modify . (progMode . gameStateL . awayScore ?~)
|
||||
|
||||
drawSimplePrompt :: String -> ProgState -> C.Update ()
|
||||
drawSimplePrompt pStr s = C.drawString $ pStr ++ s ^. inputBuffer
|
||||
|
|
|
@ -42,10 +42,6 @@ module Mtlstats.Types (
|
|||
inputBuffer,
|
||||
-- ** ProgMode Lenses
|
||||
gameStateL,
|
||||
gameTypeL,
|
||||
otherTeamL,
|
||||
homeScoreL,
|
||||
awayScoreL,
|
||||
-- ** GameState Lenses
|
||||
gameType,
|
||||
otherTeam,
|
||||
|
@ -391,42 +387,6 @@ gameStateL = lens
|
|||
_ -> newGameState)
|
||||
(\_ gs -> NewGame gs)
|
||||
|
||||
gameTypeL :: Lens' ProgMode (Maybe GameType)
|
||||
gameTypeL = lens
|
||||
(\case
|
||||
NewGame gs -> gs ^. gameType
|
||||
_ -> Nothing)
|
||||
(\m gt -> case m of
|
||||
NewGame gs -> NewGame $ gs & gameType .~ gt
|
||||
_ -> NewGame $ newGameState & gameType .~ gt)
|
||||
|
||||
otherTeamL :: Lens' ProgMode String
|
||||
otherTeamL = lens
|
||||
(\case
|
||||
NewGame gs -> gs ^. otherTeam
|
||||
_ -> "")
|
||||
(\m ot -> case m of
|
||||
NewGame gs -> NewGame $ gs & otherTeam .~ ot
|
||||
_ -> NewGame $ newGameState & otherTeam .~ ot)
|
||||
|
||||
homeScoreL :: Lens' ProgMode (Maybe Int)
|
||||
homeScoreL = lens
|
||||
(\case
|
||||
NewGame gs -> gs ^. homeScore
|
||||
_ -> Nothing)
|
||||
(\m hs -> case m of
|
||||
NewGame gs -> NewGame $ gs & homeScore .~ hs
|
||||
_ -> NewGame $ newGameState & homeScore .~ hs)
|
||||
|
||||
awayScoreL :: Lens' ProgMode (Maybe Int)
|
||||
awayScoreL = lens
|
||||
(\case
|
||||
NewGame gs -> gs ^. awayScore
|
||||
_ -> Nothing)
|
||||
(\m as -> case m of
|
||||
NewGame gs -> NewGame $ gs & awayScore .~ as
|
||||
_ -> NewGame $ newGameState & awayScore .~ as)
|
||||
|
||||
-- | Constructor for a 'ProgState'
|
||||
newProgState :: ProgState
|
||||
newProgState = ProgState
|
||||
|
|
|
@ -42,10 +42,6 @@ spec = describe "Mtlstats.Types" $ do
|
|||
databaseSpec
|
||||
pPointsSpec
|
||||
gameStateLSpec
|
||||
gameTypeLSpec
|
||||
otherTeamLSpec
|
||||
homeScoreLSpec
|
||||
awayScoreLSpec
|
||||
teamScoreSpec
|
||||
otherScoreSpec
|
||||
Menu.spec
|
||||
|
@ -94,53 +90,6 @@ gameStateLSpec = describe "gameStateL" $ lensSpec gameStateL
|
|||
]
|
||||
where gs t = newGameState & gameType ?~ t
|
||||
|
||||
gameTypeLSpec :: Spec
|
||||
gameTypeLSpec = describe "gameTypeL" $ lensSpec gameTypeL
|
||||
[ ( MainMenu, Nothing )
|
||||
, ( m HomeGame, Just HomeGame )
|
||||
, ( m AwayGame, Just AwayGame )
|
||||
]
|
||||
[ ( MainMenu, Just HomeGame )
|
||||
, ( MainMenu, Just AwayGame )
|
||||
, ( m HomeGame, Just AwayGame )
|
||||
, ( m AwayGame, Just HomeGame )
|
||||
, ( m HomeGame, Nothing )
|
||||
]
|
||||
where m t = NewGame $ newGameState & gameType ?~ t
|
||||
|
||||
otherTeamLSpec :: Spec
|
||||
otherTeamLSpec = describe "otherTeamL" $ lensSpec otherTeamL
|
||||
[ ( MainMenu, "" )
|
||||
, ( m "foo", "foo" )
|
||||
]
|
||||
[ ( MainMenu, "foo" )
|
||||
, ( m "foo", "bar" )
|
||||
, ( m "foo", "" )
|
||||
]
|
||||
where m t = NewGame $ newGameState & otherTeam .~ t
|
||||
|
||||
homeScoreLSpec :: Spec
|
||||
homeScoreLSpec = describe "homeScoreL" $ lensSpec homeScoreL
|
||||
[ ( MainMenu, Nothing )
|
||||
, ( m 1, Just 1 )
|
||||
]
|
||||
[ ( MainMenu, Just 1 )
|
||||
, ( m 1, Just 2 )
|
||||
, ( m 1, Nothing )
|
||||
]
|
||||
where m s = NewGame $ newGameState & homeScore ?~ s
|
||||
|
||||
awayScoreLSpec :: Spec
|
||||
awayScoreLSpec = describe "awayScoreL" $ lensSpec awayScoreL
|
||||
[ ( MainMenu, Nothing )
|
||||
, ( m 1, Just 1 )
|
||||
]
|
||||
[ ( MainMenu, Just 1 )
|
||||
, ( m 1, Just 2 )
|
||||
, ( m 1, Nothing )
|
||||
]
|
||||
where m s = NewGame $ newGameState & awayScore ?~ s
|
||||
|
||||
teamScoreSpec :: Spec
|
||||
teamScoreSpec = describe "teamScore" $ do
|
||||
let
|
||||
|
|
Loading…
Reference in New Issue
Block a user