OCommand: A Domain Specific Language for Type Safe Shell Programming in OCaml

We propose a domain-speci c language (DSL), called OCommand, for executing
shell commands from within OCaml programs in a type safe way. OCommand
takes a command speci cation consisting of types of output columns from the
command and effects of command options on the types of the columns, and
generates an OCaml module that contains a command-executing function and
a set of values representing the command options. The command-executing
function takes options as arguments, runs the command, parses the output
lines, and returns them as a list of records. In order to statically-check
existence and types of elds of the output record that can be changed by
command options, we used generalized algebraic data type. With our
implementation constructed by using Camlp4, we successfully handle typical
Unix commands like ls and ps by using OCommand.

Members

Publications