Plugins: How to determine ghc vs ghci
Levent Erkok
erkokl at gmail.com
Sat Dec 5 01:39:22 UTC 2015
Thanks Simon.. I tried the 'hscTarget df == HscInterpreted' check, and it
works perfectly well.
-Levent.
On Fri, Dec 4, 2015 at 12:34 AM, Simon Marlow <marlowsd at gmail.com> wrote:
> On 24/11/2015 07:37, Levent Erkok wrote:
>
>> I'm working on a plugin, and would like to be able to tell if it's GHC
>> or GHCi that's running.
>>
>> I tried:
>>
>> df <- getDynFlags
>> let isGHCi = ghcMode df == CompManager
>>
>> Alas, while that correctly tells apart "ghci" from "ghc -c", it also
>> returns True when ghc is called without the "-c" argument.
>>
>> Is there a better/more robust way of figuring out whether we're in an
>> interactive session?
>>
>
> The best way is to check whether hscTarget df == HscInterpreted, and you
> can also check whether ghcLink df == LinkInMemory.
>
> Checking for the `--interactive` flag only works for the standalone GHCi,
> and not users of the GHC API.
>
> Cheers,
> Simon
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20151204/b1d0e3a2/attachment.html>
More information about the ghc-devs
mailing list