-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTODO
More file actions
76 lines (69 loc) · 3.2 KB
/
Copy pathTODO
File metadata and controls
76 lines (69 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
* done; - not done; / decided against
bug:
- support unqualified constructors
. e.g. NonEmpty((:|))
* Ignore unqualified names if they're already imported from a different
module.
- It wants to import unqualified names defined in the module.
feature:
* support nix-style cabal
I need to get ghc-pkg to see the local packages... is it one of those
hidden files?
. It's .ghc.environment.x86_64-darwin-9.2.5:
clear-package-db
global-package-db
package-db /Users/elaforge/.cabal/store/ghc-9.2.5/package.db
package-db dist-newstyle/packagedb/ghc-9.2.5
package-id hlibgit2-0.18.0.16-inplace
package-id base-4.16.4.0
package-id bndngs-DSL-1.0.25-d82df022
. Since the package db will have multiple packages of the same name,
I need to search the explicit package ids.
. ghc-pkg --unit-id --no-user-package-db --package-db .. \
field pkgname name,exposed,exposed-modules
. But ghc-pkg doesn't let me list packages in fields, I'd have to run it
a bunch of times.
. So, parse the files myself? I would read the *.conf files, but it
would be nicer to read package.cache.
. Where is ghc-pkg source?
import qualified GHC.Unit.Database as GhcPkg
(db_stack, GhcPkg.DbOpenReadOnly, flag_db_stack)
<- getPkgDatabases verbosity GhcPkg.DbOpenReadOnly
GhcPkg.readPackageDbForGhcPkg cache mode
if not reading the cache:
BS.readFile file >>= fmap fst . parsePackageInfo
parseInstalledPackageInfo
readPackageDbForGhcPkg :: Binary pkgs => FilePath -> DbOpenMode mode t
-> IO (pkgs, DbOpenMode mode PackageDbLock)
readPackageDbForGhcPkg "path" DbOpenReadOnly
ambiguous import resolution:
- Ask interactively.
. This requires deeper integration, but vim does have menu selection
support.
- Write a simple tool to analyze existing code and assign priorities
based on how often each is imported.
- When run with a flag, add them all, but commented out, so you can pick
on in the editor. Maybe jump the cursor up there automatically.
- Use haskell-names to guess the module to import based on the function
name: http://documentup.com/haskell-suite/haskell-names
- Use tags to guess based on the function name.
. https://github.com/JonnyRa/vim-himposter
- Or use HIE files to do the same.
automatic unqualified imports:
- any of the haskell-names, tags, or HIE above could do this.
- I'd like a add/removed symbol if it modified an unqualified import list
/ add *all* possible imports, but comment out all but the priority one
. This seems not great because much of the time it guesses right.
. Then I need some notion of certainty.
. Maybe only for local imports? Or local imports where there isn't an
obvious winner, where obvious winner means in the same directory?
/ Use a cabal sandbox if one is present.
- use stack if present
. I think just:
if [ $use_stack ]; then
export GHC_PACKAGE_PATH=$(stack path --ghc-package-path)
PATH=$(stack path --compiler-bin):$PATH
fi
/ Optionally write a cache of the package db.
. No need, most time is spent parsing.
. It's fast enough.