X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=utils%2Frunghc%2Frunghc.hs;h=1ce358e7d07221caa9f87158bc0294810e704379;hb=5656eb8f9bc7ee43da889da4847856a0f70d9461;hp=decbdcd2ba838df17b7dabaa28e307e96fab54c3;hpb=54b748e03297e970bbef9d00a96139798009af0d;p=ghc-hetmet.git diff --git a/utils/runghc/runghc.hs b/utils/runghc/runghc.hs index decbdcd..1ce358e 100644 --- a/utils/runghc/runghc.hs +++ b/utils/runghc/runghc.hs @@ -82,9 +82,16 @@ doIt ghc args = do hClose h doIt ghc (ghc_args ++ [filename]) filename : prog_args -> do - let xflag = if takeExtension filename == ".lhs" - then [] - else ["-x", "hs"] + -- If the file exists, and is not a .lhs file, then we + -- want to treat it as a .hs file. + -- + -- If the file doesn't exist then GHC is going to look for + -- filename.hs and filename.lhs, and use the appropriate + -- type. + exists <- doesFileExist filename + let xflag = if exists && (takeExtension filename /= ".lhs") + then ["-x", "hs"] + else [] c1 = ":set prog " ++ show filename c2 = ":main " ++ show prog_args res <- rawSystem ghc (["-ignore-dot-ghci"] ++