Showing 32 of 32 total issues

Use lambda-case
Open

    A.withText "HalmaDirection" $ \text ->
      case text of
        "N"  -> pure North
        "NE" -> pure Northeast
        "SE" -> pure Southeast
Severity: Minor
Found in halma/src/Game/Halma/Board.hs by hlint

Found

\ text ->
  case text of
      "N" -> pure North
      "NE" -> pure Northeast
      "SE" -> pure Southeast
      "S" -> pure South
      "SW" -> pure Southwest
      "NW" -> pure Northwest
      _ -> fail
             "expected a Halma direction (one of N, NE, SE, S, SW, NW)"

Perhaps

\case
    "N" -> pure North
    "NE" -> pure Northeast
    "SE" -> pure Southeast
    "S" -> pure South
    "SW" -> pure Southwest
    "NW" -> pure Northwest
    _ -> fail
           "expected a Halma direction (one of N, NE, SE, S, SW, NW)"

Use section
Open

      in sendI18nMsg (flip hlAIMove moveByAi)

Found

(flip hlAIMove moveByAi)

Perhaps

(`hlAIMove` moveByAi)

Reduce duplication
Open

            let
              match' = match { matchCurrentGame = Just game' }

Found

let match' = match{matchCurrentGame = Just game'}
modify $ \ chat -> chat{hcMatchState = MatchRunning match'}
sendMatchState

Perhaps

Combine with halma-telegram-bot/src/Game/Halma/TelegramBot/Controller.hs:228:7

Use newtype instead of data
Open

data TargetModifier
  = TargetModifier
  { _unTargetModifier :: Int
  } deriving (Show, Eq, Ord)

Found

data TargetModifier
  = TargetModifier {_unTargetModifier :: Int}
  deriving (Show, Eq, Ord)

Perhaps

newtype TargetModifier
  = TargetModifier {_unTargetModifier :: Int}
  deriving (Show, Eq, Ord)

Applying this change:

  • decreases laziness

Use lambda-case
Open

    A.withText "MoveRestriction" $ \text ->
      case text of
        "allowed"     -> pure Allowed
        "temporarily" -> pure Temporarily
        "forbidden"   -> pure Forbidden
Severity: Minor
Found in halma/src/Game/Halma/Rules.hs by hlint

Found

\ text ->
  case text of
      "allowed" -> pure Allowed
      "temporarily" -> pure Temporarily
      "forbidden" -> pure Forbidden
      _ -> fail "expected 'allowed', 'temporarily' or 'forbidden'"

Perhaps

\case
    "allowed" -> pure Allowed
    "temporarily" -> pure Temporarily
    "forbidden" -> pure Forbidden
    _ -> fail "expected 'allowed', 'temporarily' or 'forbidden'"

Applying this change:

  • may require {-# LANGUAGE LambdaCase #-} adding to the top of the file

Use String
Open

pieceNumberToChars :: PieceNumber -> [Char]

Found

PieceNumber -> [Char]

Perhaps

PieceNumber -> String

Use section
Open

    sendI18nMsg (flip hlUnrecognizedCmdMsg call)

Found

(flip hlUnrecognizedCmdMsg call)

Perhaps

(`hlUnrecognizedCmdMsg` call)

Use section
Open

          ] ++ map (flip button ButtonInactive) ["Four Players", "Five Players", "Six Players"]
Severity: Minor
Found in halma-gui/src/Main.hs by hlint

Found

(flip button ButtonInactive)

Perhaps

(`button` ButtonInactive)

Redundant $
Open

          , map (\(numStr, players') -> button (numStr ++ " Players") (configButtonAction (playersOnLargeGrid players'))) $
            [ ("Two", TwoPlayers () ())
            , ("Three", ThreePlayers () () ())
            , ("Four", FourPlayers () () () ())
            , ("Five", FivePlayers () () () () ())
Severity: Minor
Found in halma-gui/src/Main.hs by hlint

Found

map
  (\ (numStr, players') ->
     button (numStr ++ " Players")
       (configButtonAction (playersOnLargeGrid players')))
  $
  [("Two", TwoPlayers () ()), ("Three", ThreePlayers () () ()),
   ("Four", FourPlayers () () () ()),
   ("Five", FivePlayers () () () () ()),
   ("Six", SixPlayers () () () () () ())]

Perhaps

map
  (\ (numStr, players') ->
     button (numStr ++ " Players")
       (configButtonAction (playersOnLargeGrid players')))
  [("Two", TwoPlayers () ()), ("Three", ThreePlayers () () ()),
   ("Four", FourPlayers () () () ()),
   ("Five", FivePlayers () () () () ()),
   ("Six", SixPlayers () () () () () ())]

Use section
Open

          sendI18nMsg (flip hlNotYourTurn notYourTurnInfo)

Found

(flip hlNotYourTurn notYourTurnInfo)

Perhaps

(`hlNotYourTurn` notYourTurnInfo)

Use guards
Open

    go (Just (currentMax, bestMove)) (option@(rating, move):options) =
      if isWin rating then
        option
      else if newRating <= currentMax then
        go (Just (currentMax, bestMove)) options

Found

go (Just (currentMax, bestMove)) (option@(rating, move) : options)
  = if isWin rating then option else
      if newRating <= currentMax then
        go (Just (currentMax, bestMove)) options else
        if boundReached newRating then (newRating, move) else
          go (Just (newRating, move)) options
  where newRating = fst $ nextLevel option (Just currentMax)

Perhaps

go (Just (currentMax, bestMove)) (option@(rating, move) : options)
  | isWin rating = option
  | newRating <= currentMax =
    go (Just (currentMax, bestMove)) options
  | boundReached newRating = (newRating, move)
  | otherwise = go (Just (newRating, move)) options
  where newRating = fst $ nextLevel option (Just currentMax)

Use section
Open

            sendI18nMsg (flip hlCantUndo Nothing)

Found

(flip hlCantUndo Nothing)

Perhaps

(`hlCantUndo` Nothing)
Severity
Category
Status
Source
Language