idris-lang / Idris2

A purely functional programming language with first class types
https://idris-lang.org/
Other
2.53k stars 380 forks source link

[ elab ] Let elab scripts access visibility modifiers #3235

Closed jacobjwalters closed 8 months ago

jacobjwalters commented 8 months ago

Description

This is a small extension to the elaborator that allows an elab script to query the visibility of a declaration.

As a quick example, given the following file:

private foo : Bar
export baz : Quux
namespace A
  public export foo : Bar

We can get do the following in the REPL:

> :let %language ElabReflection
> %runElab getVis `{foo}
[(NS (MkNS ["A", "Main"]) (UN (Basic "foo")), Public),
 (NS (MkNS ["Main"]) (UN (Basic "foo")), Private)]
> %runElab getVis `{baz}
[(NS (MkNS ["Main"]) (UN (Basic "baz")), Export)]

The visibilities of all declarations matching the given Name are returned.

Should this change go in the CHANGELOG?

andrevidela commented 8 months ago

I don't know if I can do this for you, but if you rebase from main you should be able to get all the tests pass

andrevidela commented 8 months ago

LGTM