[GHC] #14780: :type-at doesn't work when :load-ing with module name instead of file path

#14780: :type-at doesn't work when :load-ing with module name instead of file path --------------------------------------+--------------------------- Reporter: jol | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.2.2 Keywords: | Operating System: Linux Architecture: x86_64 (amd64) | Type of failure: Other Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: --------------------------------------+--------------------------- After running {{{#!sh stack new something cd something }}} we have a file in src/Lib.hs with the contents: {{{#!hs module Lib ( someFunc ) where someFunc :: IO () someFunc = putStrLn "someFunc" }}} If we start `stack ghci`, we can have the following session showing the errors: {{{
:set +c :l Lib [1 of 1] Compiling Lib ( /home/jol/work- for/me/something/src/Lib.hs, interpreted ) Ok, one module loaded. Collecting type info for 1 module(s) ... :type-at Lib 6 12 6 20
<no location info>: error: not an expression: ‘’
:type-at src/Lib.hs 6 12 6 20 Couldn't guess that module name. Does it exist? }}}
If we had done `:l src/Lib.hs` instead, then we can use the filepath like the following, but still not the module name: {{{
:set +c :l src/Lib.hs [1 of 1] Compiling Lib ( src/Lib.hs, interpreted ) Ok, one module loaded. Collecting type info for 1 module(s) ... :type-at Lib 6 12 6 20
<no location info>: error: not an expression: ‘’
:type-at src/Lib.hs 6 12 6 20 :: String -> IO () }}}
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14780 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14780: :type-at doesn't work when :load-ing with module name instead of file path ---------------------------+-------------------------------------- Reporter: jol | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.2.2 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 (amd64) Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------+-------------------------------------- Comment (by jol): I'm really not sure what the proper fix should be. Because this is meant for use by an IDE and not a user, maybe the documentation could simply be improved? I spent a while trying to figure out how to use `:type-at`, because 1. I didn't understand that the right bound for the span given should be one column to the right of the last character of the expression, and 2. I didn't know that this would only work when {{{:load}}}-ing with the filepath, and not the module name. This was unexpected because the ghc user guide entry for `:load` never seems to hint that behaviour could depend on which is chosen. 3. Also, the guide entry for `:type-at` never says that the argument needs to be a filepath. I think the error messages could also be improved. Point 1 above would've been obvious if the error message contained the text it tried to parse, after the "not an expression", in between the quotes, instead of just presenting an empty string. Also, it's difficult to understand ghci when it says that `:type-at` couldn't "guess that module name" when given src/Lib.hs in the first session, but it could in the second. Anyway, thank you for your attention and the awesome `:type-at` feature. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14780#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC