Abstract
This paper proposes a new approach to embedding shell scripts in an ML-style typed functional language. Instead of representing each construct in the shell script language as a typed component, the proposed approach treats an untyped shell script program as a typed function. The programmer writes a shell script and specifies its type according to the intention of his/her script. The ML compiler automatically generates glue codes that serialize and de-serialize input and output data. With this embedding mechanism, an ML programmer can enjoy the full benefits of shell programming directly within an ML program. The proposed approach has been implemented in our SML# compiler.
Similar content being viewed by others
Explore related subjects
Discover the latest articles, news and stories from top researchers in related subjects.References
Abadi, M., Cardelli, L., Pierce, B. C. and Plotkin, G. D., “Dynamic typing in a statically typed language,” ACM Trans. Program. Lang. Syst., 13, 2, pp. 237–268, 1991.
Heller, A. and Tov, J. A., “Caml-shcaml: an OCaml library for Unix shell programming,” in Proc. of the ACM Workshop on ML, 2008, Victoria, BC, Canada, September 21, 2008 (Sumii, E ed.), pp. 79–90 ACM, 2008.
“ISO/IEC 9945:2009” Information technology - Portable Operating System Interface (POSIX \({^{\textregistered}}\)) Base Specifications, 7, 2009.
Kahn, G., “Natural semantics,” in Proc. Symposium on Theoretical Aspects of Computer Science, pp. 22–39, Springer Verlag, 1987.
Kamath, Y. H. and Matthews, M. M., “Implementation of an fp-shell,” IEEE Trans. Software Eng., 13, 5, pp. 532–539, 1987.
McDonald, C. S., “fsh - a functional UNIX command interpreter,” Softw., Pract. Exper., 17, 10, pp. 685–700, 1987.
Ohori, A. and Kato, K., “Semantics for communication primitives in a polymorphic language,” in POPL ’93: Proc. of the 20th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pp. 99–112, 1993.
Pessaux, F. and Rouaix, F., “The CamlTk interface,” Technical report, INRIA Rocquencourt, 1996.
Plasmeijer, R. and van Weelden, A., “A functional shell that operates on typed and compiled applications,” Advanced Functional Programming, 5 \({^{th}}\) International School, AFP 2004, Tartu, Estonia, August 14–21, 2004, Revised Lectures, LNCS, 3622, pp. 245–272, Springer, 2005.
Shivers, O., “A Scheme shell,” Technical Report LCS/TR-635, Massachusetts Institute of Technology, 1994.
Shultis, J., “A functional shell,” in Proc. of the 1983 ACM SIGPLAN symposium on Programming language issues in software systems, SIGPLAN Not., 18, 6, pp. 202–211, ACM, New York, NY, USA, 1983.
Siek, J. G. and Taha, W., “Gradual typing for functional languages,” in Scheme and Functional Programming Workshop, pp. 81–92, 2006.
SML# compiler. http://www.pllab.riec.tohoku.ac.jp/smlsharp/.
Author information
Authors and Affiliations
Corresponding author
Additional information
A preliminary version of this work appeared in pre-proc. of Symposium on Trends in Functional Programming, 2014.
About this article
Cite this article
Ueno, K., Ohori, A. A Foreign Language Interface from ML to Shell. New Gener. Comput. 34, 239–256 (2016). https://doi.org/10.1007/s00354-016-0303-1
Received:
Revised:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00354-016-0303-1