[GHC] #13893: Improved help for "import" command at the start of a script when "variable not in scope" in error msg (was: Improved Help for Control.Concurrent and Control.Exception when "variable not in scope")

GHC ghc-devs at haskell.org
Mon Jul 3 10:09:13 UTC 2017


#13893: Improved help for "import" command at the start of a script when "variable
not in scope" in error msg
-------------------------------------+-------------------------------------
        Reporter:  vanto             |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.2
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Poor/confusing    |  Unknown/Multiple
  error message                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by vanto):

 Replying to [[span(style=color: #FF0000, slyfox )]]\\
 To make it simple:

 {{{
 module Azer where
 -- import Data.Char

 main :: IO ()
 main = print (map toLower "HELLO")
 }}}
 Compiler response:\\

 {{{
 Prelude> :l azer
 [1 of 1] Compiling Azer             ( azer.hs, interpreted )

 azer.hs:5:19: error: Variable not in scope: toLower :: Char -> b0
   |
 5 | main = print (map toLower "HELLO")
   |                   ^^^^^^^
 Failed, modules loaded: none.
 }}}

 {{{toLower}}} belongs to data. Char. It would be easy for GHC to propose
 it in
 suggestion. How? I do not know. I have not the same knowledge as you in
 the
 Haskell compiler. Nevertheless I think that is possible. Easy or difficult
 to do,
 I don't know.\\
 Regarding FromList, for instance:\\

 {{{
 Data.Sequence.fromList :: [a] -> Seq a
         -- Defined in `Data.Sequence'

 Data.IntSet.fromList :: [Key] -> IntSet
         -- Defined in `containers-0.5.7.1:Data.IntSet.Base'
 }}}
 It may be more difficult. We can teach the compiler to make a better
 difference.\\
 How? I do not know yet but it can be studied.\\
 This ticket should be considered as an idea for a future improvement in
 aid
 to the programmer.\\
 Nevertheless as many people agree to improve the error messages, and this
 for a very long time, it is certainly better to start thinking about this.
 As this
 ticket is part of it, it will be de facto taken into account.
 Don't worry too much with this ticket, consider it only as an idea that
 can be
 applied later in the compiler.
 Do not close this ticket it will be able to serve later.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13893#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list