Closed willbasky closed 6 years ago
If using with stack projects, run stack build ghc-mod
in project directory.
If using with plain Haskell files, try adding location of ghc-mod
exectulable to 'additional path'. I.e. if it's installed in /home/user/.local/bin
, add /home/user/.local/bin
to 'Additional Path Directories'. Note that shell expansion does not work, so no $HOME
or ~
.
UPD: Just to be clear,
$ stack exec which ghc-mod
/home/user/.local/bin/ghc-mod
should translate into
I have added ghc-mod
exectulable to 'additional path' as you wrote and nothing changed.
Oh, wait, I didn't notice the title. If you're getting "Error: Got neither type nor info" it usually means that source doesn't typecheck for whatever reason (syntax errors, really bad type errors etc)
i got it. i checked directly in ghci and it show:
ghc-mod type file.hs 60 1 EXCEPTION: types: The IO action ‘main’ is not defined in module ‘Main’
i tried hover inside file with main defined and it works well.
Why doesn`t it work in file without main?
Because you don't have a module name, so it defaults to Main
. And module Main
has to contain function main
.
Haskell Report 2010, Chapter 5:
A Haskell program is a collection of modules, one of which, by convention, must be called
Main
and must export the valuemain
. The value of the program is the value of the identifiermain
in moduleMain
, which must be a computation of typeIO τ
for some typeτ
(see Chapter 7). When the program is executed, the computationmain
is performed, and its result (of typeτ
) is discarded.
Additionally, section 5.1 in the same chapter:
An abbreviated form of module, consisting only of the module body, is permitted. If this is used, the header is assumed to be
module Main(main) where
.
Thank you! It helps to improve haskell`s skills!
@lierdakil This happened multiple times on my machine. What helped was commenting out/in code or just pressing save multiple times so that it re-analyzes stuff. It is very flaky and doesn't seem to have anything to do with the code not building. This time I even restarted Atom and it was still showing "Error: Got neither type nor info".
@razvan-panda please don't hijack old issues. As for your problem, check developer console for warnings, there are probably a lot of those from ghc-mod.
@lierdakil I only posted here since the title is the same problem - and it is not currently fixed.
If by developer console you mean the JavaScript one you get from View -> Developer -> Toggle Developer Tools then yes, there are a bunch of ghc-mod errors/warnings there.
I will create a ticket when I have a minimal way to reproduce the flakiness - not seeing any obvious patterns yet.
Linux Mint 18, atom 1.21.1, ghc-mod installed with stack, other atom plugin for haskell installed also.
GHC Mode Path: default, additional path: empty.
How to get type or info on hover? Where to search mistake?