Gabriella439 / Gabriella439/turtle
Ambiguous occurrence ‘stdout’, and likewise ‘stderr’, when trying to doctest turtle script
- Dominant language
- Haskell
- Stars
- 978
- Forks
- 94
- PR merge metrics
- No merged PRs in 30d
Description
usually I run doctests on my Haskell programs, like so:
```
$ doctest -DDOCTEST somefile.hs
```
when I do this with a minimal turtle script, like this one:
```haskell
#!/usr/bin/env runturtle
{-# LANGUAGE CPP #-}
#ifdef DOCTEST
-- stuff here usually
#endif
import Turtle
main = return ()
```
(having defined a separate runturtle script for that matter)
```shell
#!/bin/sh
exec cabal exec runhaskell -- "$@"
```
I get error messages:
```
rx@mirabelle {master} ~/cfg/spin $ doctest -DDOCTEST somefile.hs
:5:14: error:
Ambiguous occurrence ‘stdout’
It could refer to either ‘Turtle.stdout’,
imported from ‘Turtle’ at somefile.hs:12:1-13
(and originally defined in ‘Turtle.Prelude’)
or ‘System.IO.stdout’,
imported from ‘System.IO’
(and originally defined in ‘GHC.IO.Handle.FD’)
:5:21: error:
Ambiguous occurrence ‘stderr’
It could refer to either ‘Turtle.stderr’,
imported from ‘Turtle’ at somefile.hs:12:1-13
(and originally defined in ‘Turtle.Prelude’)
or ‘System.IO.stderr’,
imported from ‘System.IO’
(and originally defined in ‘GHC.IO.Handle.FD’)
:7:15: error:
Ambiguous occurrence ‘stdout’
It could refer to either ‘Turtle.stdout’,
imported from ‘Turtle’ at somefile.hs:12:1-13
(and originally defined in ‘Turtle.Prelude’)
or ‘System.IO.stdout’,
imported from ‘System.IO’
(and originally defined in ‘GHC.IO.Handle.FD’)
:9:15: error:
Ambiguous occurrence ‘stderr’
It could refer to either ‘Turtle.stderr’,
imported from ‘Turtle’ at somefile.hs:12:1-13
(and originally defined in ‘Turtle.Prelude’)
or ‘System.IO.stderr’,
imported from ‘System.IO’
(and originally defined in ‘GHC.IO.Handle.FD’)
:11:14: error:
Ambiguous occurrence ‘stdout’
It could refer to either ‘Turtle.stdout’,
imported from ‘Turtle’ at somefile.hs:12:1-13
(and originally defined in ‘Turtle.Prelude’)
or ‘System.IO.stdout’,
imported from ‘System.IO’
(and originally defined in ‘GHC.IO.Handle.FD’)
:13:14: error:
Ambiguous occurrence ‘stderr’
It could refer to either ‘Turtle.stderr’,
imported from ‘Turtle’ at somefile.hs:12:1-13
(and originally defined in ‘Turtle.Prelude’)
or ‘System.IO.stderr’,
imported from ‘System.IO’
(and originally defined in ‘GHC.IO.Handle.FD’)
Examples: 0 Tried: 0 Errors: 0 Failures: 0
rx@mirabelle {master} ~/cfg/spin $
```
not sure how to best cope with that situation, using
```
{-# LANGUAGE NoImplicitPrelude #-}
```
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
```
import Turtle hiding (stderr, stdout)
```
but really I would prefer Turtle's stderr/stdout over the ones from System.IO/Prelude
and thus stay in my Turtle world. however
```
import Prelude hiding (stderr, stdout)
import Turtle
```
does not help (I still get the errors above ?)
thanks
-Andreas
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the minimal Turtle script and the `doctest -DDOCTEST somefile.hs` command shown in the report; inspect Turtle's exported `stdout` and `stderr` names and how doctest loads imports. Done means the reproducer can be doctested without ambiguous-occurrence errors while preserving the intended Turtle handles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- cli, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100