[Haskell-cafe] -i in OPTIONS_GHC

Brandon Allbery allbery.b at gmail.com
Wed Jul 30 19:23:09 UTC 2025


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 at 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-line-options-in-source-files
> [1]
> https://downloads.haskell.org/ghc/latest/docs/users_guide/flags.html#finding-imports
> _______________________________________________
> 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 at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20250730/ef39bdbc/attachment.html>


More information about the Haskell-Cafe mailing list