Abstract

In this paper, we describe our experience incorporating gradual types in a statically typed functional language with Hindley-Milner style type inference. Where most gradually typed systems aim to improve static checking in a dynamically typed language, we approach it from the opposite perspective and promote dynamic checking in a statically typed language. Our approach provides a glimpse into how languages like SML and OCaml might handle gradual typing. We discuss our implementation and challenges faced -- specifically how gradual typing rules apply to our representation of composite and recursive types. We review the various implementations that add dynamic typing to a statically typed language in order to highlight the different ways of mixing static and dynamic typing and examine possible inspirations while maintaining the gradual nature of our type system. This paper also discusses our motivation for adding gradual types to our language, and the practical benefits of doing so in our industrial setting.

Highlights

  • Static typing and dynamic typing are two opposing type system paradigms

  • Gradual typing in Bloomberg Contract Language (BCL) allows language maintainers to stick to static typing and end users to selectively disable static typing when it interferes with their ability to work in BCL

  • Despite the flexibility offered by dynamic typing, the safety offered by static typing is helpful in domains where correctness is critical

Read more

Summary

Introduction

Static typing and dynamic typing are two opposing type system paradigms. Statically typed languages are able to catch more programmer bugs early in the compilation process, at the expense of a more flexible semantics. Language maintainers are Bloomberg software engineers who are most at ease programming in statically typed and often functional languages like OCaml. Whilst it is of paramount importance to provide our end users with an environment in which they are comfortable, our domain—financial contracts— is one in which correctness is of extraordinary importance, since errors can lead to large financial losses This makes static types appealing, as they catch many errors that dynamic systems might miss. Abadi’s work uses a dynamic construct to build terms of type Dynamic and a typecase construct to perform case analysis on the runtime type of an expression of type Dynamic This is similar to the typeof() function in dynamic languages like Python, which resolve the type of an expression at runtime.

Objectives
Discussion
Conclusion

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call

Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.