Skip to main content

Catch Me If You Can

Looking for Type-Safe, Hierarchical, Lightweight, Polymorphic and Efficient Error Management in OCaml

  • Conference paper
Implementation and Application of Functional Languages (IFL 2008)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 5836))

Included in the following conference series:

  • 430 Accesses

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 54.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 69.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 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)

    Chapter  Google Scholar 

  2. Warren Burton, F.: Type extension through polymorphism. ACM Trans. Program. Lang. Syst. 12(1), 135–138 (1990)

    Article  Google Scholar 

  3. 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)

    Chapter  Google Scholar 

  4. Carette, J., van Dijk, L.E., Kiselyov, O.: Syntax extension for monads in ocaml, http://www.cas.mcmaster.ca/~carette/pa_monad/

  5. 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)

    Google Scholar 

  6. 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)

    Google Scholar 

  7. Garrigue, J.: Programming with polymorphic variants. In: ML Workshop (1998)

    Google Scholar 

  8. Garrigue, J.: Relaxing the value restriction. In: Kameyama, Y., Stuckey, P.J. (eds.) FLOPS 2004. LNCS, vol. 2998, pp. 196–213. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  9. Guyer, S.Z., Lin, C.: An annotation language for optimizing software libraries. In: DSL, pp. 39–52 (1999)

    Google Scholar 

  10. Holt, R.C., Wortman, D.B.: A sequence of structured subsets of pl/i. SIGCSE Bull. 6(1), 129–132 (1974)

    Article  Google Scholar 

  11. Marlow, S.: An extensible dynamically-typed hierarchy of exceptions. In: Haskell 2006: ACM SIGPLAN Workshop on Haskell, Portland, Oregon, ACM Press, New York (2006)

    Google Scholar 

  12. Milner, R., Tofte, M., Macqueen, D.: The Definition of Standard ML. MIT Press, Cambridge (1990)

    Google Scholar 

  13. Mitchell, N., Runciman, C.: A static checker for safe pattern matching in Haskell. In: Trends in Functional Programming, vol. 6. Intellect (February 2007)

    Google Scholar 

  14. Pessaux, F.: Détection statique d’exceptions non rattrapées en Objective Caml. PhD thesis, Université Pierre & Marie Curie - Paris 6 (2000)

    Google Scholar 

  15. Ramsey, N.: Eliminating spurious error messages using exceptions, polymorphism, and higher-order functions. The Computer Journal 42(5), 360–372 (1999)

    Article  MATH  Google Scholar 

  16. 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)

    Google Scholar 

  17. Talpin, J.-P., Jouvelot, P.: The type and effect discipline. Inf. Comput. 111(2), 245–296 (1994)

    Article  MathSciNet  MATH  Google Scholar 

  18. 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

  19. 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)

    Google Scholar 

  20. Yi, K., Ryu, S.: A cost-effective estimation of uncaught exceptions in standard ml programs. Theor. Comput. Sci. 277(1-2), 185–217 (2002)

    Article  MathSciNet  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics