12 research outputs found
Generic Programming with Extensible Data Types; Or, Making Ad Hoc Extensible Data Types Less Ad Hoc
We present a novel approach to generic programming over extensible data
types. Row types capture the structure of records and variants, and can be used
to express record and variant subtyping, record extension, and modular
composition of case branches. We extend row typing to capture generic
programming over rows themselves, capturing patterns including lifting
operations to records and variations from their component types, and the
duality between cases blocks over variants and records of labeled functions,
without placing specific requirements on the fields or constructors present in
the records and variants. We formalize our approach in System R{\omega}, an
extension of F{\omega} with row types, and give a denotational semantics for
(stratified) R{\omega} in Agda.Comment: To appear at: International Conference on Functional Programming 2023
Corrected citations from previous versio
RepLib: A library for derivable type classes
Some type class instances can be automatically derived from the structure of types. As a result, the Haskell language includes the deriving mechanism to automatic generates such instances for a small number of built-in type classes. In this paper, we present RepLib, a GHC library that enables a similar mechanism for arbitrary type classes. Users of RepLib can define the relationship between the structure of a datatype and the associated instance declaration by a normal Haskell functions that pattern-matches a representation types. Furthermore, operations defined in this manner are extensible-instances for specific types not defined by type structure may also be incorporated. Finally, this library also supports the definition of operations defined by parameterized types
A type- and scope-safe universe of syntaxes with binding: their semantics and proofs
Almost every programming language's syntax includes a notion of binder and corresponding bound occurrences, along with the accompanying notions of alpha-equivalence, capture-avoiding substitution, typing contexts, runtime environments, and so on. In the past, implementing and reasoning about programming languages required careful handling to maintain the correct behaviour of bound variables. Modern programming languages include features that enable constraints like scope safety to be expressed in types. Nevertheless, the programmer is still forced to write the same boilerplate over again for each new implementation of a scope safe operation (e.g., renaming, substitution, desugaring, printing, etc.), and then again for correctness proofs. We present an expressive universe of syntaxes with binding and demonstrate how to (1) implement scope safe traversals once and for all by generic programming; and (2) how to derive properties of these traversals by generic proving. Our universe description, generic traversals and proofs, and our examples have all been formalised in Agda and are available in the accompanying material available online at https://github.com/gallais/generic-syntax
Abstracting Extensible Data Types: Or, Rows by Any Other Name
We present a novel typed language for extensible data types, generalizing and abstracting existing systems
of row types and row polymorphism. Extensible data types are a powerful addition to traditional functional
programming languages, capturing ideas from OOP-like record extension and polymorphism to modular
compositional interpreters. We introduce row theories, a monoidal generalization of row types, giving a
general account of record concatenation and projection (dually, variant injection and branching). We realize
them via qualified types, abstracting the interpretation of records and variants over different row theories. Our
approach naturally types terms untypable in other systems of extensible data types, while maintaining strong
metatheoretic properties, such as coherence and principal types. Evidence for type qualifiers has computational content, determining the implementation of record and variant operations; we demonstrate this in giving a modular translation from our calculus, instantiated with various row theories, to polymorphic λ -calculus
Patterns for Programming in the Semantic Web
Originally proposed in the mid-90s, design patterns for software development played a key role in object-oriented programming not only in increasing software quality, but also by giving a better understanding of the power and limitations of this paradigm. Since then, several authors have endorsed a similar task for other programming paradigms, in the hope of achieving similar benefits.
In this paper we discuss design patterns for the Semantic Web, giving new insights on how existing programming frameworks can be used in a systematic way to design large-scale systems. The common denominator between these frameworks is the combination between different reasoning systems, namely description logics and logic programming. Therefore, we chose to work in a generalization of dl-programs that supports several (possibly different) description logics, expecting that our results will be easily adapted to other existing frameworks such as multi-context systems. This study also suggests new constructs to enforce legibility and internal structure of logic-based Semantic Web programs
Reusable User Interface Behaviors
User interfaces often account for a majority of application code and defects. High quality user interfaces come with equally high development costs – lower than the cost of multitudes of users coping with low quality user interfaces, but higher than the mild frustration experienced by any individual user. Thus, the economics of software lead to a situation where barely passable user interfaces abound. That most user interface code comes from bespoke attempts to implement vague human interface guidelines is a leading cause of high cost and low quality.
This thesis introduces a novel formalism for user interfaces based on ordered constraint systems. Using explicit models for the values and relationships in a user interface, several reusable algorithms are defined for rich user interface behaviors, including value propagation, dataflow visualization, pinning, scripting, command activation, widget enablement, and context-sensitive help. Developers can leverage provably correct implementations of such desirable features for free, raising the quality of user interfaces while lowering their production cost.
Some of these behaviors have been implemented in a JavaScript framework, Hot-Drink, for web user interfaces, and a C++ framework, Adam, for desktop user interfaces. Experiments have demonstrated higher developer productivity, fewer lines of code, fewer defects, and fewer components when compared to conventional user interface frameworks
Towards A Practical High-Assurance Systems Programming Language
Writing correct and performant low-level systems code is a notoriously demanding job, even for experienced developers. To make the matter worse, formally reasoning about their correctness properties introduces yet another level of complexity to the task. It requires considerable expertise in both systems programming and formal verification. The development can be extremely costly due to the sheer complexity of the systems and the nuances in them, if not assisted with appropriate tools that provide abstraction and automation.
Cogent is designed to alleviate the burden on developers when writing and verifying systems code. It is a high-level functional language with a certifying compiler, which automatically proves the correctness of the compiled code and also provides a purely functional abstraction of the low-level program to the developer. Equational reasoning techniques can then be used to prove functional correctness properties of the program on top of this abstract semantics, which is notably less laborious than directly verifying the C code.
To make Cogent a more approachable and effective tool for developing real-world systems, we further strengthen the framework by extending the core language and its ecosystem. Specifically, we enrich the language to allow users to control the memory representation of algebraic data types, while retaining the automatic proof with a data layout refinement calculus. We repurpose existing tools in a novel way and develop an intuitive foreign function interface, which provides users a seamless experience when using Cogent in conjunction with native C. We augment the Cogent ecosystem with a property-based testing framework, which helps developers better understand the impact formal verification has on their programs and enables a progressive approach to producing high-assurance systems. Finally we explore refinement type systems, which we plan to incorporate into Cogent for more expressiveness and better integration of systems programmers with the verification process
Verified programming with explicit coercions
Type systems have proved to be a powerful means of specifying and proving
important program invariants. In dependently typed programming languages
types can depend on values and hence express arbitrarily complicated
propositions and their machine checkable proofs. The type-based approach
to program specification allows for the programmer to not only transcribe
their intentions, but arranges for their direct involvement in the proving
process, thus aiding the machine in its attempt to satisfy difficult obligations.
In this thesis we develop a series of patterns for programming in a correct-by-construction style making use of constraints and coercions to prove
properties within a dependently typed host. This allows for the development
of a verified, kernel which can be built upon using the host system features.
In particular this should allow for the development of “tactics” or semiautomated
solvers invoked when coercing types all within a single language.
The efficacy of this approach is given by the development of a system of
expressions indexed by their, exposing a case analysis feature serving to
generate value constraints. These constraints are directly reflected into
the host allowing for their involvement in the type-checking process. A
motivating use case of this design shows how a term’s semantic index
information admits an exact, formalized cost analysis amenable to reasoning
within the host. Finally we show how such a system is used to identify
unreachable dead-code, trivially admitting the design and verification of
an SSA style compiler with this optimization. We think such a design
of explicitly proving the local correctness of type-transformations in the
presence of accumulated constraints can form the basis of a flexible language
in concert with a variety of trusted solver
Guaranteeing Responsiveness and Consistency in Dynamic, Asynchronous Graphical User Interfaces
This dissertation proposes a programming model for Graphical User Interfaces (GUIs) that relieves the programmer of a difficult and error-prone task: orchestrating concurrent responses to events to ensure data dependencies are always enforced correctly. In this programming model, rather than defining program responses to events, the programmer defines the data dependencies that exist in the GUI and the methods by which those dependencies may be enforced – a run-time system uses this specification to generate responses to events. The approach gives the following guarantee: the same sequence of events produces the same results, regardless of the timing of those events. The dissertation demonstrates the benefits of the proposed programming model with implementations of several example user interfaces.
At the core of this programming model is a data structure known as a property model. A property model composes responses to individual events into a single reactive program that runs asynchronously. The program's results are used to update the GUI. The program is constructed in a manner that respects all data dependencies, thereby guaranteeing that results are consistent regardless of the length of time taken by individual responses. The core reactive program may be extended with features that support additional functionality, such as access to prior variable values, optional data dependencies, and identifying unused variables. The dissertation defines the semantics of the construction and execution of this reactive program formally.
The dissertation shows how property models may be defined as a composition of reusable components. This is essential for modeling GUIs whose structures change in response to user events by the addition or removal of components. Components can contain data and dependencies as well as templates that describe how dependencies arise from composition with other components. Furthermore, templates can be written for arrays of components to define dependencies that arise among them.
One key task of the property model is planning by which methods dependencies will be enforced. The dissertation describes how a specialized planner can be constructed that is able to create a plan for a specific property model. This specialized planner is essentially a Deterministic Finite-state Automaton (DFA), and can be orders of magnitude faster than a general-purpose planner