diff options
author | Andrew Cady <d@jerkface.net> | 2022-10-04 07:56:37 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2022-10-04 07:56:37 -0400 |
commit | 3a58f9206674abd3c57197bdc05655fa5ba3acc8 (patch) | |
tree | 4c309e461adbcf4561049b9e78f24d7a558ec35b | |
parent | f869fdf59c072500932fec76eebfb4998ee24407 (diff) |
variable renames
-rwxr-xr-x | repgoal.hs | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -68,20 +68,21 @@ data Performance = Achieved { | |||
68 | achievedWeight :: Rational | 68 | achievedWeight :: Rational |
69 | } | 69 | } |
70 | 70 | ||
71 | data ExerciseTarget = ExerciseTarget { | 71 | data LiftTarget = LiftTarget { |
72 | exerciseName :: Text, | 72 | liftName :: Text, |
73 | targetWeight :: Rational, | 73 | targetWeight :: Rational, |
74 | stats :: [Performance] | 74 | stats :: [Performance] |
75 | } | 75 | } |
76 | 76 | ||
77 | exercises :: [ExerciseTarget] | 77 | lifts :: [LiftTarget] |
78 | exercises = [ | 78 | lifts = |
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 | ||
83 | computeRepGoal :: ExerciseTarget -> (Integer) | 84 | computeRepGoal :: LiftTarget -> (Integer) |
84 | computeRepGoal ExerciseTarget{..} = head $ filter isPR [2..] | 85 | computeRepGoal 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 ()] | |||
100 | drawUI () = [a] | 101 | drawUI () = [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)), |