atom-haskell-archive / haskell-ghc-mod

haskell-ghc-mod atom package
https://atom.io/packages/haskell-ghc-mod
MIT License
69 stars 20 forks source link

Error: got neigher type, nor info #226

Closed willbasky closed 6 years ago

willbasky commented 6 years ago

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?

lierdakil commented 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 image

willbasky commented 6 years ago

I have added ghc-mod exectulable to 'additional path' as you wrote and nothing changed.

lierdakil commented 6 years ago

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)

willbasky commented 6 years ago

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?

lierdakil commented 6 years ago

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 value main. The value of the program is the value of the identifier main in module Main, which must be a computation of type IO τ for some type τ (see Chapter 7). When the program is executed, the computation main 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.

willbasky commented 6 years ago

Thank you! It helps to improve haskell`s skills!

freeman42x commented 6 years ago

@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".

lierdakil commented 6 years ago

@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.

freeman42x commented 6 years ago

@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.