From 3a58f9206674abd3c57197bdc05655fa5ba3acc8 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Tue, 4 Oct 2022 07:56:37 -0400 Subject: variable renames --- repgoal.hs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/repgoal.hs b/repgoal.hs index 7b9434e..d8624e5 100755 --- a/repgoal.hs +++ b/repgoal.hs @@ -68,20 +68,21 @@ data Performance = Achieved { achievedWeight :: Rational } -data ExerciseTarget = ExerciseTarget { - exerciseName :: Text, +data LiftTarget = LiftTarget { + liftName :: Text, targetWeight :: Rational, stats :: [Performance] } -exercises :: [ExerciseTarget] -exercises = [ - ExerciseTarget "Deadlift" 345 $ [Achieved 5 360, Achieved 9 315], - ExerciseTarget "Press" 130 $ [Achieved 6 130, Achieved 9 120] - ] +lifts :: [LiftTarget] +lifts = + [ + LiftTarget "Deadlift" 345 $ [Achieved 5 360, Achieved 9 315], + LiftTarget "Press" 130 $ [Achieved 6 130, Achieved 9 120] + ] -computeRepGoal :: ExerciseTarget -> (Integer) -computeRepGoal ExerciseTarget{..} = head $ filter isPR [2..] +computeRepGoal :: LiftTarget -> (Integer) +computeRepGoal LiftTarget{..} = head $ filter isPR [2..] where isPR n = computeOneRepMax (Achieved n targetWeight) > computeOneRepMax (bestPerformance stats) @@ -100,15 +101,15 @@ drawUI :: () -> [Widget ()] drawUI () = [a] where a = hCenter $ renderTable $ table $ - map (padLeftRight 1 . str) ["Exercise", "Achieved Best", "Computed 1RM", "Goal Reps", "Goal+1"] : map toRow exercises - toRow x@ExerciseTarget{..} = + map (padLeftRight 1 . str) ["Lift", "Achieved Best", "Computed 1RM", "Goal Reps", "Goal+1"] : map toRow lifts + toRow x@LiftTarget{..} = let best@Achieved{..} = bestPerformance stats repGoal = computeRepGoal x goalTo1RM g = computeOneRepMax $ Achieved g targetWeight in map (padLeftRight 2) [ - txt $ exerciseName, + txt $ liftName, str $ printf "%d @ %s" achievedReps (showRational achievedWeight), str $ showRational $ computeOneRepMax best, str $ printf "%d @ %s ≈ 1 @ %s" (repGoal) (showRational targetWeight) (showRational (goalTo1RM repGoal)), -- cgit v1.2.3