Improved help for "import" command at the start of a script when "variable not in scope" in error msg
The piece of code that bgamari wrote in #13891
is interesting from the point of view of the error messages.\\
main = do
putStrLn "forking"
forkIO $ bracket (putStrLn "forked") (const $ putStrLn "finalize") (const $ putStrLn "hello" >> threadDelay 100000000)
threadDelay 10000
putStrLn "done"
When the imports are not written GHC answers.\\
Prelude> :l testfork
[1 of 1] Compiling Main ( testfork.hs, interpreted )
testfork.hs:6:5: error:
Variable not in scope: forkIO :: t0 -> IO a0
testfork.hs:6:14: error:
Variable not in scope:
bracket :: IO () -> (b1 -> IO ()) -> (b0 -> IO b2) -> t0
testfork.hs:6:101: error:
Variable not in scope: threadDelay :: Integer -> IO b2
testfork.hs:7:5: error:
Variable not in scope: threadDelay :: Integer -> IO a1
Failed, modules loaded: none.
Prelude>
It would be advisable to complete by:\\
Perhaps you intended to import Control.Concurrent
for forkIO
and threadDelay
.\\
Perhaps you intended to import Control.Exception
for
bracket
.\\
I hope you have a way to write it once for all the variables involved.
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.2 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |