-
Notifications
You must be signed in to change notification settings - Fork 401
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
utop + jbuilder integration #114
Comments
Do you mean without doing |
Indeed, this feature would be super useful and would make |
So the following can be done quite easily: if you run For the warnings it's a bit more complicated as jbuilder currently just knows about flags and not warnings specifically. Moreover once we'll get warnings we'll want other options such as -strict-blah as well and the toplevel doesn't understand all ocamlc flags. We'd need to hack something in utop. Jbuilder could only pass an approximation as it does for merlin at the moment. |
I'd be interested on working on that @diml. Could you give this a quick sketch? |
Sure. One question is whether we want to link custom utops or simply call utop with the right cmas on the command line. I think the former is slightly simpler to implement so we can try that. This is what needs to be done:
|
@diml thanks Regarding 1, Seems like this would limit the support to loading a single library (and its dependencies at once). While not awful, loading more than 1 library (usually all of them) is a common enough use case. Anyway we can support that? I realize that this might require generating build rules from the command invocation itself but perhaps it's worth it? This isn't an essential thing to worry about now though Some bike shedding about 3: do you mean a |
Yh, I was actually thinking of linking statically all the libraries defined in the current directory.
What do you mean by generating build rules from the command invocation?
Yh, I agree a |
Never mind. Initially, I thought you meant that every .utop.ml would only be able produce a top level for 1 library. So I thought to support multiple library we'd need to generate a more complex .utop.ml to load multiple libraries. And obviously that would depend on which library requested a top level for. We don't need any of this stuff if we just load 1 library for now. |
@diml One more thing to consider: It would be nice if there was a way to automatically load libraries that install toplevel printers. In findlib, this can be done with predicates, e.g. |
Possibly, but frankly this mechanism is a bit heavy. Now that we have annotations, we should handle toplevel printers using annotations and let the toplevel use them automatically. This would avoid having to write these boilerplate libraries manually |
@rgrinberg You should always allow the user to load the library without loading its toplevel support so the The scheme I implemented in all my packages doesn't need Regarding the scheme I propose you can have a look how it is implemented for Note that |
Could you expand on this a little bit? I don't know enough about the toplevel to know how this would work.
Shouldn't it be easy enough to have findlib add another In any case, your proposal seems good and I don't mind implementing this without relying on findlib. But it should be easy enough for users to open a toplevel with all the pretty printers installed, so I think we'd still need a directive that respects this init scheme. |
odig's toplevel printers will do this automatically unless prevented via the |
Hmm, but I thought the goal was to get rid of these Btw, I was completely unaware that odig had anything to do with toplevels until now. But it would be good if jbuilder was compatible with odig in general. Is there anything that needs to be done there? |
For instance you could have an annotation like this in your mli files: val pp : Format.formatter -> t -> unit [@@toplevel_printer] and then the toplevel would automatically do Otherwise I'm happy to use the same convention as odig. |
Yes because of the loading convention. Follow and read the links to documentation in my earlier message. |
This was a fixed a long time ago. There are more specific tickets on how to make toplevels work better. |
While working on Real World OCaml, @yminsky and I were discussing the possibility of integrating utop directly into jbuilder so that the interactive toplevel had the same set of warnings as those jbuilder uses. This would make our interactive examples much easier to work with.
I imagine something like
jbuilder top
that drops the user into a utop instance that has access to the same context asjbuilder exec
, with locally built modules and so on available there.The text was updated successfully, but these errors were encountered: