-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ new ] add docs-for-type-of IDE command #3371
base: main
Are you sure you want to change the base?
Conversation
@@ -199,6 +199,10 @@ process (MakeWith l n) | |||
= replWrap $ Idris.REPL.process (Editing (MakeWith False (fromInteger l) (UN $ mkUserName n))) | |||
process (DocsFor n modeOpt) | |||
= replWrap $ Idris.REPL.process (Doc $ APTerm (PRef EmptyFC (UN $ mkUserName n))) | |||
process (DocsForTypeOf n modeOpt) | |||
= do (REPL (TermChecked itm ity)) <- Idris.REPL.process $ (Check $ PRef replFC (UN $ mkUserName n)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REPL constructor is an error here, will be pushed with other fixes
process (DocsForTypeOf n modeOpt) | ||
= do (REPL (TermChecked itm ity)) <- Idris.REPL.process $ (Check $ PRef replFC (UN $ mkUserName n)) | ||
| err => pure $ REPL $ REPLError (pretty0 $ show err) | ||
process (DocsFor (prettyBy Syntax ity) modeOpt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea how to work with ity properly in this place. Convert ity : IPTerm
to PTerm
somehow?
If you chase various definitions you can see: -- In Idris.IDEMode.REPL
process (DocsFor n modeOpt)
= replWrap $ Idris.REPL.process (Doc $ APTerm (PRef EmptyFC (UN $ mkUserName n))) -- Idris.REPL
process (Doc dir)
= do doc <- getDocs dir
pure $ PrintedDoc doc -- In Idris.Doc.String
getDocs (APTerm ptm) = getDocsForPTerm ptm
(...)
getDocsForPTerm (PRef fc name) = getDocsForName fc name MkConfig So if you can get the name of the type's head constructor you should be golden with -- If you want to go under Pis in case the term is a function that's not fully applied
-- In Core.TT.Views
underPis : (n : Int) -> Env Term vars -> Term vars ->
(bnds : SnocList Name ** (Env Term (bnds <>> vars), Term (bnds <>> vars)))
-- To grab the head of the application (after stripping off types if necessary)
-- In Core.TT.Term
getFn : Term vars -> Term vars And you can then check that whatever you get back from -- In Core.Env
mkEnv : FC -> (vs : List Name) -> Env Term vs
-- In TTImp.Unelab
unelab : {vars : _} ->
{auto c : Ref Ctxt Defs} ->
Env Term vars ->
Term vars -> Core IRawImp |
Description
I've decided to try to implement the issue #3157 in this PR. Right now it's a draft as long as I haven't resolved several issues:
IPTerm
representation of it. Thus, for callingprocess (DocsFor ? modeOpt)
I need to use either already done function, or to extract the type name somehowShould this change go in the CHANGELOG?
Definitely yes as a feature implementation
implementation, I have updated
CHANGELOG_NEXT.md
(and potentially alsoCONTRIBUTORS.md
).