[m-users.] A perldoc-style tool (but no hoogle yet)

Julian Fondren jfondren at minimaltype.com
Mon Sep 23 13:31:33 AEST 2019

Hello list,

I've got a tool for quick access to Mercury documentation on Unix
systems, with perldoc as the inspiration. For example, if you're
suddenly not sure which parameter of list.member/2 is which,

   $ mmc-doc list member
       % member(Elem, List):
       % True iff `List' contains `Elem'.
   :- pred member(T, list(T)).
   :- mode member(in, in) is semidet.
   :- mode member(out, in) is nondet.

       % member(Elem, List, SubList):
       % True iff `List' contains `Elem', and `SubList' is a suffix of 
       % beginning with `Elem'.
       % Same as `SubList = [Elem | _], append(_, SubList, List)'.
   :- pred member(T::out, list(T)::in, list(T)::out) is nondet.

in a separate terminal can remind you. Other usage:

   $ mmc-doc map

This opens the 'map' module doc in a web browser, downloading it once if
necessary. Currently mmc-doc tries to use 'w3m' and falls back to
'xdg-open', and the browser can be overridden with $WWWPAGER

   $ mmc-doc -l map

This opens your installed library reference in a web browser, focused on
the start of the map documentation.

   $ mmc-doc -i ref

This opens your installed language reference.

   $ mmc-doc io '' -t type -g

This is a little bit arcane, but displays all of the types in the io
module. 'io' is the module, '' is the thing to search for (the empty
string), -g makes it search by substring, so that the empty string will
always be found, and '-t type' restricts matches to ':- type'

The tool is a bit hacky, and certainly isn't enough to duplicate a
'hoogle'-like tool since it doesn't actually parse the interfaces. It
can't find a type::mode pair in a non-unified predicate declaration, for
example. But I've already found it to be pretty useful. (looking up
list.member params is a real example.)

You can get it with mmc-get or at https://github.com/jrfondren/mmc-doc

Currently it needs 'wget' to get documentation.

More information about the users mailing list