diff options
author | Andrew Cady <d@jerkface.net> | 2022-10-20 16:38:05 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2022-10-20 16:38:05 -0400 |
commit | 54c9f3433947f6083e3811103dda9b4819603658 (patch) | |
tree | 5bd3ada5fd2b56672ea50bbab453eeff04ab6956 | |
parent | 3015c67066f6aadc0a2fb0faad027623b8c4f225 (diff) |
change type of achievedWeight field to Integer
-rwxr-xr-x | repgoal.hs | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -73,7 +73,7 @@ import Generic.Data.Microsurgery | |||
73 | 73 | ||
74 | data Performance = Achieved { | 74 | data Performance = Achieved { |
75 | achievedReps :: Integer, | 75 | achievedReps :: Integer, |
76 | achievedWeight :: Rational | 76 | achievedWeight :: Integer |
77 | } deriving Generic deriving (Read, Show) via Surgery Derecordify Performance | 77 | } deriving Generic deriving (Read, Show) via Surgery Derecordify Performance |
78 | 78 | ||
79 | data LiftRecord = LiftRecord { | 79 | data LiftRecord = LiftRecord { |
@@ -97,7 +97,7 @@ initial' = | |||
97 | LiftRecord "Overhead Squat" [Achieved 5 65] | 97 | LiftRecord "Overhead Squat" [Achieved 5 65] |
98 | ] | 98 | ] |
99 | 99 | ||
100 | computeRepGoal :: Rational -> [Performance] -> (Integer) | 100 | computeRepGoal :: Integer -> [Performance] -> (Integer) |
101 | computeRepGoal targetWeight stats = head $ filter isPR [2..] | 101 | computeRepGoal targetWeight stats = head $ filter isPR [2..] |
102 | where | 102 | where |
103 | isPR n = computeOneRepMax (Achieved n targetWeight) > computeOneRepMax (bestPerformance stats) | 103 | isPR n = computeOneRepMax (Achieved n targetWeight) > computeOneRepMax (bestPerformance stats) |
@@ -108,7 +108,7 @@ bestPerformance = head . sortBy (flip $ comparing computeOneRepMax) | |||
108 | -- The formula from Jim Wendler's 5-3-1: | 108 | -- The formula from Jim Wendler's 5-3-1: |
109 | -- 1RM = Weight x Reps x 0.0333 + Weight. | 109 | -- 1RM = Weight x Reps x 0.0333 + Weight. |
110 | computeOneRepMax :: Performance -> Rational | 110 | computeOneRepMax :: Performance -> Rational |
111 | computeOneRepMax Achieved{..} = achievedWeight * (realToFrac achievedReps * 0.0333 + 1) | 111 | computeOneRepMax Achieved{..} = toRational achievedWeight * (realToFrac achievedReps * 0.0333 + 1) |
112 | 112 | ||
113 | showRational :: Rational -> String | 113 | showRational :: Rational -> String |
114 | showRational n = printf format $ (realToFrac :: Rational -> Float) $ n | 114 | showRational n = printf format $ (realToFrac :: Rational -> Float) $ n |
@@ -126,7 +126,7 @@ drawUI (St lifts _) = [vCenter $ vBox [hCenter oneRepMaxTable, withVScrollBarHan | |||
126 | map (padLeftRight 2) | 126 | map (padLeftRight 2) |
127 | [ | 127 | [ |
128 | txt $ liftName, | 128 | txt $ liftName, |
129 | str $ printf "%d @ %s" achievedReps (showRational achievedWeight), | 129 | str $ printf "%d @ %d" achievedReps achievedWeight, |
130 | str $ showRational $ computeOneRepMax best | 130 | str $ showRational $ computeOneRepMax best |
131 | ] | 131 | ] |
132 | toWeekRows lift = (flip map) [1,2,3::Int] $ \week -> toWeekRow week lift | 132 | toWeekRows lift = (flip map) [1,2,3::Int] $ \week -> toWeekRow week lift |
@@ -137,8 +137,8 @@ drawUI (St lifts _) = [vCenter $ vBox [hCenter oneRepMaxTable, withVScrollBarHan | |||
137 | targetPercentage = case week of 1 -> 85; 2 -> 90; 3 -> 95; _ -> undefined | 137 | targetPercentage = case week of 1 -> 85; 2 -> 90; 3 -> 95; _ -> undefined |
138 | computedTarget = (* (targetPercentage % 100)) $ (* (90 % 100)) $ computeOneRepMax best | 138 | computedTarget = (* (targetPercentage % 100)) $ (* (90 % 100)) $ computeOneRepMax best |
139 | targetWeight = ceilingN 5 computedTarget | 139 | targetWeight = ceilingN 5 computedTarget |
140 | repGoal = computeRepGoal (targetWeight % 1) stats | 140 | repGoal = computeRepGoal targetWeight stats |
141 | goalTo1RM g = computeOneRepMax $ Achieved g (targetWeight % 1) | 141 | goalTo1RM g = computeOneRepMax $ Achieved g targetWeight |
142 | showGoal g = printf "%2d @ %d ≈ 1 @ %s" g targetWeight (showRational (goalTo1RM g)) | 142 | showGoal g = printf "%2d @ %d ≈ 1 @ %s" g targetWeight (showRational (goalTo1RM g)) |
143 | in | 143 | in |
144 | map (padLeftRight 2) | 144 | map (padLeftRight 2) |