In this lecture we do a quick recap of Haskell and talk about things like referential transparency, laziness, type classes, and a first simple example of a domain specific embedded language: Signal.
Signal | [code] |
In this lecture we develop domain specific embedded languages for describing signals and shapes. We talk about the distinction between a deep and a shallow embedding, about compositionality and abstraction.
Matrix | [code] | |
Signal | [code] | |
Signal.Shallow | [code] | |
Signal.Deep | [code] | |
Signal.Example | [code] | |
Shape | [code] | |
Shape.Shallow | [code] | |
Shape.Deep | [code] | |
ANSI | [code] | |
Render | [code] | |
Animate | [code] | |
Example | [code] |
This lecture introduces monads by looking at how to design a simple library for input/output.
Program.Shallow | [code] | |
Program.Deep1 | [code] | |
Program.Deep2 | [code] | |
Program | [code] | |
Game | [code] | |
Coord | [code] | |
Snake | [code] |
In this lecture we look at another application of monads, namely parsing. We also see how to refine the implementation of a library. Starting from a naive translation from syntax to semantics, we derive intermediate representations for an efficient implementation. The focus here is on learning outcome "Spec: use specifictaion based development techniques".
ParseUtil | [code] | |
Parsers | [code] | |
Parser0 | [code] | |
Parser1 | [code] | |
Parser2 | [code] | |
Parser3 | [code] | |
exe/Example | [code] |
We learn how to build complicated monads from simple building blocks.
MonadT_API_summary | [code] | |
Interpreter0 | [code] | |
Interpreter1 | [code] | |
Interpreter2 | [code] | |
Interpreter3 | [code] | |
Interpreter4 | [code] | |
Examples | [code] | |
Parser | [code] |
In the course evaluation meeting after the 2013 instance we decided to dilute the first part of the course a bit: the material from lectures 2,3,4,5 are spread out over lecture slot 2-6. Concretely this means that this lecture was spent working through the StateT and ErrorT monad transformers in the interpreter example before the break and transforming looking at the Monad and Parser laws after the break. The code and the recommended reading material can be found above.
We look at program verification: proving, specifying and testing correctness of programs. (Lecturer: Jonas Duregård.)
InsertionSort | [code] |
In this lecture / excerices session we will work through old AFP exam questions in groups to identify important topics and practice collaborative problem solving and discussion. This is in response to student comments from last year wanting more practice of the kind of problems typically included in the written exams.
In this lecture we continue the work on QuickCheck, mainly looking at how to generate and shrink test data. We base the work on a compiler example and show how the program coverage tool hpc can be used to see what parts of a program has been tested. We may also look at the different stackings of the monad transformers in the Interpreter4 example (from the MonadTransformes lecture).
ParserTests | [code] |
Title: Designing EDSLs by combining Deep and Shallow Embeddings
I will present a design pattern for embedded DSLs (EDSLs) where a combination of deep and shallow embeddings is used in order to get most advantages from both approaches. This approach has been successfully used in Feldspar which is an EDSL for high-performance numeric computations. I will also introduce Feldspar and discuss some details of its implementation.
We look at two recent extensions to Haskell: GADTs and Type families.
Expr | [code] | |
Typed | [code] | |
Parser | [code] | |
Add | [code] | |
Array | [code] | |
Array/Properties | [code] | |
Array/Example | [code] | |
Array/ShowInstances | [code] | |
Array/EqInstances | [code] |
In dependently typed languages such as Agda one can both write programs and proofs about the programs. Agda can be seen as a "next generation Haskell".
Abstract: Starting with a simple example from Richard Bird's "Introduction to Functional Programming", computing square roots (section 3.6.1, pp 84--85), we introduce some problems typical of today's scientific computing: finding derivatives, optimization, controlling floating-point errors. We'll implement simple automatic differentiation and interval analysis, exposing some of the advantages and disadvantags of Haskell's numerical typeclasses. You can find related material on the web page of the Oberwolfach seminar on "Mathematics for scientific computing" [1] in particular [2], [3] and the references within.
Micro-bio: Cezar Ionescu is currently a PostDoc on "Increasingly Correct Scientific Computing" in the FP group at Chalmers. Before that he worked for several years at the Potsdam Institute for Climate Impact Research where he applied AFP in the form of Haskell, C++, Agda and Idris to Computational Vulnarability Assessment, Scientific Computing and Economic Models.
In this lecture we look back at the learning outcomes and how they relate to the different parts of the course and what parts of the RWH book are covered. Some other relevant topics did not fit but I include references and code below.
RWMonad | [code] | |
MaybeT/Deep | [code] | |
MaybeT/Shallow | [code] |
FFI | [code] | |
foreign.c | ||
Cont | [code] | |
Memo | [code] | |
Generics | [code] | |
NoGenerics | [code] |