Re: Disable messages with GHC API

2017-02-03 Thread Alan & Kim Zimmerman
Here [1] is the tweak we do in HaRe to get the right dynflags

Alan

[1]
https://github.com/alanz/HaRe/blob/master/src/Language/Haskell/Refact/Utils/Utils.hs#L224

On 3 Feb 2017 5:59 p.m., "Matthew Pickering" 
wrote:

> You are right. I looked more closely now and it looks like
> "parseModule" and so on overwrite the DynFlags with a cached version
> before running the relevant piece of the pipeline.
>
>  857hsc_env <- getSession
>  858let hsc_env_tmp = hsc_env { hsc_dflags = ms_hspp_opts ms }
>  859hpm <- liftIO $ hscParse hsc_env_tmp ms
>
>
> I think this is symptom of the fact that DynFlags is not very well
> structured and a lot of different compiler options are lumped
> together. It makes sense that we need to use the right DynFlags to run
> the module but this shouldn't overwrite things which are irrelevant
> like log_action.
>
> Matt
>
>
> On Fri, Feb 3, 2017 at 3:30 PM, Christopher Done 
> wrote:
> > Adding `handleSourceError` around it makes no difference.
> >
> > Which makes sense, as I don't think warnings count as exceptions,
> > otherwise my code would never have completed in the first place.
> >
> > On 3 February 2017 at 12:50, Matthew Pickering
> >  wrote:
> >> The errors are eventually caught and printed by "handleSourceError"
> >> which is used a few times in your code. You could either modify one of
> >> these to not print out any errors or try something more intelligent
> >> like is in `parUpsweep_one` which does use the `log_action` in order
> >> to print the errors out.
> >>
> >> On Fri, Feb 3, 2017 at 12:21 PM, Christopher Done 
> wrote:
> >>> In Intero, after loading modules, for each one I run the following
> >>> function: https://github.com/commercialhaskell/intero/blob/
> 300ac5a/src/GhciInfo.hs#L75..L85
> >>>
> >>> If there are warnings or any output, they get outputted. As they are
> >>> already outputted by regular :load, I don’t need the same output
> >>> twice.
> >>>
> >>> How do I disable non-severe output for any GhcMonad m => m a? I’m
> >>> using GHC 8.0.1 presently.
> >>>
> >>> I tried the following before calling getModInfo, expecting there to be
> >>> no output anymore:
> >>>
> >>> +  GHC.setSessionDynFlags
> >>> +df {log_action = \ref dflags severity srcSpan style msg ->
> return ()}
> >>>
> >>> And this had no effect. I tried some other things but ran out of
> >>> patience to keep a record of them all.
> >>>
> >>> Ciao!
> >>> ___
> >>> ghc-devs mailing list
> >>> ghc-devs@haskell.org
> >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
> ___
> ghc-devs mailing list
> ghc-devs@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


Re: Disable messages with GHC API

2017-02-03 Thread Matthew Pickering
You are right. I looked more closely now and it looks like
"parseModule" and so on overwrite the DynFlags with a cached version
before running the relevant piece of the pipeline.

 857hsc_env <- getSession
 858let hsc_env_tmp = hsc_env { hsc_dflags = ms_hspp_opts ms }
 859hpm <- liftIO $ hscParse hsc_env_tmp ms


I think this is symptom of the fact that DynFlags is not very well
structured and a lot of different compiler options are lumped
together. It makes sense that we need to use the right DynFlags to run
the module but this shouldn't overwrite things which are irrelevant
like log_action.

Matt


On Fri, Feb 3, 2017 at 3:30 PM, Christopher Done  wrote:
> Adding `handleSourceError` around it makes no difference.
>
> Which makes sense, as I don't think warnings count as exceptions,
> otherwise my code would never have completed in the first place.
>
> On 3 February 2017 at 12:50, Matthew Pickering
>  wrote:
>> The errors are eventually caught and printed by "handleSourceError"
>> which is used a few times in your code. You could either modify one of
>> these to not print out any errors or try something more intelligent
>> like is in `parUpsweep_one` which does use the `log_action` in order
>> to print the errors out.
>>
>> On Fri, Feb 3, 2017 at 12:21 PM, Christopher Done  
>> wrote:
>>> In Intero, after loading modules, for each one I run the following
>>> function: 
>>> https://github.com/commercialhaskell/intero/blob/300ac5a/src/GhciInfo.hs#L75..L85
>>>
>>> If there are warnings or any output, they get outputted. As they are
>>> already outputted by regular :load, I don’t need the same output
>>> twice.
>>>
>>> How do I disable non-severe output for any GhcMonad m => m a? I’m
>>> using GHC 8.0.1 presently.
>>>
>>> I tried the following before calling getModInfo, expecting there to be
>>> no output anymore:
>>>
>>> +  GHC.setSessionDynFlags
>>> +df {log_action = \ref dflags severity srcSpan style msg -> return 
>>> ()}
>>>
>>> And this had no effect. I tried some other things but ran out of
>>> patience to keep a record of them all.
>>>
>>> Ciao!
>>> ___
>>> ghc-devs mailing list
>>> ghc-devs@haskell.org
>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


Re: Disable messages with GHC API

2017-02-03 Thread Daniel Gröber
On Fri, Feb 03, 2017 at 12:21:38PM +, Christopher Done wrote:
> I tried the following before calling getModInfo, expecting there to be
> no output anymore:
> 
> +  GHC.setSessionDynFlags
> +df {log_action = \ref dflags severity srcSpan style msg -> return ()}

That is pretty much exactly what I do in ghc-mod to suppress all
output (other than the SourceError exceptions) so it's strange that
wouldn't work.

Have you tried making a small self contained test case for your
problem, maybe it's something intero specific? How far has it diverged
from it's GHCi roots these days anyways?

Here's[1] a small testcase I usually modify to test various GHC oddities
when I'm not sure if my ghc-mod monad magic is doing something werid
or not, might be helpful:

[1]: 
https://github.com/DanielG/ghc-mod/blob/master/test/manual/not-interpreted-error/GhcTestcase.hs

--Daniel


signature.asc
Description: PGP signature
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


Re: Disable messages with GHC API

2017-02-03 Thread Christopher Done
Adding `handleSourceError` around it makes no difference.

Which makes sense, as I don't think warnings count as exceptions,
otherwise my code would never have completed in the first place.

On 3 February 2017 at 12:50, Matthew Pickering
 wrote:
> The errors are eventually caught and printed by "handleSourceError"
> which is used a few times in your code. You could either modify one of
> these to not print out any errors or try something more intelligent
> like is in `parUpsweep_one` which does use the `log_action` in order
> to print the errors out.
>
> On Fri, Feb 3, 2017 at 12:21 PM, Christopher Done  wrote:
>> In Intero, after loading modules, for each one I run the following
>> function: 
>> https://github.com/commercialhaskell/intero/blob/300ac5a/src/GhciInfo.hs#L75..L85
>>
>> If there are warnings or any output, they get outputted. As they are
>> already outputted by regular :load, I don’t need the same output
>> twice.
>>
>> How do I disable non-severe output for any GhcMonad m => m a? I’m
>> using GHC 8.0.1 presently.
>>
>> I tried the following before calling getModInfo, expecting there to be
>> no output anymore:
>>
>> +  GHC.setSessionDynFlags
>> +df {log_action = \ref dflags severity srcSpan style msg -> return 
>> ()}
>>
>> And this had no effect. I tried some other things but ran out of
>> patience to keep a record of them all.
>>
>> Ciao!
>> ___
>> ghc-devs mailing list
>> ghc-devs@haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


Re: Disable messages with GHC API

2017-02-03 Thread Matthew Pickering
The errors are eventually caught and printed by "handleSourceError"
which is used a few times in your code. You could either modify one of
these to not print out any errors or try something more intelligent
like is in `parUpsweep_one` which does use the `log_action` in order
to print the errors out.

On Fri, Feb 3, 2017 at 12:21 PM, Christopher Done  wrote:
> In Intero, after loading modules, for each one I run the following
> function: 
> https://github.com/commercialhaskell/intero/blob/300ac5a/src/GhciInfo.hs#L75..L85
>
> If there are warnings or any output, they get outputted. As they are
> already outputted by regular :load, I don’t need the same output
> twice.
>
> How do I disable non-severe output for any GhcMonad m => m a? I’m
> using GHC 8.0.1 presently.
>
> I tried the following before calling getModInfo, expecting there to be
> no output anymore:
>
> +  GHC.setSessionDynFlags
> +df {log_action = \ref dflags severity srcSpan style msg -> return ()}
>
> And this had no effect. I tried some other things but ran out of
> patience to keep a record of them all.
>
> Ciao!
> ___
> ghc-devs mailing list
> ghc-devs@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


Disable messages with GHC API

2017-02-03 Thread Christopher Done
In Intero, after loading modules, for each one I run the following
function: 
https://github.com/commercialhaskell/intero/blob/300ac5a/src/GhciInfo.hs#L75..L85

If there are warnings or any output, they get outputted. As they are
already outputted by regular :load, I don’t need the same output
twice.

How do I disable non-severe output for any GhcMonad m => m a? I’m
using GHC 8.0.1 presently.

I tried the following before calling getModInfo, expecting there to be
no output anymore:

+  GHC.setSessionDynFlags
+df {log_action = \ref dflags severity srcSpan style msg -> return ()}

And this had no effect. I tried some other things but ran out of
patience to keep a record of them all.

Ciao!
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs