hlint suggestions

This commit is contained in:
Jonathan Lamothe 2020-03-05 05:15:58 -05:00
parent 53c49492cb
commit 9ee33cbd03
6 changed files with 21 additions and 22 deletions

View File

@ -124,12 +124,13 @@ awardGoal n ps = ps
(\m -> let
stats = M.findWithDefault newPlayerStats n m
in M.insert n (stats & psGoals %~ succ) m)
& database.dbPlayers %~ map
(\(i, p) -> if i == n
& database.dbPlayers %~ zipWith
(\i p -> if i == n
then p
& pYtd.psGoals %~ succ
& pLifetime.psGoals %~ succ
else p) . zip [0..]
else p)
[0..]
-- | Awards an assist to a player
awardAssist
@ -142,12 +143,13 @@ awardAssist n ps = ps
(\m -> let
stats = M.findWithDefault newPlayerStats n m
in M.insert n (stats & psAssists %~ succ) m)
& database.dbPlayers %~ map
(\(i, p) -> if i == n
& database.dbPlayers %~ zipWith
(\i p -> if i == n
then p
& pYtd.psAssists %~ succ
& pLifetime.psAssists %~ succ
else p) . zip [0..]
else p)
[0..]
-- | Resets the entered data for the current goal
resetGoalData :: ProgState -> ProgState

View File

@ -170,10 +170,11 @@ gameGoalieMenu s = let
goalie <- nth n $ s^.database.dbGoalies
Just (n, goalie))
gids
in Menu title () $ map
(\(ch, (gid, goalie)) -> MenuItem ch (goalieSummary goalie) $
modify $ GI.setGameGoalie gid) $
zip ['1'..] goalies
in Menu title () $ zipWith
(\ch (gid, goalie) -> MenuItem ch (goalieSummary goalie) $
modify $ GI.setGameGoalie gid)
['1'..]
goalies
-- | The edit menu
editMenu :: Menu ()

View File

@ -164,9 +164,7 @@ numPromptWithFallback pStr fallback act = Prompt
, promptProcessChar = \ch str -> if isDigit ch
then str ++ [ch]
else str
, promptAction = \inStr -> case readMaybe inStr of
Nothing -> fallback
Just n -> act n
, promptAction = maybe fallback act . readMaybe
, promptSpecialKey = const $ return ()
}

View File

@ -241,8 +241,7 @@ filteredPlayerReport width label criteria showTotals lineNumbers ps = let
else repeat ""
table = overlayLast olayText
$ map (\(ln, line) -> overlay ln $ centre width line)
$ zip lnOverlay
$ zipWith (\ln line -> overlay ln $ centre width line) lnOverlay
$ complexTable ([right, left] ++ repeat right)
$ tHeader : body ++ if showTotals
then [separator, totals]
@ -301,8 +300,7 @@ goalieReport width showTotals lineNumbers goalieData = let
then "" : [right 2 $ show x | x <- [(1 :: Int)..]]
else repeat ""
in map (\(ln, line) -> overlay ln $ centre width line)
$ zip lnOverlay
in zipWith (\ln line -> overlay ln $ centre width line) lnOverlay
$ overlayLast olayText
$ complexTable ([right, left] ++ repeat right)
$ header : body ++ if showTotals

View File

@ -208,9 +208,8 @@ import Data.Aeson
, (.=)
)
import Data.Char (toUpper)
import Data.List (isInfixOf)
import Data.List (find, isInfixOf)
import qualified Data.Map as M
import Data.Maybe (listToMaybe)
import Lens.Micro (Lens', lens, (&), (^.), (.~))
import Lens.Micro.TH (makeLenses)
import qualified UI.NCurses as C
@ -1019,7 +1018,7 @@ playerSearchExact
-> Maybe (Int, Player)
-- ^ The player's index and value
playerSearchExact sStr =
listToMaybe . filter match . zip [0..]
find match . zip [0..]
where match (_, p) = p^.pName == sStr
-- | Modifies a player with a given name

View File

@ -52,8 +52,9 @@ modifyNth
-> [a]
-- ^ The list
-> [a]
modifyNth n f = map (\(i, x) -> if i == n then f x else x)
. zip [0..]
modifyNth n f = zipWith
(\i x -> if i == n then f x else x)
[0..]
-- | Modify a value indexed by a given key in a map using a default
-- initial value if not present