[Haskell-cafe] -i in OPTIONS_GHC

amindfv at mailbox.org amindfv at mailbox.org
Wed Jul 30 19:21:23 UTC 2025


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


More information about the Haskell-Cafe mailing list