Idris

A Framework for Resource Dependent EDSLs in a Dependently Typed Language

My ECOOP2020 video & paper detailing how one can create Resource-Dependent EDSLs in Idris are out!

They can be found online on the conference website. Apologies in advance for the quiet audio!

Idris’ Effects library demonstrates how to embed resource dependent algebraic effect handlers into a dependently typed host language, providing run-time and compile-time based reasoning on type-level resources. Building upon this work, RESOURCES is a framework for realising Embedded Domain Specific Languages (EDSLs) with type systems that contain domain specific substructural properties. Differing from Effects, RESOURCES allows a language’s substructural properties to be encoded within type-level resources that are associated with language variables. Such an association allows for multiple effect instances to be reasoned about autonomically and without explicit type-level declaration. Type-level predicates are used as proof that the language’s substructural properties hold. Several exemplar EDSLs are presented that illustrates our framework’s operation and how dependent types provide correctness-by-construction guarantees that substructural properties of written programs hold.

Defining Intrinsically Typed Data Structures

When reading foundational texts such as PLFA, TAPL, and Software Foundations the learner is often presented with Simply-Typed Lambda Calculi that supports both products and sums. When translating these calculi to dependently typed languages in an intrinsically typed way as we do with Idris & Agda, how we might approach supporting other data structures such as tuples, records and variants is not precisely clear. In fact Software Foundations does give an idea on how to do so but let us explore how we may choose to represent such structures in Idris/Agda.

Programming with Holes

Traditionally, computer programs must be complete when presented to the compiler. Typed Holes (also known as meta variables) are an important tool when programming that supports computing with incomplete programs in which holes (the things we do not know) are a core aspect of the language (and tooling) design. Specifically, if you have used dependently typed languages such as Idris and Agda you will have encountered holes before. Typed Holes in Idris allow us to inspect the local typing context from where the hole was placed. This allows us to see what information is directly available when looking to fill the hole. Further, computing the type of the typed hole also tells us the type of thing we need to insert.

Building Resource-Dependent EDSLs in a Dependently-Typed Language

Today, I gave an extended talk about Resource Dependent EDSLs in a Dependently Typed Language at the MSP101 Seminar Series of the MSP Group at the University of Strathclyde. This was joint work with Wim Vanderbauwhede, and Edwin Brady.

While many people use dependent types for theorem proving some of us like to use dependent types for building, and running, safer programs.

Idris’ Effects library demonstrates how to embed resource dependent algebraic effect handlers into a dependently typed host language, providing run-time and compile-time based reasoning on type-level resources. Building upon this work, Resources is a framework for realising EDSLs with type systems that contain domain specific substructural properties. Differing from Effects, Resources allows a language’s substructural properties to be encoded within type-level resources that are associated with language variables. Such an association allows for multiple effect instances to be reasoned about autonomically and without explicit type-level declaration. We use type-level predicates as proof that a language’s substructural properties hold.

A Framework for Resource Dependent EDSLs in a Dependently Typed Language

I am very pleased to announce that my paper describing a framework for constructing Resource Dependent EDSLs in a Dependently Typed Language was accepted to ECOOP 2020. Many of you may have seen this from the conference website itself, and I was waiting until the camera ready copy was produced to properly publicly announce. This was joint work with Wim Vanderbauwhede, and Edwin Brady.

Idris’ Effects library demonstrates how to embed resource dependent algebraic effect handlers into a dependently typed host language, providing run-time and compile-time based reasoning on type-level resources. Building upon this work, RESOURCES is a framework for realising Embedded Domain Specific Languages (EDSLs) with type systems that contain domain specific substructural properties. Differing from Effects, RESOURCES allows a language’s substructural properties to be encoded within type-level resources that are associated with language variables. Such an association allows for multiple effect instances to be reasoned about autonomically and without explicit type-level declaration. Type-level predicates are used as proof that the language’s substructural properties hold. Several exemplar EDSLs are presented that illustrates our framework’s operation and how dependent types provide correctness-by-construction guarantees that substructural properties of written programs hold.

The Last Step

Every so often I like to reread notable books on /Programming Language Theory/ (PLT). Namely, one should read:

With these books each presents a treatment of PLT either: mechanised using Agda or Coq; presented purely theoretically in LaTeX; or a mixture of theory and practice.

Of particular interest to myself is the presentation using Agda. Dependent types allow us to present formal descriptions of our programs together with their practical constructions.

Mutual Avoidance

Sometimes dependent types push you towards mutually defined data structures: I try to avoid them where I can. For me, this occurrs when you need a helper data type where a container is not suitable expressive at the type level to capture the inductive case. When this happens you can index your helper data structure with the signature of the top type. This helps remove the need for a mutual definition, that is turn the call graph edge from undirected to directed.

Decidably Uninformative

Dependently typed theorem proving is about using the power of dependent types to provide guarantees over various properties of software programs and mathematical constructs. In dependently typed programming we use dependent types to construct and better reason about the properties of our software programs.

While the former requires that we construct proofs, the latter requires that we construct a usable system. In this post I want to discuss how proving and construction can get in the way of each other and that when programming with dependent types we must recognise and tread carefully the fine line between theorem proving and programming.

Well-Typed Expressions lead to Well-Typed Well-Scoped Programs

Let us consider the /Well-Typed Interpreter/ (WTI), a well known application of dependent types to ensure that our program’s are not only well-typed but also well-scoped w.r.t. variables. To be specific the WTI details not how program’s are correct but /expressions/. When dealing with program’s we will have a top-level expression that may depend on globally declared expressions.

In this post I will describe a Razor, detailing how with a little thought we can use the concept of the WTI to described /Well-Typed Programs/.

Hutton's Razor(s)

In this post we will consider Hutton’s Razor.

This post was derived from a literate Idris file so there will be some cruft related to Idris that will remain until I get round to 1 improving Idris’ literate mode support.

module Main

We will need some data structures, and helper functions, not defined in Idris’ prelude.

import Data.List

The following two imports are from my container’s library, we will need these in the final sections to keep our musing’s DRY.

← Previous 1 2 3 4 5 Next →