-- -----------------------------------------------------------------------------
-- Configuring

configure :: Verbosity -> Maybe FilePath -> Maybe FilePath
          -> ProgramConfiguration -> IO (Compiler, ProgramConfiguration)
configure verbosity hcPath _hcPkgPath conf = do

  (_ffihugsProg, conf') <- requireProgram verbosity ffihugsProgram
                            (userMaybeSpecifyPath "ffihugs" hcPath conf)
  (_hugsProg, version, conf'')
                        <- requireProgramVersion verbosity hugsProgram'
                            (orLaterVersion (Version [2006] [])) conf'

  let comp = Compiler {
        compilerId             = CompilerId Hugs version,
        compilerLanguages      = hugsLanguages,
        compilerExtensions     = hugsLanguageExtensions
      }
  return (comp, conf'')

  where
    hugsProgram' = hugsProgram { programFindVersion = getVersion }
configure :: Verbosity -> Maybe FilePath -> Maybe FilePath
          -> ProgramConfiguration -> IO (Compiler, ProgramConfiguration)
configure verbosity hcPath _hcPkgPath conf = do

  (_ffihugsProg, conf') <- requireProgram verbosity ffihugsProgram
                            (userMaybeSpecifyPath "ffihugs" hcPath conf)
  (_hugsProg, version, conf'')
                        <- requireProgramVersion verbosity hugsProgram'
                            (orLaterVersion (Version [2006] [])) conf'

  let comp = Compiler {
        compilerId             = CompilerId Hugs version,
        compilerLanguages      = hugsLanguages,
        compilerExtensions     = hugsLanguageExtensions
      }
  return (comp, conf'')

  where
    hugsProgram' = hugsProgram { programFindVersion = getVersion }
configure verbosity hcPath _hcPkgPath conf = do

  (_ffihugsProg, conf') <- requireProgram verbosity ffihugsProgram
                            (userMaybeSpecifyPath "ffihugs" hcPath conf)
  (_hugsProg, version, conf'')
                        <- requireProgramVersion verbosity hugsProgram'
                            (orLaterVersion (Version [2006] [])) conf'

  let comp = Compiler {
        compilerId             = CompilerId Hugs version,
        compilerLanguages      = hugsLanguages,
        compilerExtensions     = hugsLanguageExtensions
      }
  return (comp, conf'')

  where
    hugsProgram' = hugsProgram { programFindVersion = getVersion }