## A functional specification of effects (2009)

Citations: | 10 - 1 self |

### BibTeX

@TECHREPORT{Swierstra09afunctional,

author = {Wouter Swierstra},

title = {A functional specification of effects},

institution = {},

year = {2009}

}

### OpenURL

### Abstract

This dissertation is about effects and type theory. Functional programming languages such as Haskell demonstrate that monads can safely encapsulated side effects. If you want to reason about effectful code, however, it is not enough to only encapsulate effects: you must explain their meaning. In this dissertation I provide pure specifications of effects in type theory. After initial investigations using Haskell, I show how such specifications can be made total in a language with dependent types. Hoare Type Theory takes an alternative approach to incorporating effects in a dependently typed language. Instead of giving functional specifications, they follow Haskell’s lead and postulate the existence of primitive functions. This dissertation shows how some of these primitives may be implemented in a programming language with dependent types. I believe that functional specifications may provide the foundations on top of which richer logics may be constructed. The results presented in this dissertation may be used to write and verify

### Citations

508 |
Interactive Theorem Proving and Program Development
- Bertot, Casteran
- 2004
(Show Context)
Citation Context ...eyton Jones, 2003) type system, for example, is constantly being refined in pursuit of increasingly strong static guarantees. At the very end of the correctness spectrum, theorem provers such as Coq (=-=Bertot and Castéran, 2004-=-), HOL (Nipkow et al., 2002), and PVS (Owre et al., 1992) are used to verify properties of computer programs. These systems typically use an abstract model representing the software system. Such tools... |

489 |
The Calculus of Constructions
- Coquand, Huet
- 1988
(Show Context)
Citation Context ...ory, a point we will discuss in greater detail in Section 9.3. 9.1 An overview of Hoare Type Theory Hoare Type Theory extends a ‘vanilla’ type theory, such as the Calculus of Inductive Constructions (=-=Coquand and Huet, 1988-=-) or Martin-Löf’s Theory 110Listing 23 The ST type of Hoare Type Theory postulate Loc : Set data Dyn : Set where dyn : (a : Set) → a → Dyn Heap : Set Heap = Loc → Maybe Dyn Pre : Set Pre = Heap → Pro... |

327 | Quickcheck: a lightweight tool for random testing of haskell programs
- Claessen, Hughes
- 2000
(Show Context)
Citation Context ... to be added to the stack is the first element that will be popped. fifoProp :: Int → Stack Int → Bool fifoProp x xs = top (push xs x) ≡ Just x 11By using automated testing tools such as QuickCheck (=-=Claessen and Hughes, 2000-=-), we can check such properties of our implementation of queues: *Main> quickCheck fifoProp OK, passed 100 tests. This gives us some degree of certainty that this property does hold. To convince ourse... |

278 | Refinement Calculus: A Systematic Introduction - Back, Wright - 1998 |

248 |
Interprétation Fonctionnelle et Élimination des Coupures de l’Arithmétique d’Ordre Supérieur
- Girard
- 1972
(Show Context)
Citation Context ... Furthermore, we do not use the same definition of Dyn. The definition in Hoare Type Theory has a technical problem. There is type theoretic equivalent of Russell’s paradox known as Girard’s paradox (=-=Girard, 1972-=-; Coquand, 1986). It revolves around constructing a ‘type of all types,’ much as Russell’s paradox constructs a set of all sets. To preserve a consistency many type theories maintain that the type of ... |

79 | B.: Monadic presentations of lambda terms using generalized inductive types
- Altenkirch, Reus
- 1999
(Show Context)
Citation Context ... to a heap of shape t and returns a result of type a. This pattern of indexing operations by an initial and final state is a common pattern in dependently typed programming (McKinna and Wright, 2006; =-=Altenkirch and Reus, 1999-=-). data IO (a : Set) : Shape → Shape → Set where Return : forall {s} → a → IO a s s Write : forall {s t u} → Ref u s → el u → IO a s t → IO a s t Read : forall {s t u} → Ref u s → (el u → IO a s t) → ... |

75 | A lightweight implementation of generics and dynamics
- Cheney, Hinze
- 2002
(Show Context)
Citation Context ...ons such as those that Bird has proposed. Limitations We restricted ourselves to mutable variables storing the Data type. A more flexible approach would be to use Haskell’s support for dynamic types (=-=Cheney and Hinze, 2002-=-; Baars and Swierstra, 2002) to allow references to different types. Concretely, this would involve the following changes: • Replacing the occurrences of Data in the IOs type with Dynamic and adapting... |

70 | An analysis of Girard's paradox
- Coquand
- 1986
(Show Context)
Citation Context ...we do not use the same definition of Dyn. The definition in Hoare Type Theory has a technical problem. There is type theoretic equivalent of Russell’s paradox known as Girard’s paradox (Girard, 1972; =-=Coquand, 1986-=-). It revolves around constructing a ‘type of all types,’ much as Russell’s paradox constructs a set of all sets. To preserve a consistency many type theories maintain that the type of all types shoul... |

58 | Typing dynamic typing
- Baars, Swierstra
- 2002
(Show Context)
Citation Context ...ird has proposed. Limitations We restricted ourselves to mutable variables storing the Data type. A more flexible approach would be to use Haskell’s support for dynamic types (Cheney and Hinze, 2002; =-=Baars and Swierstra, 2002-=-) to allow references to different types. Concretely, this would involve the following changes: • Replacing the occurrences of Data in the IOs type with Dynamic and adapting the smart constructors to ... |

55 | Generic programming within dependently typed programming
- Altenkirch, McBride
(Show Context)
Citation Context ...Haskell’s type classes, the data type U is closed. We cannot add new types to the universe without extending the data type U and the function el. Such universes can been used for generic programming (=-=Altenkirch and McBride, 2003-=-; Morris et al., 2007; Morris, 2007) or interfacing to foreign data (Oury and Swierstra, 2008). We will encounter another application in the next chapter. 74Chapter 6 A Total Specification of Mutable... |

54 |
Kemal Ebcioglu, Christoph von Praun, and Vivek Sarkar. X10: an object-oriented approach to non-uniform cluster computing
- Charles, Grothoff, et al.
- 2005
(Show Context)
Citation Context ...ogramming on multicore machines. Researchers have proposed several new languages to maximise the potential speedup that multicore processors offer (Allen et al., 2005; Chamberlain et al., 2005, 2000; =-=Charles et al., 2005-=-; Scholz, 2003). Although all these languages are different, they share the central notion of a distributed array, where the elements of an array may be distributed over separate processors or even ov... |

46 |
The fortress language specification
- Allen, Chase, et al.
- 2007
(Show Context)
Citation Context ...row’s programming languages must embrace parallel programming on multicore machines. Researchers have proposed several new languages to maximise the potential speedup that multicore processors offer (=-=Allen et al., 2005-=-; Chamberlain et al., 2005, 2000; Charles et al., 2005; Scholz, 2003). Although all these languages are different, they share the central notion of a distributed array, where the elements of an array ... |

39 | Parameterised notions of computation
- Atkey
(Show Context)
Citation Context ...f type el u, it extends the heap with this value; the second argument of New may then use this fresh reference to continue the computation in a larger heap. The IO data type is a parameterised monad (=-=Atkey, 2006-=-) – a monad with return and bind operators that satisfy certain coherence conditions with respect to the Shape indices. 77return : forall {s a} → a → IO a s s return = Return >>= : forall {s t u a b}... |

36 | Interactive programs in dependent type theory - Hancock, Setzer - 2000 |

30 | General recursion via coinductive types - Capretta - 2005 |

27 | ZPL: A machine independent programming language for parallel computers - Chamberlain, Choi, et al. |

23 | Nepal – Nested Data Parallelism in Haskell
- Chakravarty, Keller, et al.
(Show Context)
Citation Context ...only be compiled to Haskell. Agda does provide several pragmas to customise how Agda functions are translated to their Haskell counterparts. The ongoing effort to support data parallelism in Haskell (=-=Chakravarty et al., 2001-=-, 2007) may therefore provide us with a most welcome foothold. There are many features of X10 that we have not discussed here at all. Most notably, we have refrained from modelling many of X10’s const... |

13 | Dependent types at work
- Bove, Dybjer
- 2008
(Show Context)
Citation Context ...efore we do so, I will introduce the dependently typed programming language Agda. This chapter will only cover the features of Agda used in the rest of this thesis. There are several other tutorials (=-=Bove and Dybjer, 2008-=-; Norell, 2008) that give a more complete overview of the language. Norell’s thesis (Norell, 2007) documents many of the more technical issues. 5.1 Agda basics Agda is both a pure programming language... |

6 | Functional pearl: Unfolding pointer algorithms - Bird - 2001 |

5 | Vijay Saraswat. Safe arrays via regions and dependent types - Grothoff, Palsberg - 2006 |

5 | Ordinals and Interactive Programs - Hancock - 2000 |

4 |
Functional programming and input/output. Distinguished dissertations in computer science
- Gordon
- 1993
(Show Context)
Citation Context ...har :: IOtt Char = GetChar Return putChar :: Char → IOtt () putChar c = PutChar c (Return ()) This syntax is far from original. Gordon describes a similar approach to doing teletype IO in his thesis (=-=Gordon, 1994-=-), and cites related work dating back more than twenty years (Holmström, 1983; Karlsson, 1981). Rather than use such structures to perform IO, however, we use them to construct a pure model of functio... |

3 |
Category Theory, volume 49 of Oxford Logic Guides
- Awodey
- 2006
(Show Context)
Citation Context ...pure t) = Impure (fmap (fmap f ) t) instance Functor f ⇒ Monad (Term f ) where return x = Pure x (Pure x) >>= f = f x (Impure t) >>= f = Impure (fmap (>>=f ) t) These monads are known as free monads (=-=Awodey, 2006-=-). In general, a structure is called free when it is left-adjoint to a forgetful functor. In this specific instance, the Term data type is a higher-order functor that maps a functor f to the monad Ter... |

3 |
A brief walk through KAOS
- Cupitt
- 1989
(Show Context)
Citation Context ...mposing interactive programs that we would nowadays recognise as being monadic. Gordon (1994) mentions how Cupitt refined Thompson’s combinators when developing the Kent Applicative Operating System (=-=Cupitt, 1989-=-; Turner, 1987). Cupitt discovered the following two primitive combinators: return :: a → interact a comp :: (a → interact b) → interact a → interact b 4These two combinators correspond exactly to th... |

1 | The Java Language Specification - Hall - 1996 |