hsdev
hsdev copied to clipboard
Include re-exports in symbol results
After some digging in the source I think I've worked out how to use the symbol command. Quite impressed by how fast these commands run!
For this one, I'm wondering if there's a way to include modules which re-export a symbol? For instance, it seems that no matter what flags you supply, hsdev doesn't tell you that MVar is located in the Control.Concurrent module. Generally, it seems people would rather import MVar from there than GHC.MVar.
% hsdev symbol MVar --exact --module Control.Concurrent
[
{
"id": {
"name": "MVar",
"module": {
"location": {
"dirs": [
"/Users/me/.stack/programs/x86_64-osx/ghc-8.6.5/lib/ghc-8.6.5/base-4.12.0.0"
],
"exposed": true,
"name": "GHC.MVar",
"package": "base-4.12.0.0"
},
"name": "GHC.MVar"
}
},
"docs": "An MVar (pronounced \"em-var\") is a synchronising variable, used\nfor communication between concurrent threads. It can be thought of\nas a box, which may be empty or full.",
"info": {
"args": [
"a"
],
"what": "data",
"ctx": []
}
}
]
I'm afraid there's no such command now. But it's very easy to add. Take a look at data/hsdev.sql, where you can see schema of sqlite db underneath.
To find all modules, that exports MVar you can open db with sqlite3 and run this command:
$ sqlite3 '~\AppData\Local\Sublime Text 3\Cache\SublimeHaskell\hsdev\hsdev.db'
sqlite3> select m.name, s.name from modules as m, symbols as s, exports as e where m.id == e.module_id and s.id == e.symbol_id and s.name == 'MVar';
Control.Concurrent|MVar
Control.Concurrent.MVar|MVar
GHC.MVar|MVar
GHC.MVar|MVar
Control.Concurrent.Compat|MVar
Control.Concurrent.Compat.Repl|MVar
Control.Concurrent.MVar.Compat|MVar
Control.Concurrent.MVar.Compat.Repl|MVar
Control.Concurrent.Extra|MVar
Control.Concurrent.Lifted|MVar
Control.Concurrent.MVar.Lifted|MVar
Data.Primitive.MVar|MVar
Data.Primitive.MVar|MVar
(there're duplicated outputs because there're two different MVar's (data and constructor)
Maybe we could add an --exports flag to the symbol command that includes these?
I think we can :) I'll try to find some time on weekend