dbuenzli / down

An OCaml toplevel (REPL) upgrade
http://erratique.ch/software/down
ISC License
81 stars 3 forks source link

Tab completion for topfind #19

Open cfcs opened 5 years ago

cfcs commented 5 years ago

1) It would be nice to have tab completion for topfind, not sure if that is out of scope for down, but it would make my life easier, I imagine something like this (pulling from #list):

   # #require "ptime.[TAB]
   ptime.clock         (version: 0.8.5)
   ptime.clock.os      (version: 0.8.5)
   ptime.clock.os.top  (version: 0.8.5)
   # #require "ptime.clock
   # #require "ptime.clock.os.t[TAB]
   # #require "ptime.clock.os.top";;

2) Additionally, I currently get tab completion for (for example) Ptime_clock, but when I try to use it, I get:

   # Ptime_clock.no[TAB]
     Ptime_clock.now : unit -> Ptime.t
     Ptime_clock.now_d_ps : unit -> int * int64
   # Ptime_clock.now ();;
   Error: Unbound module Ptime_clock

Would it be possible to determine if Ptime_clock.now was currently in scope, and if not, print the required package name as a suggestion, either in the tab completion or when a line referencing it is executed?

dbuenzli commented 5 years ago

Personally I'm no longer using topfind, the cognitive burden of remembering in which ocamlfind package the module I want to use lives is is too high, so I simply load modules via omod.

Moreover both points becomes moot if we can get this to work https://github.com/b0-system/odig/issues/10#issuecomment-315884371 (replace Odig mentions there by Omod). In other words we can automatically (or after manual confirmation) load modules and their dependencies on the fly when users try to access them. But for it to be made to work seamlessly it needs fixes upstream which I would like to encourage to people to consider https://github.com/ocaml/ocaml/issues/7589.

So no plans for topfind sorry. But if you can cook something up that is not too invasive I might consider it for inclusion.

In general completion improvements are tracked in https://github.com/dbuenzli/down/issues/11

cfcs commented 5 years ago

@dbuenzli Ah, I didn't know about omod and am not tied to topfind by any means; I'd be happy to use omod instead. Is this how you would use it? (either I'm using it wrong or something seems slightly broken)

# Omod.load "Unix";;
[INC] /home/user/.opam/4.07.1+afl/lib/ocaml
[ERROR] include /home/user/.opam/4.07.1+afl/lib/ocaml:
Unknown exception:
Invalid_argument

- : bool = false
dbuenzli commented 5 years ago

Try to export OCAMLRUNPARAM='b' to get a better stacktrace and report any problems on the omod bug tracker and not here, also please try to confirm the error with a stock 4.07.1 so that this can be pinned down.

dbuenzli commented 5 years ago

@cfcs I'm really interested in having an issue and repro here for what you witnessed.