hawk icon indicating copy to clipboard operation
hawk copied to clipboard

Investigate how ghci implements `:m +Module`

Open gelisam opened this issue 3 years ago • 0 comments

According to [this Reddit comment](GHCi, version 8.10.4: https://www.haskell.org/ghc/ :? for help Loaded GHCi), the ghci command :m +Module brings into scope all the definitions from the given module and also imports all the modules which this module imports.

Similarly, Hawk brings into scope all the definitions exported from the User Prelude and also imports all the modules which the User Prelude imports, and also sets the same language extensions as those specified in LANGUAGE pragmas in the User Prelude.

The way in which hawk currently implements this is by using haskell-src-exts to parse the User Prelude in order to extract this information, and then to pass out to Hint using setImportQ etc. Since Hint and ghci are both thin wrappers around the ghc api, perhaps there is an easier, more maintainable way to implement this feature, by using whichever function from the ghc api which :m +Module is using?

gelisam avatar Aug 18 '21 06:08 gelisam