194 research outputs found

    Context-oriented functional programming

    No full text
    The modern computing landscape, featuring heterogeneous interconnected mobile devices, poses new challenges and opportunities for application development. Mobility and heterogeneity of devices imply that applications need to adapt depending on their execution context. Contexts such as the device that an application is running on, or the power profile, may require widespread program-wide adaptation. Dealing with this adaptation can lead to the introduction of subtle bugs, and subsequent runtime errors, such as null pointer exceptions when context has not been initialized. Current approaches to encoding context-aware behaviour are either very flexible but unsafe, or safe but too restrictive. In this thesis we present a new approach to context-aware application development based on functional programming, which attempts to be both flexible and safe. In order to do so, we present an embedded domain specific language in Haskell, where we explore the design space of context-dependent values within a functional programming language. In particular, we explore how to use Haskell's type system to automatically derive the context dependencies needed by a computation at the type level, and use this to ensure that required context is always available. We then develop context-dependent types to ensure safety in the presence of program-wide variation. By using different return types for different modes of operation of the program when appropriate, we can ensure isolation between them through type checking. We extend our domain specific language to support context-dependent types, whilst retaining type soundness, as well as sound and (we conjecture) complete type inference. We present a core calculus for these features and a high-level language that extends the calculus with practical programming features. Evaluation is performed by examining a context-aware application requiring exactly the kind of adaptation that is unsafe to implement in current approaches. We show that our language compares favourably to the state of the art in terms of both safety and code clarity.Open Acces

    Session Types with Arithmetic Refinements

    Get PDF
    Session types statically prescribe bidirectional communication protocols for message-passing processes. However, simple session types cannot specify properties beyond the type of exchanged messages. In this paper we extend the type system by using index refinements from linear arithmetic capturing intrinsic attributes of data structures and algorithms. We show that, despite the decidability of Presburger arithmetic, type equality and therefore also subtyping and type checking are now undecidable, which stands in contrast to analogous dependent refinement type systems from functional languages. We also present a practical, but incomplete algorithm for type equality, which we have used in our implementation of Rast, a concurrent session-typed language with arithmetic index refinements as well as ergometric and temporal types. Moreover, if necessary, the programmer can propose additional type bisimulations that are smoothly integrated into the type equality algorithm

    Reusable components of semantic specifications

    Get PDF

    Typed concurrent functional programming with channels, actors and sessions

    Get PDF
    The age of writing single-threaded applications is over. To develop scalable applications, developers must make use of concurrency and parallelism. Nonetheless, introducing concurrency and parallelism is difficult: naĂŻvely implemented, concurrent code is prone to issues such as race conditions and deadlocks. Moving to the distributed setting introduces yet more issues, in particular the possibility of failure. To cope with many of the problems of concurrent programming, language designers have proposed a class of programming languages known as communication-centric programming languages, which provide lightweight processes which do not share memory, but instead communicate using explicit message passing. The focus of this thesis is on typed communication-centric functional programming languages, using type systems to provide static guarantees about the runtime behaviour of concurrent programs. We investigate two strands of work: the relationship between typed channel- and actor-based languages, and the integration of asynchrony, exception handling, and session types in a functional programming language. In the first strand, we investigate two particular subclasses of communication-centric languages: channel-based languages such as Go, and languages based on the actor model, such as Erlang. We distil the essence of the languages into two concurrent λ-calculi: λch for simply-typed channels, and lact for simply-typed actors, and provide type- and semantics-preserving translations between them. In doing so, we clear up confusion between the two models, give theoretical foundations for recent implementations of type-parameterised actors, and also provide a theoretical grounding for frameworks which emulate actors in channel-based languages. Furthermore, by extending the core calculi, we note that actor synchronisation drastically simplifies the translation from channels into actors, and show that Erlang’s selective receive mechanism can be implemented without specialised constructs. In the second strand, we integrate session types, asynchrony, and exception handling in a functional programming language. Session types are a behavioural type system for communication channel endpoints, allowing conformance to protocols to be checked statically. We provide the first integration of exception handling and asynchronous session types in a core functional language, Exceptional GV, and prove that it satisfies preservation, global progress, and that it is confluent and terminating. We demonstrate the practical applicability of the approach by extending the Links tierless web programming language with exception handling, in turn providing the first implementation of exception handling in the presence of session types in a functional language. As a result, we show the first application of session types to web programming, providing examples including a two-factor authentication workflow and a chat application

    Reusable Components of Semantic Specifications

    Get PDF
    Semantic specifications of programming languages typically have poor modularity. This hinders reuse of parts of the semantics of one language when specifying a different language – even when the two languages have many constructs in common – and evolution of a language may require major reformulation of its semantics. Such drawbacks have discouraged language developers from using formal semantics to document their designs. In the PLanCompS project, we have developed a component-based approach to semantics. Here, we explain its modularity aspects, and present an illustrative case study: a component-based semantics for Caml Light. We have tested the correctness of the semantics by running programs on an interpreter generated from the semantics, comparing the output with that produced on the standard implementation of the language. Our approach provides good modularity, facilitates reuse, and should support co-evolution of languages and their formal semantics. It could be particularly useful in connection with domain-specific languages and language-driven software development

    A Reflection on Types

    Get PDF
    The ability to perform type tests at runtime blurs the line between statically-typed and dynamically-checked languages. Recent developments in Haskell’s type system allow even programs that use reflection to themselves be statically typed, using a type-indexed runtime representation of types called \{}\textit{TypeRep}. As a result we can build dynamic types as an ordinary, statically-typed library, on top of \{}\textit{TypeRep} in an open-world context

    A Reflection on Types

    Get PDF
    The ability to perform type tests at runtime blurs the line between statically-typed and dynamically-checked languages. Recent developments in Haskell’s type system allow even programs that use reflection to themselves be statically typed, using a type-indexed runtime representation of types called \{}\textit{TypeRep}. As a result we can build dynamic types as an ordinary, statically-typed library, on top of \{}\textit{TypeRep} in an open-world context

    ASPfun: a typed functional active object calculus

    Get PDF
    This paper provides a sound foundation for autonomous objects communicating by remote method invocations and futures. As a distributed extension of ς-calculus we define ASPfun, a calculus of functional objects, behaving autonomously and communicating by a request-reply mechanism: requests are method calls handled asynchronously and futures represent awaited results for requests. This results in an object language enabling a concise representation of a set of active objects interacting by asynchronous method invocations. This paper first presents the ASPfun calculus and its semantics. Then, we provide a type system for ASPfun which guarantees the “progress” property. Most importantly, ASPfun has been formalised; its properties have been formalised and proved using the Isabelle theorem prover and we consider this as an important step in the formalization of distributed languages. This work was also an opportunity to study different binder representations and experiment with two of them in the Isabelle/HOL theorem prover
    • 

    corecore