Skip to content

Instantly share code, notes, and snippets.

@iancanderson
Forked from MattMSumner/Beer.hs
Created April 1, 2016 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iancanderson/5622b9c94847ff11ce1a47711180543c to your computer and use it in GitHub Desktop.
Save iancanderson/5622b9c94847ff11ce1a47711180543c to your computer and use it in GitHub Desktop.
make it werrkkkk
data Hop = Hop {name :: String, alphaAcid :: Double} deriving (Show)
type BoilTime = Double
type Ounces = Double
data HopAddition = HopAddition Hop Ounces BoilTime deriving (Show)
data HomebrewRecipe = HomebrewRecipe [HopAddition] deriving (Show)
-- http://www.realbeer.com/hops/FAQ.html#units
recipeIbus :: HomebrewRecipe -> Double
recipeIbus (HomebrewRecipe as) = sum $ map ibus as
ibus :: HopAddition -> Double
ibus (HopAddition hop ounces boilTime) = (utilization boilTime) * ounces * (alphaAcid hop) * 7490 / 5
utilization :: BoilTime -> Double
utilization t = bignessFactor * boilTimeFactor(t)
bignessFactor :: Double
bignessFactor = 1.65 * 0.000125 ** (wortGravity - 1)
e :: Double
e = exp 1
boilTimeFactor :: BoilTime -> Double
boilTimeFactor t = (1 - e ** (-0.04 * t)) / 4.15
wortGravity :: Double
wortGravity = 1.050
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment