Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. {-# LANGUAGE TypeApplications #-}
  2. module Library
  3. ( Week
  4. , Day
  5. , Weight
  6. , Exercise(..)
  7. , Options(..)
  8. , run
  9. )
  10. where
  11.  
  12. type Week = [Day]
  13. type Day = [(Exercise, [Weight])]
  14. type Weight = Float
  15.  
  16. data Exercise = Squat | Bench | Deadlift | Press | Row deriving (Eq, Show)
  17.  
  18. data Options = Options
  19. { optSquat :: Weight
  20. , optBench :: Weight
  21. , optDeadlift :: Weight
  22. , optPress :: Weight
  23. , optRow :: Weight
  24. } deriving (Eq, Show)
  25.  
  26. minPlates :: Weight
  27. minPlates = 2.5
  28.  
  29. interval :: Float
  30. interval = 0.125
  31.  
  32. run :: Options -> Week
  33. run opts = [mkMonday opts, mkWednesday opts, mkFriday opts]
  34.  
  35. mkMonday :: Options -> Day
  36. mkMonday opts =
  37. [ (Squat, mkSets $ optSquat opts)
  38. , (Bench, mkSets $ optBench opts)
  39. , (Row , mkSets $ optRow opts)
  40. ]
  41. where mkSets weight = map (mkSet weight) [4, 3, 2, 1, 0]
  42.  
  43. mkWednesday :: Options -> Day
  44. mkWednesday opts =
  45. [ (Squat , map (mkSet (optSquat opts)) [4, 3, 2, 2])
  46. , (Press , mkSets $ optPress opts)
  47. , (Deadlift, mkSets $ optDeadlift opts)
  48. ]
  49. where mkSets weight = map (mkSet weight) [3, 2, 1, 0]
  50.  
  51. mkFriday :: Options -> Day
  52. mkFriday opts =
  53. [ (Squat, mkSets $ optSquat opts)
  54. , (Bench, mkSets $ optBench opts)
  55. , (Row , mkSets $ optRow opts)
  56. ]
  57. where
  58. mkSets weight =
  59. map (mkSet weight) [4, 3, 2, 1]
  60. <> [mkSet weight 0 + minPlates, mkSet weight 2]
  61.  
  62. -- 0 -> 100%
  63. -- 1 -> 87.5%
  64. -- 2 -> 75%
  65. -- ...
  66. mkSet :: Weight -> Integer -> Weight
  67. mkSet weight i = ceilWeight $ weight * (1 - interval * fromIntegral i)
  68.  
  69. ceilWeight :: Weight -> Weight
  70. ceilWeight weight =
  71. minPlates * (fromIntegral @Integer . ceiling $ weight / minPlates)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement