Abstract
This is the year 2008 and ML-style exceptions are everywhere. Most modern languages, whether academic or industrial, feature some variant of this mechanism. Languages such as Java even feature static coverage-checking for such exceptions, something not available for ML languages, at least not without resorting to external tools.
In this document, we demonstrate a design principle and a tiny library for managing errors in a functional manner, with static coverage-checking, automatically-inferred, structurally typed and hierarchical exceptional cases, with a reasonable run-time penalty. Our work is based on OCaml and features monads, polymorphic variants, compile-time code rewriting and trace elements of black magic.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Blume, M., Acar, U.A., Chae, W.: Exception handlers as extensible cases. In: Ramalingam, G. (ed.) APLAS 2008. LNCS, vol. 5356, pp. 273–289. Springer, Heidelberg (2008)
Warren Burton, F.: Type extension through polymorphism. ACM Trans. Program. Lang. Syst. 12(1), 135–138 (1990)
Carette, J., Kiselyov, O.: Multi-stage programming with functors and monads: Eliminating abstraction overhead from generic code. In: Glück, R., Lowry, M. (eds.) GPCE 2005. LNCS, vol. 3676, pp. 256–274. Springer, Heidelberg (2005)
Carette, J., van Dijk, L.E., Kiselyov, O.: Syntax extension for monads in ocaml, http://www.cas.mcmaster.ca/~carette/pa_monad/
Czarnecki, K., O’Donnell, J.T., Striegnitz, J., Taha, W.: Dsl implementation in metaocaml, template haskell, and c++. In: Domain-Specific Program Generation, pp. 51–72 (2003)
Fluet, M., Pucella, R.: Phantom types and subtyping. In: TCS 2002: Proceedings of the IFIP 17th World Computer Congress - TC1 Stream / 2nd IFIP International Conference on Theoretical Computer Science, Deventer, The Netherlands, pp. 448–460. Kluwer, B.V., Dordrecht (2002)
Garrigue, J.: Programming with polymorphic variants. In: ML Workshop (1998)
Garrigue, J.: Relaxing the value restriction. In: Kameyama, Y., Stuckey, P.J. (eds.) FLOPS 2004. LNCS, vol. 2998, pp. 196–213. Springer, Heidelberg (2004)
Guyer, S.Z., Lin, C.: An annotation language for optimizing software libraries. In: DSL, pp. 39–52 (1999)
Holt, R.C., Wortman, D.B.: A sequence of structured subsets of pl/i. SIGCSE Bull. 6(1), 129–132 (1974)
Marlow, S.: An extensible dynamically-typed hierarchy of exceptions. In: Haskell 2006: ACM SIGPLAN Workshop on Haskell, Portland, Oregon, ACM Press, New York (2006)
Milner, R., Tofte, M., Macqueen, D.: The Definition of Standard ML. MIT Press, Cambridge (1990)
Mitchell, N., Runciman, C.: A static checker for safe pattern matching in Haskell. In: Trends in Functional Programming, vol. 6. Intellect (February 2007)
Pessaux, F.: Détection statique d’exceptions non rattrapées en Objective Caml. PhD thesis, Université Pierre & Marie Curie - Paris 6 (2000)
Ramsey, N.: Eliminating spurious error messages using exceptions, polymorphism, and higher-order functions. The Computer Journal 42(5), 360–372 (1999)
Rossberg, A., Le Botlan, D., Tack, G., Brunklaus, T., Smolka, G.: Alice through the looking glass. In: Trends in Functional Programming, vol. 5, pp. 77–96 (2006)
Talpin, J.-P., Jouvelot, P.: The type and effect discipline. Inf. Comput. 111(2), 245–296 (1994)
Teller, D., Spiwack, A., Varoquaux, T.: Catch me if you can, Software package available at http://www.univ-orleans.fr/lifo/Members/David.Teller/software/exceptions/catch_0_2.tgz
Wadler, P.: The essence of functional programming. In: POPL 1992: Proceedings of the 19th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 1–14. ACM, New York (1992)
Yi, K., Ryu, S.: A cost-effective estimation of uncaught exceptions in standard ml programs. Theor. Comput. Sci. 277(1-2), 185–217 (2002)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2011 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Teller, D., Spiwack, A., Varoquaux, T. (2011). Catch Me If You Can. In: Scholz, SB., Chitil, O. (eds) Implementation and Application of Functional Languages. IFL 2008. Lecture Notes in Computer Science, vol 5836. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-24452-0_14
Download citation
DOI: https://doi.org/10.1007/978-3-642-24452-0_14
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-24451-3
Online ISBN: 978-3-642-24452-0
eBook Packages: Computer ScienceComputer Science (R0)