<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>I think this is an ok forum for this kind of question. You could
      also try the haskell mailing list but I'm not sure if you will get
      more<br>
      help tehre.<br>
      <br>
      I recently played around with the ghc api and I found the `hint`
      package to be quite helpful as an example on how to do various<br>
      things when using the ghc api to implement your own interpreter.</p>
    <p>Have you tried setting verbose? Perhaps the include dir is
      relative to the working directory. In that case setting:</p>
    <div><span style="font-family: Menlo, Consolas, Courier New,
        monospace; font-size: 9pt; line-height: normal;">               
                          , workingDirectory = Just targetDir </span></div>
    <div><span style="font-family: Menlo, Consolas, Courier New,
        monospace; font-size: 9pt; line-height: normal;">               
                          , importPaths      = [targetDir] ++
        importPaths dynflags</span></div>
    <p></p>
    <p>would mean ghc will search in targetDir/targetDir for Lib/Lib2.
      Should be easy to say for sure by enabling verbosity and looking
      at the output.<br>
    </p>
    <div class="moz-cite-prefix">Am 06/02/2023 um 13:42 schrieb Eternal
      Recursion via ghc-devs:<br>
    </div>
    <blockquote type="cite"
cite="mid:rSXyIUkrf4dNDsydopCO_jSsneQTnC2elms00Q80waRxm-9b5C-897lXlptzSleyUyqzazjaTHVDCJZA9QJokrO_hVML70__EWIKOFGkGf0=@proton.me">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div style="font-family: Arial, sans-serif; font-size: 14px;">If
        this is the wrong forum for this question (which as I think
        about it, I suppose it is) then redirection to a more
        appropriate mailing list or forum (or any advice, really) would
        be appreciated. I just figured this would be the forum with the
        best understanding of how the GHC API works (and has changed
        over time), and my longer term goal is indeed to contribute to
        it after I get past my learning curve. <br>
      </div>
      <div style="font-family: Arial, sans-serif; font-size: 14px;"><br>
      </div>
      <div style="font-family: Arial, sans-serif; font-size: 14px;">Sincerely,</div>
      <div style="font-family: Arial, sans-serif; font-size: 14px;"><br>
      </div>
      <div style="font-family: Arial, sans-serif; font-size: 14px;">Bob<br>
      </div>
      <div style="font-family: Arial, sans-serif; font-size: 14px;"><br>
      </div>
      <div class="protonmail_signature_block" style="font-family: Arial,
        sans-serif; font-size: 14px;">
        <div class="protonmail_signature_block-user
          protonmail_signature_block-empty"> </div>
        <div class="protonmail_signature_block-proton"> Sent with <a
            target="_blank" href="https://proton.me/" rel="noopener
            noreferrer" moz-do-not-send="true">Proton Mail</a> secure
          email. </div>
      </div>
      <div style="font-family: Arial, sans-serif; font-size: 14px;"><br>
      </div>
      <div class="protonmail_quote"> ------- Original Message -------<br>
        On Saturday, February 4th, 2023 at 4:04 PM, Eternal Recursion
        via ghc-devs <a class="moz-txt-link-rfc2396E" href="mailto:ghc-devs@haskell.org"><ghc-devs@haskell.org></a> wrote:<br>
        <br>
        <blockquote class="protonmail_quote" type="cite">
          <div style="font-family: Arial, sans-serif; font-size: 14px;
            color: rgb(0, 0, 0);">Hi Everyone!</div>
          <div style="font-family: Arial, sans-serif; font-size: 14px;
            color: rgb(0, 0, 0);"><br>
          </div>
          <div style="font-family: Arial, sans-serif; font-size: 14px;
            color: rgb(0, 0, 0);">I'm new here, trying to learn the GHC
            API. using 944 with cabal 3.8.1.0.<br>
          </div>
          <div style="font-family: Arial, sans-serif; font-size: 14px;
            color: rgb(0, 0, 0);"><br>
          </div>
          <div style="font-family: Arial, sans-serif; font-size: 14px;
            color: rgb(0, 0, 0);">How do I correctly set a GHC Session's
            DynFlags (and/or other properties) to ensure local libraries
            imported by the main target are resolved properly at compile
            time?</div>
          <div style="font-family: Arial, sans-serif; font-size: 14px;
            color: rgb(0, 0, 0);"><br>
          </div>
          <div style="font-family: Arial, sans-serif; font-size: 14px;
            color: rgb(0, 0, 0);">What flags need to be set so that GHC
            is able to load/analyze/compile all relevant Libraries in a
            package?</div>
          <div style="font-family: Arial, sans-serif; font-size: 14px;
            color: rgb(0, 0, 0);"><br>
          </div>
          <div style="font-family: Arial, sans-serif; font-size: 14px;
            color: rgb(0, 0, 0);">This is my current code:</div>
          <div style="font-family: Arial, sans-serif; font-size: 14px;
            color: rgb(0, 0, 0);"><br>
          </div>
          <div style="font-family: Arial, sans-serif; font-size: 14px;
            color: rgb(0, 0, 0);"><span style="font-family: Menlo,
              Consolas, Courier New, monospace; font-size: 9pt;
              line-height: normal;">withPath :: FilePath -> IO ()</span>
            <div>
              <div><span style="font-family: Menlo, Consolas, Courier
                  New, monospace; font-size: 9pt; line-height: normal;">withPath
                  target = do</span></div>
              <div><span style="font-family: Menlo, Consolas, Courier
                  New, monospace; font-size: 9pt; line-height: normal;"> 
                  let targetDir = takeDirectory target </span></div>
            </div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">  let
                targetFile = takeFileName target</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;"> 
                listing <- listDirectory targetDir</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">  let
                imports = filter (\f -> takeExtension f == ".hs")
                listing</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">  print
                imports</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">  let
                moduleName = mkModuleName targetFile</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">  g
                <- defaultErrorHandler defaultFatalMessager
                defaultFlushOut</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">    $
                runGhc (Just libdir) $ do</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">   
                initGhcMonad (Just libdir)</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">   
                dynflags <- getSessionDynFlags</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">   
                setSessionDynFlags $ dynflags { ghcLink          =
                LinkInMemory</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">       
                                          , ghcMode          =
                CompManager</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">       
                                          , backend          =
                Interpreter</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">       
                                          , mainModuleNameIs =
                moduleName</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">       
                                          , workingDirectory = Just
                targetDir </span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">       
                                          , importPaths      =
                [targetDir] ++ importPaths dynflags</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">       
                                          }</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">    </span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">   
                targets <- mapM (\t -> guessTarget t Nothing
                Nothing) imports</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">   
                setTargets targets</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">   
                setContext [ IIDecl $ simpleImportDecl (mkModuleName
                "Prelude") ]</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">   
                load LoadAllTargets</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">   
                liftIO . print . ppr =<< getTargets</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">   
                getModuleGraph</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;"> 
                putStrLn "Here we go!"</span></div>
            <div><span style="font-family: Menlo, Consolas, Courier New,
                monospace; font-size: 9pt; line-height: normal;">  print
                $ ppr $ mgModSummaries g</span></div>
            <span style="font-family: Menlo, Consolas, Courier New,
              monospace; font-size: 9pt; line-height: normal;"> 
              putStrLn "☝️ "</span><br>
          </div>
          <div style="font-family: Arial; font-size: 14px;"><br>
          </div>
          <div style="font-family: Arial; font-size: 14px;">However,
            when I run it (passing to example/app/Main.hs, in which
            directory are Lib.hs and Lib2.hs, the latter being imported
            into Main), I get: <br>
          </div>
          <div style="font-family: Arial; font-size: 14px;"><br>
          </div>
          <div style="font-family: Arial; font-size: 14px;"><span
              style="font-family:monospace"><span style="font-weight:
                bold; color: rgb(84, 255, 84); background-color:
                rgb(255, 255, 255); font-size: 9pt; line-height:
                normal;">$</span><span style="color: rgb(0, 0, 0);
                background-color: rgb(255, 255, 255); font-size: 9pt;
                line-height: normal;"> cabal run cli --
                example/app/Main.hs
              </span><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">Up to date
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">["Main.hs","Lib.hs","Lib2.hs"]
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">[main:Main.hs, main:Lib.hs,
              main:Lib2.hs]
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">Here we go!
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">[ModSummary {
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">    ms_hs_hash =
              23f9c4415bad851a1e36db9d813f34be
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">    ms_mod = Lib,
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">    unit = main
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">    ms_textual_imps = [(, Prelude)]
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">    ms_srcimps = []
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;"> },
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;"> ModSummary {
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">    ms_hs_hash =
              e1eccc23af49f3498a5a9566e63abefd
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">    ms_mod = Lib2,
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">    unit = main
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">    ms_textual_imps = [(, Prelude)]
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">    ms_srcimps = []
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;"> },
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;"> ModSummary {
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">    ms_hs_hash =
              5f6751d7f0d5547a1bdf39af84f8c07f
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">    ms_mod = Main,
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">    unit = main
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">    ms_textual_imps = [(, Prelude),
              (, Lib2)]
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">    ms_srcimps = []
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;"> }]
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">☝  </span><span
              style="font-family:monospace"><br>
              <br>
              <span style="font-weight: bold; color: rgb(0, 0, 0);
                background-color: rgb(255, 255, 255); font-size: 9pt;
                line-height: normal;">example/app/Main.hs:4:1: </span><span
                style="font-weight: bold; color: rgb(255, 84, 84);
                background-color: rgb(255, 255, 255); font-size: 9pt;
                line-height: normal;">error:</span><span
                style="color:#000000;background-color:#ffffff"></span><br>
              <span style="font-weight: bold; color: rgb(0, 0, 0);
                background-color: rgb(255, 255, 255); font-size: 9pt;
                line-height: normal;">    Could not find module ‘Lib2’</span><span
                style="color:#000000;background-color:#ffffff"></span><br>
              <span style="font-weight: bold; color: rgb(0, 0, 0);
                background-color: rgb(255, 255, 255); font-size: 9pt;
                line-height: normal;">    Use -v (or `:set -v` in ghci)
                to see a list of the files searched for.</span><span
                style="color:#000000;background-color:#ffffff"></span><br>
              <span style="font-weight: bold; color: rgb(84, 84, 255);
                background-color: rgb(255, 255, 255); font-size: 9pt;
                line-height: normal;">  |</span><span
                style="color:#000000;background-color:#ffffff"></span><br>
              <span style="font-weight: bold; color: rgb(84, 84, 255);
                background-color: rgb(255, 255, 255); font-size: 9pt;
                line-height: normal;">4 |</span><span style="color:
                rgb(0, 0, 0); background-color: rgb(255, 255, 255);
                font-size: 9pt; line-height: normal;"> </span><span
                style="font-weight: bold; color: rgb(255, 84, 84);
                background-color: rgb(255, 255, 255); font-size: 9pt;
                line-height: normal;">import qualified Lib2 as L2</span><span
                style="color:#000000;background-color:#ffffff"></span><br>
              <span style="font-weight: bold; color: rgb(84, 84, 255);
                background-color: rgb(255, 255, 255); font-size: 9pt;
                line-height: normal;">  |</span><span
                style="font-weight: bold; color: rgb(255, 84, 84);
                background-color: rgb(255, 255, 255); font-size: 9pt;
                line-height: normal;"> ^^^^^^^^^^^^^^^^^^^^^^^^^^^</span><span
                style="color:#000000;background-color:#ffffff"></span><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">cli: example/app/Main.hs:4:1: error:
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">    Could not find module `Lib2'
            </span><span style="font-family:monospace"><br>
            </span><span style="font-family: monospace; font-size: 9pt;
              line-height: normal;">    Use -v (or `:set -v` in ghci) to
              see a list of the files searched for.
            </span><span style="font-family:monospace"><br>
              <br>
            </span><span style="font-family: Arial, sans-serif;">​</span><span
              style="font-family: Arial, sans-serif;">What do I need to
              do differently to make this work?</span></div>
          <div style="font-family: Arial; font-size: 14px;"><span
              style="font-family: Arial, sans-serif;"><br>
            </span></div>
          <div style="font-family: Arial; font-size: 14px;"><span
              style="font-family: Arial, sans-serif;">I have a local
              Cabal file I could use, but to know what I need out of it,
              I need to understand the minimum required info to get this
              to work. TIA!<br>
            </span></div>
          <div style="font-family: Arial; font-size: 14px;"><span
              style="font-family: Arial, sans-serif;"><br>
            </span></div>
          <div style="font-family: Arial; font-size: 14px;"><span
              style="font-family: Arial, sans-serif;">Sincerely,</span></div>
          <div style="font-family: Arial; font-size: 14px;"><span
              style="font-family: Arial, sans-serif;"><br>
            </span></div>
          <div style="font-family: Arial; font-size: 14px;"><span
              style="font-family: Arial, sans-serif;">Bob</span></div>
          <div style="font-family: Arial; font-size: 14px;"><span
              style="font-family: Arial, sans-serif;"><br>
            </span></div>
          <div class="protonmail_signature_block" style="font-family:
            Arial; font-size: 14px;">
            <div class="protonmail_signature_block-user
              protonmail_signature_block-empty"> </div>
            <div class="protonmail_signature_block-proton"> Sent with <a
                target="_blank" href="https://proton.me/"
                rel="noreferrer nofollow noopener"
                moz-do-not-send="true">Proton Mail</a> secure email. </div>
          </div>
        </blockquote>
        <br>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
ghc-devs mailing list
<a class="moz-txt-link-abbreviated" href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a>
</pre>
    </blockquote>
  </body>
</html>