def _output_file_ext(base, dynamic, profiling_enabled):
  """Return extension that output of compilation should have depending on the
  following inputs:

  Args:
    base: usually "o" for object files and "hi" for interface files. Preceding
      dot "." will be preserved in the output.
    dynamic: bool, whether we're compiling dynamic object files.
    profiling_enabled: bool, whether profiling is enabled.

  Returns:
    String, extension of Haskell object file.
  """

  with_dot = False
  ext = ""

  if base[0] == '.':
    with_dot = True
    ext = base[1:]
  else:
    ext = base

  if dynamic:
    ext = "dyn_" + ext
  if profiling_enabled:
    ext = "p_" + ext
  return ("." if with_dot else "") + ext