Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting import path in an OPTIONS pragma

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?

like image 739
Cactus Avatar asked Aug 04 '18 04:08

Cactus


1 Answers

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.

like image 184
K. A. Buhr Avatar answered Oct 14 '22 16:10

K. A. Buhr