use ?~ operator (where applicable)
This commit is contained in:
@@ -29,7 +29,7 @@ module Mtlstats.Actions
|
|||||||
, setAwayGame
|
, setAwayGame
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Lens.Micro (over, (&), (.~), (%~))
|
import Lens.Micro (over, (&), (.~), (?~), (%~))
|
||||||
|
|
||||||
import Mtlstats.Types
|
import Mtlstats.Types
|
||||||
|
|
||||||
@@ -52,11 +52,11 @@ startNewGame
|
|||||||
-- | Sets the game type to 'HomeGame'
|
-- | Sets the game type to 'HomeGame'
|
||||||
setHomeGame :: ProgState -> ProgState
|
setHomeGame :: ProgState -> ProgState
|
||||||
setHomeGame = over progMode $ \case
|
setHomeGame = over progMode $ \case
|
||||||
NewGame gs -> NewGame (gs & gameType .~ Just HomeGame)
|
NewGame gs -> NewGame (gs & gameType ?~ HomeGame)
|
||||||
_ -> NewGame $ newGameState & gameType .~ Just HomeGame
|
_ -> NewGame $ newGameState & gameType ?~ HomeGame
|
||||||
|
|
||||||
-- | Sets the game type to 'AwayGame'
|
-- | Sets the game type to 'AwayGame'
|
||||||
setAwayGame :: ProgState -> ProgState
|
setAwayGame :: ProgState -> ProgState
|
||||||
setAwayGame = over progMode $ \case
|
setAwayGame = over progMode $ \case
|
||||||
NewGame gs -> NewGame (gs & gameType .~ Just AwayGame)
|
NewGame gs -> NewGame (gs & gameType ?~ AwayGame)
|
||||||
_ -> NewGame $ newGameState & gameType .~ Just AwayGame
|
_ -> NewGame $ newGameState & gameType ?~ AwayGame
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
module ActionsSpec (spec) where
|
module ActionsSpec (spec) where
|
||||||
|
|
||||||
import Control.Monad (replicateM)
|
import Control.Monad (replicateM)
|
||||||
import Lens.Micro ((&), (.~), (^.))
|
import Lens.Micro ((&), (.~), (?~), (^.))
|
||||||
import System.Random (randomRIO)
|
import System.Random (randomRIO)
|
||||||
import Test.Hspec (Spec, context, describe, it, shouldBe, shouldNotBe)
|
import Test.Hspec (Spec, context, describe, it, shouldBe, shouldNotBe)
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ resetYtdSpec = describe "resetYtd" $
|
|||||||
|
|
||||||
setHomeGameSpec :: Spec
|
setHomeGameSpec :: Spec
|
||||||
setHomeGameSpec = describe "setHomeGame" $ do
|
setHomeGameSpec = describe "setHomeGame" $ do
|
||||||
let m = NewGame $ newGameState & gameType .~ Just HomeGame
|
let m = NewGame $ newGameState & gameType ?~ HomeGame
|
||||||
|
|
||||||
context "unexpected mode" $
|
context "unexpected mode" $
|
||||||
it "should set the game type" $ let
|
it "should set the game type" $ let
|
||||||
@@ -124,7 +124,7 @@ setHomeGameSpec = describe "setHomeGame" $ do
|
|||||||
|
|
||||||
setAwayGameSpec :: Spec
|
setAwayGameSpec :: Spec
|
||||||
setAwayGameSpec = describe "setAwayGame" $ do
|
setAwayGameSpec = describe "setAwayGame" $ do
|
||||||
let m = NewGame $ newGameState & gameType .~ Just AwayGame
|
let m = NewGame $ newGameState & gameType ?~ AwayGame
|
||||||
|
|
||||||
context "unexpected mode" $
|
context "unexpected mode" $
|
||||||
it "should set the game type" $ let
|
it "should set the game type" $ let
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ module TypesSpec (spec) where
|
|||||||
|
|
||||||
import Data.Aeson (decode, encode)
|
import Data.Aeson (decode, encode)
|
||||||
import Data.ByteString.Lazy (ByteString)
|
import Data.ByteString.Lazy (ByteString)
|
||||||
import Lens.Micro ((&), (.~))
|
import Lens.Micro ((&), (.~), (?~))
|
||||||
import Test.Hspec (Spec, context, describe, it, shouldBe)
|
import Test.Hspec (Spec, context, describe, it, shouldBe)
|
||||||
import Text.RawString.QQ (r)
|
import Text.RawString.QQ (r)
|
||||||
import Mtlstats.Types
|
import Mtlstats.Types
|
||||||
@@ -63,9 +63,9 @@ teamPointsSpec :: Spec
|
|||||||
teamPointsSpec = describe "teamPoints" $ do
|
teamPointsSpec = describe "teamPoints" $ do
|
||||||
let
|
let
|
||||||
m t = NewGame $ newGameState
|
m t = NewGame $ newGameState
|
||||||
& gameType .~ Just t
|
& gameType ?~ t
|
||||||
& homeScore .~ Just 1
|
& homeScore ?~ 1
|
||||||
& awayScore .~ Just 2
|
& awayScore ?~ 2
|
||||||
s t = newProgState
|
s t = newProgState
|
||||||
& progMode .~ m t
|
& progMode .~ m t
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user