-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ambiguous occurrence ‘stdout’, and likewise ‘stderr’, when trying to doctest turtle script #299
Comments
Even if you do an open import for the |
well thanks a lot.
however the error messages are not coming from any particular usage of
stdout/stderr in any doctests of my program, but from running doctest on
an almost empty file already, consider this 3 lines program minimal.hs:
…--------------------
module Foo where
import Turtle
--------------------
there is no doctest in there yet, and stdout isn't used either,
nevertheless doctest complains (output truncated):
rx@dell {master} ~/cfg/spin $ doctest -DDOCTEST minimal.hs
<interactive>:5:14: error:
Ambiguous occurrence ‘stdout’
It could refer to either ‘Turtle.stdout’,
imported from ‘Turtle’ at minimal.hs:3:1-13
(and originally defined in ‘Turtle.Prelude’)
or ‘System.IO.stdout’,
imported from ‘System.IO’
(and originally defined in ‘GHC.IO.Handle.FD’)
<interactive>:5:21: error:
Ambiguous occurrence ‘stderr’
It could refer to either ‘Turtle.stderr’,
imported from ‘Turtle’ at minimal.hs:3:1-13
(and originally defined in ‘Turtle.Prelude’)
or ‘System.IO.stderr’,
imported from ‘System.IO’
(and originally defined in ‘GHC.IO.Handle.FD’)
these error messages are kind of distracting, so I calm them down with
import Turtle hiding (stdout, stderr)
import qualified Turtle as T
and then I would later use eg. T.stdout in a silly function foo:
foo :: (MonadIO io) => Shell Line -> io ()
foo = T.stdout
that's the only way I have found to turn them off:
import Turtle hiding (stdout, stderr)
thus I cannot use, what would feel more natural,
the style of open import
import Turtle
foo :: (MonadIO io) => Shell Line -> io ()
foo = stdout
when I want to run doctest on my programs.
I am aware that this is not a turtle bug, but rather
a question: maybe the situation can be improved somehow ?
it would be nice if my 3 lines / almost empty program above
would not cause 6 error messages in doctest, and if I could
use the simple pattern of open import
import Turtle
without hesitating usually.
thanks again
Gabriel Gonzalez <[email protected]> writes:
Even if you do an open import for the `Turtle` package you can use
`Turtle.stderr` in your doctest to disambiguate which `stderr` you
meant
|
Oh, I see. I guess |
OK, will do.
Gabriel Gonzalez <[email protected]> writes:
… Oh, I see. I guess `doctest` is including some unqualified references
to `stderr` and `stdout` in its own logic. If that is the case then
your only resort is `import Turtle hiding (stderr, stdout)`. I would
also open up an issue against `doctest` to fully qualify its own
`stderr`/`stdout` references since that seems like a bug to me
|
usually I run doctests on my Haskell programs, like so:
when I do this with a minimal turtle script, like this one:
(having defined a separate runturtle script for that matter)
I get error messages:
not sure how to best cope with that situation, using
causes me a lot of pain to import everything I need by hand
maybe I am doing something wrong? my turtle script runs just fine though,
it's just the fact that I cannot doctest it, that's annoying me
I can calm down the error msgs with
but really I would prefer Turtle's stderr/stdout over the ones from System.IO/Prelude
and thus stay in my Turtle world. however
does not help (I still get the errors above ?)
thanks
-Andreas
The text was updated successfully, but these errors were encountered: