6 research outputs found
An idiom’s guide to formlets
Formlets in Links decouple user interface from data, a vital form of abstraction supported by very few web frameworks. Formlets are best defined in terms of idioms, not monads or arrows as one might suppose from the existing literature. 1
Language-Integrated Updatable Views
Relational lenses are a modern approach to the view update problem in relational databases. As introduced by Bohannon et al. [5], relational lenses allow the definition of updatable views by the composition of lenses performing individual transformations. Horn et al. [20] provided the first implementation of incremental relational lenses, which demonstrated that relational lenses can be implemented efficiently by propagating changes to the database rather than replacing the entire database state.
However, neither approach proposes a concrete language design; consequently, it is unclear how to integrate lenses into a general-purpose programming language, or how to check that lenses satisfy the well-formedness conditions needed for predictable behaviour. In this paper, we propose the first full account of relational lenses in a functional programming language, by extending the Links web programming language. We provide support for higher-order predicates, and provide the first account of typechecking relational lenses which is amenable to implementation. We prove the soundness of our typing rules, and illustrate our approach by implementing a curation interface for a scientific database application
Typed concurrent functional programming with channels, actors and sessions
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
Abstraction for web programming
This thesis considers several instances of abstraction that arose in the design and implementation
of the web programming language Links. The first concerns user interfaces, specified
using HTML forms. We wish to construct forms from existing form fragments without introducing
dependencies on the implementation details of those fragments. Surprisingly, many
existing web systems do not support this simple scenario. We present a library which captures
the essence of form abstraction, and extend it with more practical facilities, such as validation
of the HTML a program produces and of the input a user submits.
An important part of our library is a simple semantics, given as the composition of three
primitive “idioms”, an interface to computation introduced by McBride and Paterson. In order
to justify this approach we present a comparison of idioms with the related notions of monads
and arrows, refining the informal claims in the literature.
Our library forms part of the Links framework for stateless web interactions. We describe a
related aspect of this system, a preprocessor that derives generic instances of functions, which
we use to serialise server state between client requests. The abstraction in this case involves
the shape of datatypes: the serialisation operation is specified independently of the particular
types involved.
Our final instance of abstraction involves abstract types. Functional programming languages
typically offer one of two styles of abstract type: the abstraction boundary may be
drawn using a private data constructor, or using a type signature. We show that there is a pair
of semantics-preserving translations between these two styles. In the light of this, we revisit
the decision of the Haskell designers to offer the constructor style, and define a library that
supports signature-style definitions in Haskell by translation into the constructor style
Web programming with SMLserver
Abstract. SMLserver is an efficient multi-threaded Web server platform for Standard ML programs. It provides access to a variety of different Relational Database Management Systems (RDBMSs), including Oracle, MySQL, and PostgreSQL. We describe the execution model and the region-based memory model of SMLserver and explain our solutions to the design issues we were confronted with in the development. We also describe our experience with programming and maintaining Web applications using Standard ML, which provides higher-order functions, static typing, and a rich module system. Through experiments based on user scenarios for some common Web tasks, the paper demonstrates the efficiency of SMLserver, both with respect to script execution and database connectivity.