[m-users.] Announce: Mercury Supplementary Libraries

Volker Wysk post at volker-wysk.de
Sat Nov 30 02:03:14 AEDT 2024


Hi.

I've released my supplementary libraries for Mercury. In them, I've
collected some useful general-purpose code that I've written over time. They
provide things that aren't available in the standard libraries:


dirsupp.m: This complements the standard dir library. This contains
predicates for reading directory contents, dealing with the working
directory and for making directories.

iosupp.m: This complements the standard io library. This introduces a new
error type iosupp.error, which consists of an io.error and a filename/path.
The io.error type is unsuitable for throwing it as an exception, because the
path isn't included in it. The predicates in the msupp library all use this
type for returning or throwing errors.

There also are routines for parsing and normalising paths. They remove
duplicated slashes and "." path components. They also try to remove ".."
components. The problem with them is that they can't be simply be removed
along with the preceding path component, when this is a symlink.

Then there is code for quoting strings for the shell and otherwise. And
whole files can be read. This is the same as io.read_named_file_as_string,
but iosupp.error is used instead of io.error. They they can also be written.

posix.m: This contains bindings for POSIX system library calls. This is
similar to Melbourne Mercury's extra library "posix", except that the
functionality is integrated in the iosupp library (see above), and therefore
in
the Mercury standard io library. This mostly concerns error handling. Most
of the posix extra library calls are available here.

There are routines for linking/unlinking/renaming files, the exec... family
of functions, forking and waiting for child processes, extended attributes,
file permissions, getting the system time, the stat() library call,
realpaths and exiting.

stringsupp.m: This only contains predicates for getting all the prefixes of
a string.

unicode.m: This contains a few bindings to unicode related things from the
GNU glib library. Such as character classification and unicode-aware string
collation.


It's here:
https://gitlab.com/volkerwysk/msupp

Happy hacking, 
Volker


More information about the users mailing list