-------------------------------------------------------------------------------

ppMain :: Int -> [ExtVars] -> Doc
ppMain numIterations vars =
  vcat $
    [ text "int main(int argc, char const *argv[]) {"
    , text "  int i;"
    , text "  for (i = 0; i < " <> rnds <> text "; i++) {"
    , space
    , vcat $ map (nest 3) $ map assignVals vars
    , space
    , text "    if (i > 0) printf(\"#\\n\");"
    , text "    " <> text "step();"
    , text "  }"
    , text "  return 0;"
    , text "}"
    , space
    ]

  where
  rnds = text $ show numIterations
  assignVals :: (Name, DynamicF [] Type) -> Doc
  assignVals (name, _) = 
    text name <+> equals <+> 
      valsName name <> lbrack <> text "i" <> rbrack <> semi

--------------------------------------------------------------------------------

ppMain :: Int -> [ExtVars] -> Doc
ppMain numIterations vars =
  vcat $
    [ text "int main(int argc, char const *argv[]) {"
    , text "  int i;"
    , text "  for (i = 0; i < " <> rnds <> text "; i++) {"
    , space
    , vcat $ map (nest 3) $ map assignVals vars
    , space
    , text "    if (i > 0) printf(\"#\\n\");"
    , text "    " <> text "step();"
    , text "  }"
    , text "  return 0;"
    , text "}"
    , space
    ]

  where
  rnds = text $ show numIterations
  assignVals :: (Name, DynamicF [] Type) -> Doc
  assignVals (name, _) = 
    text name <+> equals <+> 
      valsName name <> lbrack <> text "i" <> rbrack <> semi

--------------------------------------------------------------------------------
ppMain numIterations vars =
  vcat $
    [ text "int main(int argc, char const *argv[]) {"
    , text "  int i;"
    , text "  for (i = 0; i < " <> rnds <> text "; i++) {"
    , space
    , vcat $ map (nest 3) $ map assignVals vars
    , space
    , text "    if (i > 0) printf(\"#\\n\");"
    , text "    " <> text "step();"
    , text "  }"
    , text "  return 0;"
    , text "}"
    , space
    ]

  where
  rnds = text $ show numIterations
  assignVals :: (Name, DynamicF [] Type) -> Doc
  assignVals (name, _) = 
    text name <+> equals <+> 
      valsName name <> lbrack <> text "i" <> rbrack <> semi

--------------------------------------------------------------------------------