dense-analysis / dense-analysis/ale

Haskell Module import wonkiness with "stack new"-built project

Open
#2,715 0 comments 4 reactions 0 assignees View on GitHub
bug
Dominant language
Vim Script
Stars
14k
Forks
1.5k
Avg merge
17h 49m
Merged PRs (30d)
1

Description

These sorts of errors happen with the default project generated by `stack new ${project_name}`.

Example directory structure:

```
.
├── ChangeLog.md
├── LICENSE
├── README.md
├── Setup.hs
├── app
│   └── Main.hs
├── package.yaml
├── src
│   └── Lib.hs
├── stack.yaml
├── stack.yaml.lock
├── test
│   └── Spec.hs
└── tooling.cabal
```

VI version:

```
VIM - Vi IMproved 8.1 (2018 May 18, compiled Aug 16 2019 02:18:16)
macOS version
Included patches: 1-1850
Compiled by Homebrew
```

Stack version (ouput from `stack --version`):

```
Version 2.1.3, Git revision 0fa51b9925decd937e4a993ad90cb686f88fa282 (7739 commits) x86_64 hpack-0.31.2
```

Operating system (output from `uname -a`):

```
Darwin myhost.local 18.7.0 Darwin Kernel Version 18.7.0: Thu Jun 20 18:42:21 PDT 2019; root:xnu-4903.270.47~4/RELEASE_X86_64 x86_64
```

And finally output from `:ALEInfo` executed in app/Main.hs:

```
Current Filetype: haskell
Available Linters: ['cabal_ghc', 'ghc', 'ghc_mod', 'hdevtools', 'hie', 'hlint', 'stack_build', 'stack_ghc']
Linter Aliases:
'cabal_ghc' -> ['cabal-ghc']
'ghc_mod' -> ['ghc-mod']
'stack_build' -> ['stack-build']
'stack_ghc' -> ['stack-ghc']
Enabled Linters: ['cabal_ghc', 'ghc', 'ghc_mod', 'hdevtools', 'hie', 'hlint', 'stack_build', 'stack_ghc']
Suggested Fixers:
'brittany' - Fix Haskell files with brittany.
'floskell' - Fix Haskell files with floskell.
'hfmt' - Fix Haskell files with hfmt.
'hlint' - Refactor Haskell files with hlint.
'remove_trailing_lines' - Remove all blank lines at the end of a file.
'stylish-haskell' - Refactor Haskell files with stylish-haskell.
'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
Linter Variables:
let g:ale_haskell_cabal_ghc_options = '-fno-code -v0'
let g:ale_haskell_ghc_mod_executable = 'ghc-mod'
let g:ale_haskell_ghc_options = '-fno-code -v0'
let g:ale_haskell_hdevtools_executable = 'hdevtools'
let g:ale_haskell_hdevtools_options = '-g -Wall'
let g:ale_haskell_hie_executable = 'hie'
let g:ale_haskell_hlint_executable = 'hlint'
let g:ale_haskell_hlint_options = ''
let g:ale_haskell_stack_build_options = '--fast'
let g:ale_haskell_stack_ghc_options = '-fno-code -v0'
Global Variables:
let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'normal'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let g:ale_linters_explicit = 0
let g:ale_list_vertical = 0
let g:ale_list_window_size = 8
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_lsp_root = {}
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 1
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 1
let g:ale_sign_error = '>>'
let g:ale_sign_info = '--'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = '>>'
let g:ale_sign_style_warning = '--'
let g:ale_sign_warning = '--'
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
Command History:
(executable check - success) cabal
(finished - exit code 1) ['/bin/sh', '-c', 'cd ''/Users/ricorodriguez/Haskell/tooling/app'' && cabal exec -- ghc -fno-code -v0 ''/var/folders/wt/xh46t1fx79n2xhxlx74q0t680000gn/T/v7PJhQC/5/Main.hs''']
<<>>
Warning: The exec command is a part of the legacy v1 style of cabal usage.
Please switch to using either the new project style and the new-exec command
or the legacy v1-exec alias as new-style projects will become the default in
the next version of cabal-install. Please file a bug if you cannot replicate a
working v1- use case with the new-style commands.
For more information, see: https://wiki.haskell.org/Cabal/NewBuild
/var/folders/wt/xh46t1fx79n2xhxlx74q0t680000gn/T/v7PJhQC/5/Main.hs:6:8: error:
Variable not in scope: someFunc :: IO ()
|
6 | main = someFunc
| ^^^^^^^^
<<>>
(executable check - success) ghc
(finished - exit code 1) ['/bin/sh', '-c', 'ghc -fno-code -v0 ''/var/folders/wt/xh46t1fx79n2xhxlx74q0t680000gn/T/v7PJhQC/6/Main.hs''']
<<>>
/var/folders/wt/xh46t1fx79n2xhxlx74q0t680000gn/T/v7PJhQC/6/Main.hs:6:8: error:
Variable not in scope: someFunc :: IO ()
|
6 | main = someFunc
| ^^^^^^^^
<<>>
(executable check - failure) ghc-mod
(executable check - failure) hdevtools
(executable check - success) hie
(executable check - failure) hlint
(executable check - success) stack
(finished - exit code 0) ['/bin/sh', '-c', 'stack build --fast']
<<>>
(finished - exit code 1) ['/bin/sh', '-c', 'cd ''/Users/ricorodriguez/Haskell/tooling/app'' && stack ghc -- -fno-code -v0 ''/var/folders/wt/xh46t1fx79n2xhxlx74q0t680000gn/T/v7PJhQC/8/Main.hs''']
<<>>
/var/folders/wt/xh46t1fx79n2xhxlx74q0t680000gn/T/v7PJhQC/8/Main.hs:3:1: error:
Ambiguous module name ‘Lib’:
it was found in multiple packages: libiserv-8.6.3 tooling-0.1.0.0
|
3 | import Lib
| ^^^^^^^^^^
<<>>
(started) ['/bin/sh', '-c', '''hie'' --lsp']
```

I get the following errors in app/Main.hs no matter which directory I execute `vi` from:
`error| Ambiguous module name ‘Lib’: it was found in multiple packages:`
`error| Variable not in scope: someFunc :: IO () |6 | main = someFunc`

although when I `vi Main.hs` from inside the app/ directory, I get the "Variable not in scope" message twice.

This could be related to https://github.com/dense-analysis/ale/issues/2554.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.