summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2022-10-04 07:56:37 -0400
committerAndrew Cady <d@jerkface.net>2022-10-04 07:56:37 -0400
commit3a58f9206674abd3c57197bdc05655fa5ba3acc8 (patch)
tree4c309e461adbcf4561049b9e78f24d7a558ec35b
parentf869fdf59c072500932fec76eebfb4998ee24407 (diff)
variable renames
-rwxr-xr-xrepgoal.hs25
1 files 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 {
68 achievedWeight :: Rational 68 achievedWeight :: Rational
69} 69}
70 70
71data ExerciseTarget = ExerciseTarget { 71data LiftTarget = LiftTarget {
72 exerciseName :: Text, 72 liftName :: Text,
73 targetWeight :: Rational, 73 targetWeight :: Rational,
74 stats :: [Performance] 74 stats :: [Performance]
75} 75}
76 76
77exercises :: [ExerciseTarget] 77lifts :: [LiftTarget]
78exercises = [ 78lifts =
79 ExerciseTarget "Deadlift" 345 $ [Achieved 5 360, Achieved 9 315], 79 [
80 ExerciseTarget "Press" 130 $ [Achieved 6 130, Achieved 9 120] 80 LiftTarget "Deadlift" 345 $ [Achieved 5 360, Achieved 9 315],
81 ] 81 LiftTarget "Press" 130 $ [Achieved 6 130, Achieved 9 120]
82 ]
82 83
83computeRepGoal :: ExerciseTarget -> (Integer) 84computeRepGoal :: LiftTarget -> (Integer)
84computeRepGoal ExerciseTarget{..} = head $ filter isPR [2..] 85computeRepGoal LiftTarget{..} = head $ filter isPR [2..]
85 where 86 where
86 isPR n = computeOneRepMax (Achieved n targetWeight) > computeOneRepMax (bestPerformance stats) 87 isPR n = computeOneRepMax (Achieved n targetWeight) > computeOneRepMax (bestPerformance stats)
87 88
@@ -100,15 +101,15 @@ drawUI :: () -> [Widget ()]
100drawUI () = [a] 101drawUI () = [a]
101 where 102 where
102 a = hCenter $ renderTable $ table $ 103 a = hCenter $ renderTable $ table $
103 map (padLeftRight 1 . str) ["Exercise", "Achieved Best", "Computed 1RM", "Goal Reps", "Goal+1"] : map toRow exercises 104 map (padLeftRight 1 . str) ["Lift", "Achieved Best", "Computed 1RM", "Goal Reps", "Goal+1"] : map toRow lifts
104 toRow x@ExerciseTarget{..} = 105 toRow x@LiftTarget{..} =
105 let best@Achieved{..} = bestPerformance stats 106 let best@Achieved{..} = bestPerformance stats
106 repGoal = computeRepGoal x 107 repGoal = computeRepGoal x
107 goalTo1RM g = computeOneRepMax $ Achieved g targetWeight 108 goalTo1RM g = computeOneRepMax $ Achieved g targetWeight
108 in 109 in
109 map (padLeftRight 2) 110 map (padLeftRight 2)
110 [ 111 [
111 txt $ exerciseName, 112 txt $ liftName,
112 str $ printf "%d @ %s" achievedReps (showRational achievedWeight), 113 str $ printf "%d @ %s" achievedReps (showRational achievedWeight),
113 str $ showRational $ computeOneRepMax best, 114 str $ showRational $ computeOneRepMax best,
114 str $ printf "%d @ %s ≈ 1 @ %s" (repGoal) (showRational targetWeight) (showRational (goalTo1RM repGoal)), 115 str $ printf "%d @ %s ≈ 1 @ %s" (repGoal) (showRational targetWeight) (showRational (goalTo1RM repGoal)),