Scoped Typed Holes
Motivation
Sometimes I know that a module defines a function, but I've forgotten the name. The concrete example is this:
import Database.Persist.Sql as Sql
-- snip... lots of code
someFunc =<< _f userId
-- etc...
The inferred type of _f
is UserId -> SqlPersistT m (Entity User)
. There are too many terms in scope and for whatever reason GHC does not suggest any valid hole fits.
But I know the function is in Database.Persist.Sql
! So I ideally would be able to write:
someFunc =<< Sql._f userId
Which should limit the scope of possible hole fits to those imported from Database.Persist.Sql
. Right now, it just fails with an error message:
lumi-mojo> /home/matt/Projects/lumi/mojo/lib/Lumi/Database/API/Zendesk.hs:574:8: error:
lumi-mojo> Not in scope: ‘Sql._f’
lumi-mojo> Perhaps you meant one of these:
lumi-mojo> data constructor ‘Sql.Eq’ (imported from Database.Persist.Sql),
lumi-mojo> data constructor ‘Sql.Ge’ (imported from Database.Persist.Sql),
lumi-mojo> data constructor ‘Sql.Gt’ (imported from Database.Persist.Sql)
lumi-mojo> Module ‘Database.Persist.Sql’ does not export ‘_f’.
lumi-mojo> |
lumi-mojo> 574 | what = Sql._f
lumi-mojo> | ^^^^^^
lumi-mojo>
Proposal
I'd like for ModuleName._hole_expression
to go through the typed hole search if the term isn't exported from the module, limiting search to items exported from the module.