Strongly typed memory areas programming systems-level data structures in a functional language

Modern functional languages offer several attractive features to support development of reliable and secure software. However, in our efforts to use Haskell for systems programming tasks-including device driver and operating system construction-we have also encountered some significant gaps in functionality. As a result, we have been forced, either to code some non-trivial components in more traditional but unsafe languages like C or assembler, or else to adopt aspects of the foreign function interface that compromise on strong typing and type safety.In this paper, we describe how we have filled one of these gaps by extending a Haskell-like language with facilities for working directly with low-level, memory-based data structures. Using this extension, we are able to program a wide range of examples, including hardware interfaces, kernel data structures, and operating system APIs. Our design allows us to address concerns about representation, alignment, and placement (in virtual or physical address spaces) that are critical in some systems applications, but clearly beyond the scope of most existing functional languages.Our approach leverages type system features that are wellknown and widely supported in existing Haskell implementations, including kinds, multiple parameter type classes, functional dependencies, and improvement. One interesting feature is the use of a syntactic abbreviation that makes it easy to define and work with functions at the type level.

[1]  Mark P. Jones Simplifying and improving qualified types , 1995, FPCA '95.

[2]  Mark P. Jones,et al.  High-level views on low-level representations , 2005, ICFP '05.

[3]  Andrew P. Tolmach,et al.  From ML to Ada: Strongly-typed language interoperability via source translation , 1998, Journal of Functional Programming.

[4]  Simon L. Peyton Jones,et al.  Associated type synonyms , 2005, ICFP '05.

[5]  Peyton Jones,et al.  Haskell 98 language and libraries : the revised report , 2003 .

[6]  James Cheney,et al.  Cyclone: A Safe Dialect of C , 2002, USENIX Annual Technical Conference, General Track.

[7]  Simon L. Peyton Jones,et al.  H/Direct: a binary foreign language interface for Haskell , 1998, ICFP '98.

[8]  Christoph Kreitz,et al.  Building reliable, high-performance communication systems from components , 2000, OPSR.

[9]  Frank Pfenning,et al.  The Fox Project: Advanced Language Technology for Extensible Systems , 1998 .

[10]  Mark P. Jones,et al.  A principled approach to operating system construction in Haskell , 2005, ICFP '05.

[11]  Matthias Blume No-Longer-Foreign: Teaching an ML compiler to speak C "natively" , 2001, Electron. Notes Theor. Comput. Sci..

[12]  Brian W. Kernighan,et al.  The C Programming Language , 1978 .

[13]  Robert Gruber,et al.  PADS: a domain-specific language for processing ad hoc data , 2005, PLDI '05.

[14]  Mark P. Jones,et al.  Type Classes with Functional Dependencies , 2000, ESOP.

[15]  Peter Thiemann,et al.  A Functional Notation for Functional Dependencies , 2001 .

[16]  Riccardo Pucella,et al.  A framework for interoperability , 2001, Electron. Notes Theor. Comput. Sci..

[17]  Magnus Carlsson,et al.  Composed, and in Control: Programming the Timber Robot , 2002 .

[18]  Godmar Back,et al.  DataScript - A Specification and Scripting Language for Binary Data , 2002, GPCE.

[19]  Norman Ramsey,et al.  Specifying representations of machine instructions , 1997, TOPL.

[20]  Dan Grossman,et al.  Safe Programming at the C Level of Abstraction , 2003 .