-- Render recipe into a sequence of lines
renderRecipe :: Int -> Recipe -> [String]
renderRecipe sigFigs sections =
  concatMap (renderSection sigFigs fieldLengths) sections ++
    [dashes fieldLengths]
      where fieldLengths = recipeFieldLengths sigFigs sections

-- Render numerical quantities to strings sensibly: one wants to render as few
-- significant digits as possible while keeping n significant digits of
-- accuracy. Rendering as few significant digits as possible is provided by the
-- Formatting library.
--
-- For three significant digits (renderAmount 3 x):
--      0.0     => "0"
--      23.4601 => "23.5"
--      1500    => "1500"
--      0.04659 => "0.0466"
renderRecipe :: Int -> Recipe -> [String]
renderRecipe sigFigs sections =
  concatMap (renderSection sigFigs fieldLengths) sections ++
    [dashes fieldLengths]
      where fieldLengths = recipeFieldLengths sigFigs sections

-- Render numerical quantities to strings sensibly: one wants to render as few
-- significant digits as possible while keeping n significant digits of
-- accuracy. Rendering as few significant digits as possible is provided by the
-- Formatting library.
--
-- For three significant digits (renderAmount 3 x):
--      0.0     => "0"
--      23.4601 => "23.5"
--      1500    => "1500"
--      0.04659 => "0.0466"
renderRecipe sigFigs sections =
  concatMap (renderSection sigFigs fieldLengths) sections ++
    [dashes fieldLengths]
      where fieldLengths = recipeFieldLengths sigFigs sections

-- Render numerical quantities to strings sensibly: one wants to render as few
-- significant digits as possible while keeping n significant digits of
-- accuracy. Rendering as few significant digits as possible is provided by the
-- Formatting library.
--
-- For three significant digits (renderAmount 3 x):
--      0.0     => "0"
--      23.4601 => "23.5"
--      1500    => "1500"
--      0.04659 => "0.0466"