According to the GHC 8.4.3 flag reference, the -i flag is dynamic, which means it should be settable by an OPTIONS pragma.
So I tried the following:
.
├── Main.hs
└── imp
└── Imported.hs
Contents of imp/Imported.hs:
module Imported (foo) where
foo :: String
foo = "Foo"
Contents of Main.hs:
{-# OPTIONS_GHC -iimp #-}
import Imported (foo)
main :: IO ()
main = putStrLn foo
However, if I try to run Main.hs using runhaskell, it complains that Imported cannot be found:
$ runhaskell -v Main.hs
...
Main.hs:2:1: error:
Could not find module ‘Imported’
Locations searched:
Imported.hs
Imported.lhs
Imported.hsig
Imported.lhsig
How do I specify the -i flag in an OPTIONS pragma?
This appears to be a regression of a documentation bug that was fixed in 2007 and then re-broken in 2014 when a bunch of "static"s were changed to "dynamic"s in the flag reference table. As per the linked bug report, the -i flag is not fully dynamic. It can be :set in GHCi but can't be specified in an OPTIONS_GHC line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With