## Parametricity for Haskell with Imprecise Error Semantics

### Cached

### Download Links

Citations: | 4 - 4 self |

### BibTeX

@MISC{Stenger_parametricityfor,

author = {Florian Stenger and Janis Voigtländer},

title = {Parametricity for Haskell with Imprecise Error Semantics},

year = {}

}

### OpenURL

### Abstract

Types play an important role both in reasoning about Haskell and for its implementation. For example, the Glasgow Haskell Compiler performs certain fusion transformations that are intended to improve program efficiency and whose semantic justification is derived from polymorphic function types. At the same time, GHC adopts a scheme of error raising, propagation, and handling which is nondeterministic in the sense that there is some freedom as to which of a number of potential failure events hidden somewhere in a program is actually triggered. Implemented for good pragmatic reasons, this scheme complicates the meaning of programs and thus necessitates extra care when reasoning about them. In particular, since every erroneous value now represents a whole set of potential (but not arbitrary) failure causes, and since the associated propagation rules are askew to standard notions of program flow and value dependence, some standard laws suddenly fail to hold. This includes laws derived from polymorphic types, popularized as free theorems and at the base of the mentioned kind of fusion. We study this interaction between type-based reasoning and imprecise errors by revising and extending the foundational notion of relational parametricity, as well as further material required to make it applicable. More generally, we believe that our development and proofs help direct the way for incorporating further and other extensions and semantic features that deviate from the “naive ” setting in which reasoning about Haskell programs often takes place.

### Citations

364 |
Types, abstraction and parametric polymorphism
- Reynolds
- 1983
(Show Context)
Citation Context ...lly is a semantic equivalence. Moreover, it is relative to the particular definition of takeWhile given at the very beginning, whereas laws like (1) are often derived more generally as free theorems (=-=Reynolds 1983-=-; Wadler 1989) from types alone, without considering concrete definitions. In this paper we undertake to develop the theory of free theorems for Haskell with imprecise error semantics. This continues ... |

329 | Theorems for free
- Wadler
- 1989
(Show Context)
Citation Context ...ally is a semantic equivalence. Moreover, it is relative to the particular definition of takeWhile given at the very beginning, whereas laws like (1) are often derived more generally as free theorems =-=[7,9]-=- from types alone,without considering concrete definitions. In this paper, we develop the theory of free theorems for Haskell with imprecise error semantics. This continues earlier work [1] for Haske... |

99 | Tackling the awkward squad: monadic input/output, concurrency, exceptions, and foreign-language calls in haskell
- Jones
- 2002
(Show Context)
Citation Context ...2 , respectively. The role of bottom-reflection in the ⊥-only setting is to ensure, via the induction hypothesis corresponding to the precondition Γ ⊢ t1 : τ1, viz. ([t1 ]θ1,σ1, [t1 ]θ2,σ2) ∈ ∆τ1,ρ , =-=(4)-=-that the same branch is chosen in (the analogues of) the two case distinctions above. Here the same can be achieved by introducing an auxiliary function extracting the tag of a value as follows: { Ok... |

74 | Parametric polymorphism and operational equivalence
- Pitts
- 2000
(Show Context)
Citation Context ...[x↦→c]) ∈ ∆τ2,ρ . (5) However, in the case that [t1 ]θ1,σ1 = Bad e1 and [[t1 ]θ2,σ2 = Bad e2, we need to show that (Bad (e1 ∪ E([t2 ] θ1,σ1[x↦→Bad ∅])), Bad (e2 ∪ E([t2 ] θ2,σ2[x↦→Bad ∅]))) ∈ ∆τ2,ρ , =-=(6)-=- and do not yet have the means for doing so. Note that a supposed error-strictness of ∆τ2,ρ would only allow us to conclude the desired membership if the sets e1 ∪ E([t2 ] θ1,σ1[x↦→Bad ∅]) and e2 ∪ E(... |

52 | A semantics for imprecise exceptions
- Jones, Reid, et al.
- 1999
(Show Context)
Citation Context ...eWhile p (map h l) = map h (takeWhile (p ◦ h) l) . (1) But programming language reality can be a tough game, leading to unexpected failures of such near-obvious laws. For example, Peyton Jones et al. =-=[5]-=- proposed a design for error handling based on a certain degree of impreciseness. The major implementations GHC and Hugs have integrated this design years ago. However, the resulting semantics breaks ... |

37 | Free theorems in the presence of seq
- Johann, Voigtländer
- 2004
(Show Context)
Citation Context ... sets thereof) are related? The relevant proof case to check here is the one for the strict-let construct, because selective strictness was what necessitated bottom-reflectingness in the first place (=-=Johann and Voigtländer 2004-=-). Recall that the typing rule is as follows: Γ ⊢ t1 : τ1 Γ, x : τ1 ⊢ t2 : τ2 Γ ⊢ (let! x = t1 in t2) : τ2 . Inside the proof of an analogue of Theorem 2.2 by induction over typing derivations we will... |

26 | Static contract checking for Haskell, in
- Xu, Jones, et al.
(Show Context)
Citation Context ...lar, it should be possible to leverage GHC’s strictness analyzer for also establishing error-strictness, and a sufficient check for error-totality is possible using the strategy employed by Xu et al. =-=[10]-=-, namely symbolic evaluation plus syntactic safety, all ready for the taking in (a branch of) GHC. Acknowledgements. We would like to thank anonymous reviewers for their comments and suggestions. Refe... |

12 | Selective strictness and parametricity in structural operational semantics, inequationally - Voigtländer, Johann |

8 | Imprecise exceptions, coinductively
- Moran, Lassen, et al.
- 1999
(Show Context)
Citation Context ...fixes can be obtained for other free theorems. The accompanying technical report [8] goes on to establish “inequational” parametricity theorems, including one for the refinement order of Moran et al. =-=[3]-=-. Then, for example, slightly weaker conditions than those mentioned above suffice for a variant of (1) in which the left-hand side is only stated to semantically approximate the right-hand side. The ... |

5 | A family of syntactic logical relations for the semantics of Haskell-like languages
- Johann, Voigtländer
- 2002
(Show Context)
Citation Context ...direct syntactical counterparts in the underlying calculus. The set of all erroneous values is then Verr = {Bad e | e ∈ P(E) ∪ {E nt }} 3 and its elements are ordered by Bad e ⊑ Bad e ′ iff e ⊇ e ′ . =-=(2)-=- The operation lift maps complete partial orders to so-called error-lifted cpos (henceforth, for short, elcpos): lift S = Verr ∪{Ok s | s ∈ S}. The approximation order on such an elcpo is given by (2)... |

1 | 31 A Proof of Theorem 2.2 - Jones, Reid, et al. - 1999 |