Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE TypeApplications #-}
- module Library
- ( Week
- , Day
- , Weight
- , Exercise(..)
- , Options(..)
- , run
- )
- where
- type Week = [Day]
- type Day = [(Exercise, [Weight])]
- type Weight = Float
- data Exercise = Squat | Bench | Deadlift | Press | Row deriving (Eq, Show)
- data Options = Options
- { optSquat :: Weight
- , optBench :: Weight
- , optDeadlift :: Weight
- , optPress :: Weight
- , optRow :: Weight
- } deriving (Eq, Show)
- minPlates :: Weight
- minPlates = 2.5
- interval :: Float
- interval = 0.125
- run :: Options -> Week
- run opts = [mkMonday opts, mkWednesday opts, mkFriday opts]
- mkMonday :: Options -> Day
- mkMonday opts =
- [ (Squat, mkSets $ optSquat opts)
- , (Bench, mkSets $ optBench opts)
- , (Row , mkSets $ optRow opts)
- ]
- where mkSets weight = map (mkSet weight) [4, 3, 2, 1, 0]
- mkWednesday :: Options -> Day
- mkWednesday opts =
- [ (Squat , map (mkSet (optSquat opts)) [4, 3, 2, 2])
- , (Press , mkSets $ optPress opts)
- , (Deadlift, mkSets $ optDeadlift opts)
- ]
- where mkSets weight = map (mkSet weight) [3, 2, 1, 0]
- mkFriday :: Options -> Day
- mkFriday opts =
- [ (Squat, mkSets $ optSquat opts)
- , (Bench, mkSets $ optBench opts)
- , (Row , mkSets $ optRow opts)
- ]
- where
- mkSets weight =
- map (mkSet weight) [4, 3, 2, 1]
- <> [mkSet weight 0 + minPlates, mkSet weight 2]
- -- 0 -> 100%
- -- 1 -> 87.5%
- -- 2 -> 75%
- -- ...
- mkSet :: Weight -> Integer -> Weight
- mkSet weight i = ceilWeight $ weight * (1 - interval * fromIntegral i)
- ceilWeight :: Weight -> Weight
- ceilWeight weight =
- minPlates * (fromIntegral @Integer . ceiling $ weight / minPlates)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement