ABSTRACT
Existing ML-like languages guarantee type-safety, ensuring memory safety and protecting the invariants of abstract types, but only within single executions of single programs. Distributed programming is becoming ever more important, and should benefit even more from such guarantees. In previous work on theoretical calculi and the Acute prototype language we outlined techniques to provide them for simple languages.In this paper we put these ideas into practice, describing the HashCaml extension to the OCaml bytecode compiler, which supports type-safe and abstraction-safe marshalling, together with related naming constructs. Our contribution is threefold: (1) We show how to define globally meaningful runtime type names for key OCaml type constructs that were not covered in our previous work, dealing with the generativity issues involved: user-defined variant and record types, substructures, functors, arbitrary ascription, separate compilation, and external C functions. (2) We support marshalling within polymorphic functions by type-passing, requiring us to build compositional runtime type names and revisit the OCaml relaxed value restriction. We show that with typed marshalling one must fall back to the SML97 value restriction. (3) We show how the above can be implemented with reasonable performance as an unintrusive modification to the existing OCaml language, implementation, and standard libraries. An alpha release of HashCaml, capable of bootstrapping itself, is available, along with an example type-safe distributed communication library written in the language.
- Java™ object serialization specification 1.5.0. Technical report, Sun Microsystems, Apr. 2004.]]Google Scholar
- M. Abadi, L. Cardelli, B. Pierce, and G. Plotkin. Dynamic typing in a statically typed language. ACM TOPLAS, 13(2):237--268, 1991.]] Google ScholarDigital Library
- M. Abadi, L. Cardelli, B. Pierce, and D. Rémy. Dynamic typing in polymorphic languages. J. Functional Programming, 5(1):111--130, 1995.]]Google ScholarCross Ref
- G. Bierman, M. Hicks, P. Sewell, G. Stoyle, and K. Wansbrough. Dynamic rebinding for marshalling and update, with destruct-time λ. In Proc. ICFP, 2003.]] Google ScholarDigital Library
- J. Billings. A bytecode compiler for Acute, 2005. Computer Science Tripos Part II Dissertation, University of Cambridge.]]Google Scholar
- J. Billings, P. Sewell, M. Shinwell, and R. Strniša. HashCaml 3.09.1-alpha-785. http://www.cl.cam.ac.uk/users/pes20/hashcaml, Apr. 2006.]]Google Scholar
- J. Billings, P. Sewell, M. Shinwell, and R. Strniša. The implementation of HashCaml, Apr. 2006. http://www.cl.cam.ac.uk/users/pes20/hashcaml.]]Google Scholar
- L. Cardelli. Amber. In Combinators and Functional Programming Languages, LNCS 242, pages 21--70, 1986.]] Google Scholar
- K. Crary, S. Weirich, and G. Morrisett. Intensional polymorphism in type erasure semantics. In Proc. ICFP, pages 301--313, 1998.]] Google ScholarDigital Library
- P.-M. Deniélou and J. J. Leifer. Abstraction preservation and subtyping in distributed languages, Sep. 2006. In Proc. ICFP, 2006.]] Google ScholarDigital Library
- D. Dreyer, K. Crary, and R. Harper. A type theory for higher-order modules. In Proc. POPL, 2003.]] Google ScholarDigital Library
- C. Fournet, F. L. Fessant, L. Maranget, and A. Schmitt. The JoCaml language beta release documentation and user's manual, Jan. 2001. http://moscova.inria.fr/jocaml/.]]Google Scholar
- J. Furuse. Extensional Polymorphism: Theory and Applications. PhD thesis, Université Paris 7, 2002.]]Google Scholar
- J. Furuse and P. Weis. Entrées/sorties de valeurs en Caml. In J. Francophones des Langages Applicatifs, 2000.]]Google Scholar
- J. Garrigue. Relaxing the value restriction. In International Symposium on Functional and Logic Programming, Nara, LNCS 2998, Apr. 2004.]]Google ScholarCross Ref
- J. Garrigue. Personal communication, Sept. 2005.]]Google Scholar
- B. Goldberg. Tag-free garbage collection for strongly typed programming languages. Sigplan, 26(6):165--176, 1991.]] Google ScholarDigital Library
- D. Grossman, G. Morrisett, and S. Zdancewic. Syntactic type abstraction. ACM TOPLAS, 22(6):1037--1080, 2000.]] Google ScholarDigital Library
- R. Harper and M. Lillibridge. A type-theoretic approach to higher-order modules with sharing. In Proc. 21st POPL, 1994.]] Google ScholarDigital Library
- R. Harper and B. C. Pierce. Design issues in advanced module systems, 2005. Chapter in Advanced Topics in Types and Programming Languages, B. C. Pierce, editor.]]Google Scholar
- G. Henry, M. Mauny, and E. Chailloux. Typer la désérialisation sans sérialiser les types. In Journées Francophones des Langages Applicatifs, Jan. 2006.]]Google Scholar
- J. J. Leifer, G. Peskine, P. Sewell, and K. Wansbrough. Global abstraction-safe marshalling with hash types. In Proc. ICFP, 2003.]] Google ScholarDigital Library
- X. Leroy. Manifest types, modules, and separate compilation. In Proc. 21st POPL, 1994.]] Google ScholarDigital Library
- X. Leroy et al. Objective Caml 3.09.1. http://caml.inria.fr, Jan. 2006.]]Google Scholar
- X. Leroy and M. Mauny. Dynamics in ML. Journal of Functional Programming, 3(4):431--463, 1993.]]Google ScholarCross Ref
- R. Milner, J. Parrow, and D. Walker. A calculus of mobile processes, Parts I + II. Information and Computation, 100(1):1--77, 1992.]] Google ScholarDigital Library
- B. C. Pierce and D. N. Turner. Pict: A programming language based on the pi-calculus. In Proof, Language and Interaction: Essays in Honour of Robin Milner, pages 455--494. MIT Press, 2000.]] Google ScholarDigital Library
- J. H. Reppy. Concurrent Programming in ML. Cambridge University Press, 1999.]] Google ScholarDigital Library
- A. Rossberg. Generativity and dynamic opacity for abstract types. In Proc. 5th PPDP, Aug. 2003.]] Google ScholarDigital Library
- A. Rossberg, D. L. Botlan, G. Tack, T. Brunklaus, and G. Smolka. Alice through the looking glass. In Trends in Functional Programming, Vol. 5, Feb. 2006.]]Google Scholar
- P. Sewell. Modules, abstract types, and distributed versioning. In Proc. 28th POPL, 2001.]] Google ScholarDigital Library
- P. Sewell, J. J. Leifer, K. Wansbrough, M. Allen-Williams, F. Zappa Nardelli, P. Habouzit, and V. Vafeiadis. Acute: High-level programming language design for distributed computation. Design rationale and language definition. Technical Report 605, University of Cambridge Computer Laboratory, Oct. 2004. Also published as INRIA RR-5329. 193pp.]]Google Scholar
- P. Sewell, J. J. Leifer, K. Wansbrough, F. Zappa Nardelli, M. Allen-Williams, P. Habouzit, and V. Vafeiadis. Acute: High-level programming language design for distributed computation. In Proc. ICFP, Sept. 2005.]] Google ScholarDigital Library
- P. Sewell, J. J. Leifer, K. Wansbrough, F. Zappa Nardelli, M. Allen-Williams, P. Habouzit, and V. Vafeiadis. Acute: High-level programming language design for distributed computation. Dec. 2005. Submitted for publication. http://www.cl.cam.ac.uk/users/pes20/acute/paper3.ps.]]Google Scholar
- P. Sewell, P. T. Wojciechowski, and B. C. Pierce. Location-independent communication for mobile agents: a two-level architecture. In Internet Programming Languages, LNCS 1686, pages 1--31, 1999.]] Google ScholarDigital Library
- M. R. Shinwell, A. M. Pitts, and M. J. Gabbay. FreshML: Programming with binders made simple. In Proc. ICFP, 2003.]] Google ScholarDigital Library
- B. Thomsen, L. Leth, and T.-M. Kuo. A Facile tutorial. In CONCUR'96, LNCS 1119, 1996.]] Google ScholarDigital Library
- J. Verlaguet. Acaml: An extension of OCaml with Acute-like marshalling, Oct. 2005. Masters Dissertation.]]Google Scholar
- D. Vytiniotis, G. Washburn, and S. Weirich. An open and shut typecase. In Proc. ACM SIGPLAN Workshop on Types in Language Design and Implementation (TLDI), Jan. 2005.]] Google ScholarDigital Library
- A. K. Wright. Simple imperative polymorphism. Lisp and Symbolic Computation, 8(4):343--355, 1995.]] Google ScholarDigital Library
Index Terms
- Type-safe distributed programming for OCaml
Recommendations
Type-safe run-time polytypic programming
Polytypic programming is a way of defining type-indexed operations, such as map, fold and zip, based on type information. Run-time polytypic programming allows that type information to be dynamically computed – this support is essential in modern ...
Searching for type-error messages
Proceedings of the 2007 PLDI conferenceAdvanced type systems often need some form of type inference to reduce the burden of explicit typing, but type inference often leads to poor error messages for ill-typed programs. This work pursues a new approach to constructing compilers and presenting ...
Refinement kinds: type-safe programming with practical type-level computation
This work introduces the novel concept of kind refinement, which we develop in the context of an explicitly polymorphic ML-like language with type-level computation. Just as type refinements embed rich specifications by means of comprehension principles ...
Comments