Skip to content
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

Open
reuleaux opened this issue Mar 26, 2018 · 4 comments

Comments

@reuleaux
Copy link

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:

#!/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)

#!/bin/sh
exec cabal exec runhaskell -- "$@"

I get error messages:

rx@mirabelle {master} ~/cfg/spin $ doctest -DDOCTEST somefile.hs 

<interactive>: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’)

<interactive>: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’)

<interactive>: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’)

<interactive>: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’)

<interactive>: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’)

<interactive>: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

@Gabriella439
Copy link
Owner

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

@reuleaux
Copy link
Author

reuleaux commented Mar 26, 2018 via email

@Gabriella439
Copy link
Owner

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

@reuleaux
Copy link
Author

reuleaux commented Mar 27, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants