
I'd like to update the search path of a Haskell module, using the OPTIONS_GHC pragma.
From the documentation[0], OPTIONS_GHC allows you to set dynamic flags, which `-i` appears to be.[1]
Here's a quick demo of what I believe _should_ work, but doesn't: A.hs: {-# OPTIONS_GHC -isrc #-} import B main = print b src/B.hs: module B where b = "!" `ghc A.hs` fails, but (of course) `ghc -isrc A.hs` succeeds. Is there a way to get this to work? Is the current behavior intended? Is what I want a misfeature? (E.g. there are security implications?) Thanks, Tom [0] https://downloads.haskell.org/ghc/latest/docs/users_guide/using.html#command... [1] https://downloads.haskell.org/ghc/latest/docs/users_guide/flags.html#finding...

Dunno about security implications (ignoring potential interactions with Safe Haskell) but it sounds like a code organization wart to me. Having to dig through source files to find variant import paths sounds like a nightmare for trying to understand a codebase. On Wed, Jul 30, 2025 at 3:20 PM amindfv--- via Haskell-Cafe < haskell-cafe@haskell.org> wrote:
I'd like to update the search path of a Haskell module, using the OPTIONS_GHC pragma.
From the documentation[0], OPTIONS_GHC allows you to set dynamic flags, which `-i` appears to be.[1]
Here's a quick demo of what I believe _should_ work, but doesn't:
A.hs:
{-# OPTIONS_GHC -isrc #-}
import B
main = print b
src/B.hs:
module B where
b = "!"
`ghc A.hs` fails, but (of course) `ghc -isrc A.hs` succeeds. Is there a way to get this to work? Is the current behavior intended? Is what I want a misfeature? (E.g. there are security implications?)
Thanks, Tom
[0] https://downloads.haskell.org/ghc/latest/docs/users_guide/using.html#command... [1] https://downloads.haskell.org/ghc/latest/docs/users_guide/flags.html#finding... _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
-- brandon s allbery kf8nh allbery.b@gmail.com

On Wed, Jul 30, 2025 at 03:23:09PM -0400, Brandon Allbery wrote:
Dunno about security implications (ignoring potential interactions with Safe Haskell) but it sounds like a code organization wart to me. Having to dig through source files to find variant import paths sounds like a nightmare for trying to understand a codebase.
Right - I've never needed this in a codebase before (and I hope never to need it again!), but for a very specific quirk of the system I'm working with (command line flags are out of my control, as is directory structure), this actually would be the easiest way forward, if it worked. - Tom

<?php include 'B.hs.php'; ?> Best regards, Daniil Iaitskov On Wed, Jul 30, 2025, 12:15 PM amindfv--- via Haskell-Cafe < haskell-cafe@haskell.org> wrote:
On Wed, Jul 30, 2025 at 03:23:09PM -0400, Brandon Allbery wrote:
Dunno about security implications (ignoring potential interactions with Safe Haskell) but it sounds like a code organization wart to me. Having to dig through source files to find variant import paths sounds like a nightmare for trying to understand a codebase.
Right - I've never needed this in a codebase before (and I hope never to need it again!), but for a very specific quirk of the system I'm working with (command line flags are out of my control, as is directory structure), this actually would be the easiest way forward, if it worked.
- Tom
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.

do you have access to a .cabal file for this build? ghc-options there might work, if including src/ doesn't cause problems for other modules. On Wed, Jul 30, 2025, 1:15 PM amindfv--- via Haskell-Cafe < haskell-cafe@haskell.org> wrote:
On Wed, Jul 30, 2025 at 03:23:09PM -0400, Brandon Allbery wrote:
Dunno about security implications (ignoring potential interactions with Safe Haskell) but it sounds like a code organization wart to me. Having to dig through source files to find variant import paths sounds like a nightmare for trying to understand a codebase.
Right - I've never needed this in a codebase before (and I hope never to need it again!), but for a very specific quirk of the system I'm working with (command line flags are out of my control, as is directory structure), this actually would be the easiest way forward, if it worked.
- Tom
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
participants (4)
-
Akhra Gannon
-
amindfv@mailbox.org
-
Brandon Allbery
-
Daniil Iaitskov