Idris

Off The Beaten Track

I submitted a talk entitled Type-Driven Development of Security Protocols to Off-The-Beaten-Track ‘17.

I have decided to uploaded the abstract here so that my attempt is a least indexable by the great machine spirit in the web—Hallowed be thy API. Given time I will also upload a copy of the paper to ArXiV.

The abstract is:

Implementing security protocols correctly is hard; verifying them is too. However, we also implement them in languages different to those we verify them in. With dependent types we can reason on software with greater precision and link specifications to implementations. In this talk we examine how state-of-the-art programming language research can help us to verify and implement protocols in the same language.

SPLS-Type-Driven Design of Communicating Systems using Idris

Today I gave a talk about my work at SPLS Nov ‘16 at the University of Strathclyde.

The idea of communicating systems is a cornerstone of modern technology that allows heterogeneous collections of components to communicate through well-defined communication patterns. However, there is a disconnect between the tooling and languages used to design, implement and reason about communication protocols.

Idris is a general purpose programming language that supports full-dependent types, providing programmers with the ability to reason more precisely about programs. Inspired by work on Session types, our research looks to leverage dependent types to describe and reason about secure communication patterns and their implementation in different communication contexts.

Effectful Channel Management

Communicating systems require channels to communicate, in many of the programming languages that provide communication channels the management of these channels at the application layer is left to the programmer to get right. That is, the programmer is responsible for ensuring that the channel is established, connected to, and then destroyed.

In languages that support dependent types we can encoded, at the type level, extra properties about our software program. Further, the idea of algebraic effects supports the separation of a program’s description from its realisation in different contexts. Edwin Brady’s EFFECTS library has shown how this is possible using dependent types [@Brady2015rda]. The implementation of EFFECTS allows for efficient management of a program’s side-effects and dealings with the outside world. See the Effects Tutorial for more information.

Tips for using Effects in Idris

Effects is an Idris package that implements resource-dependent algebraic effects. This allows a developer to control at a fine-a-grained level the side affects (state, logging, IO) for effectful programs. A tutorial and more background on their use is available on line.

When writting my Idris libraries I have used Effects to manage exceptions, state, logging, and IO. Here are some tips in my experiences in using Effects.

Global Effects List

In an effectful function the effects used are declared in a List data structure of type List EFFECT. An effectful main function will look like:

Dependent Types and Goal-Oriented DSMLs

I submitted a paper entitled Using Dependent Types to Build Domain Specific Goal-Oriented Modelling Languages to GPCE ‘15. Sadly it was rejected. I mentioning it here, so that my attempt is a least indexable by the great machine spirit in the web—Hallowed be thy API.

The abstract is:

The Goal Requirements Language (GRL) has been used as a host language for the creation of Domain Specific Goal-Oriented Modelling Languages (DSMLs). The pictorial language constructs, however, do not allow for a more formal language-driven treatment to be given for DSMLs created in the GRL. Dependent types allow for more precise reasoning to be made about programs. This paper describes the GStar framework that uses of dependent types to reason on the construction of DSMLs based on the GRL. Two styles of DSML construction are presented. The first allows for structurally equivalent DSML to be created that differ in terminology and semantic constructs. The second facilitates the construction of structurally different DSMLs that have the same evaluation semantics. Both techniques allows for a direct correspondence to be made between the semantics and structure of the host language and domain language.

Dependent Lists

Edits Spelling and Grammar

In dependently typed languages such as Idris, types can depend on values. This facilitates the construction of rich type-eco-system for reasoning on our software programmes. However, when working with dependently typed values it makes the collection of these values into containers much more interesting. As types depend on a value collecting a set of dependent type into a standard container type means that all items in the container must have the same type.

Edits As someone cannot proof-read, this post has been updated.

Idris is my day to day language for programming. This article and subsequent will detail some tricks that may be of benefit when creating Idris Programs.

The Idris compiler goes through many a stage during the compilation process. Idris code is:

  • elaborated
  • checked for coverage
  • checked for totality
  • checked for unification
  • defunctionalised
  • turned into code

These checks are not necessarily robust stages perform a series of checks on the code, or apply transformations, and when presented with code written in a poor style can lead to false negatives being reported, or the Idris compiler becoming confused as to what is happening. This can lead to Idris experiencing long compile times or failing to compile successfully.

Types and Abstract Interpretation

This post demonstrates how Dependent Types can be used to implement ‘Types as (Abstract) Interpretations’. The full code can be found on GIST.

The concept of abstract interpretation is to model the runtime behaviour (semantics) of a program using an existing formalism whose execution costs are lightweight in comparison to the original program.

With dependent types we can encode such abstract interpretations at the type-level to both model and reason on software execution.

Embedded Domain Specific Type Systems for Declarative EDSls

Example of Embedded Domain Specific Type Systems for Declarative EDSLs. The full code can be found: https://gist.github.com/jfdm/2c37389f89203448f763

This example represents the FooExpr language, this is a declarative language for specifiying different kinds of elements, and their links. The real world semantics of FooExpr do nto matter here, but think of we are building graphs and constraining the values for nodes and edges.

The Meta Typing System

Meet the meta-types in our typing system.

An Effectful Logger: Part One

Effects is an Idris package that implements resource-dependent algebraic effects. This allows a developer to control at a fine-a-grained level the side affects (state, logging, IO) for effectful programs. A tutorial and more background on their use is available on line.

In the past I wrote some Logging effects as a means to understand how resource-dependent algebraic effects work. Recently, I had need to use it in anger in my application. As a result I rewrote the damm thing, and decided to describe the output in a blog post. This post will describe the simple logging model, with a future post describing the category based model.

← Previous 1 2 3 4 5