- stubdir = stubDir dflags
-
- mod_basename = moduleNameSlashes mod
- src_basename = basenameOf (expectJust "mkStubPaths"
- (ml_hs_file location))
-
- stub_basename0
- | Just dir <- stubdir = dir `joinFileName` mod_basename
- | otherwise = src_basename
-
- stub_basename = stub_basename0 ++ "_stub"
-
- -- this is the filename we're going to use when
- -- #including the stub_h file from the .hc file.
- -- Without -stubdir, we just #include the basename
- -- (eg. for a module A.B, we #include "B_stub.h"),
- -- relying on the fact that we add an implicit -I flag
- -- for the directory in which the source file resides
- -- (see DriverPipeline.hs). With -stubdir, we
- -- #include "A/B.h", assuming that the user has added
- -- -I<dir> along with -stubdir <dir>.
- include_basename
- | Just _ <- stubdir = mod_basename
- | otherwise = filenameOf src_basename
+ stubdir = stubDir dflags
+
+ mod_basename = moduleNameSlashes mod
+ src_basename = dropExtension $ expectJust "mkStubPaths"
+ (ml_hs_file location)
+
+ stub_basename0
+ | Just dir <- stubdir = dir </> mod_basename
+ | otherwise = src_basename
+
+ stub_basename = stub_basename0 ++ "_stub"
+
+ -- this is the filename we're going to use when
+ -- #including the stub_h file from the .hc file.
+ -- Without -stubdir, we just #include the basename
+ -- (eg. for a module A.B, we #include "B_stub.h"),
+ -- relying on the fact that we add an implicit -I flag
+ -- for the directory in which the source file resides
+ -- (see DriverPipeline.hs). With -stubdir, we
+ -- #include "A/B.h", assuming that the user has added
+ -- -I<dir> along with -stubdir <dir>.
+ include_basename
+ | Just _ <- stubdir = mod_basename
+ | otherwise = takeFileName src_basename