In Proc. ACM SIGPLAN Workshop on ML (ML’08), September 2008.
Objective Caml is a flexible, expressive programming language, but for manipulating Unix processes, nothing beats the terseness and clarity of Bourne Shell:
ls *.docx | wc -l
To achieve the same effect in C requires several more lines of
code and, very likely, a glance at the manual page for
readdir().
Despite OCaml's excellent Unix
module, which provides
access
to a wide variety of system calls, a task as simple as counting
the
.docx
files in the current directory is hardly easier
in
OCaml than in C. The code looks largely the same.
Caml-Shcaml addresses this problem by bringing high-level abstractions for Unix systems and shell programming to OCaml. In particular, we take advantage of OCaml's type system to offer statically-checked data pipelines. External Unix processes and internal OCaml stream transducers communicate seamlessly within these pipelines. Shcaml brings other essential systems concepts into the world of typed functional programming as well, including high-level interfaces to Unix facilities for I/O redirection, signal handling, program execution, and subprocess reaping.
© 2008 ACM. This is the author's version of the work. It is posted here by permission of ACM for your personal use. Not for redistribution. The definitive version was published in Proc. ACM SIGPLAN Workshop on ML, 9:79-90, 2008. http://doi.acm.org/10.1145/1411304.1411316