A Simple Semantics for Polymorphic Recursion* - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

A Simple Semantics for Polymorphic Recursion*

Description:

– PowerPoint PPT presentation

Number of Views:41
Avg rating:3.0/5.0
Slides: 19
Provided by: csMis
Category:

less

Transcript and Presenter's Notes

Title: A Simple Semantics for Polymorphic Recursion*


1
A Simple Semantics for Polymorphic Recursion
  • William L. Harrison, Ph.D
  • Department of Computer Science
  • University of Missouri, Columbia

This research supported in part by subcontract
GPACS0016, System Information Assurance II,
through OGI/Oregon Health Sciences University.
2
What is polymorphic recursion?
Compact list-like structure Okasaki98
size runs in O(log n), list length in O(n)
Polymorphic recursion useful in generic
programming Hinze00,HinzeJeuring02
3
polymorphic recursion aka non-uniform
recursion
size Seq a?Int
size Seq (a,a)?Int
length a?Int
length a?Int
4
Roadmap
  • Ohori 89 conservatively extends semantics of STLC
    to Core-ML
  • Harrison/Kieburtz 05 extend to model logic of
    Haskell demand
  • Present work models recursion in Haskell
  • Remaining aspects seem to fit well in this
    framework
  • In particular, type classes
  • Goal H98 semantics akin to Definition of
    Standard ML

Goal Haskell 98 Semantics
Simple Model for Polymorphic Recursion APLAS05
Demand in Haskell 98 JFP05
Simple Model for ML Polymorphism Ohori89
5
Background Frame Models
is a frame model iff
6
Simple Model for ML polymorphism Ex (?x.x)
?a.a?a
Denotes at any instance
Simple Model conservatively extends model of
simply-typed ?-calculus
An alternative HarperMitchell93 is to model
type quantifiers with type abstraction as in
System F/polymorphic ?-calculus Girard,Reynolds
7
Language for Polymorphic Recursion
  • Language combines features of Kfoury93
    Ohori89
  • special pfix binder for polymorphic recursive
    definitions
  • stratified type language simple, open, and
    universal

Abstract Syntax for PR
8
Type Syntax
Stratified Types
? is an instantiation
if, and only if
9
Typing Rules for PR
PR rules Kfoury93
Hindley-Milner
Type system is syntax-oriented Kfoury93 I.e.,
derivations are unique modulo application
order of GEN rule.
10
Typing Rules for PR
Leaf in the type derivation of size
11
Pointed CPO Frames
  • is a pcpo frame if each D?
    is a pointed cpo w.r.t. , , and

Ex.
For ? Int?Int,
Where continuity and fix are defined
conventionally
12
Where do we solve equations such as
?
size Seq a?Int
size Seq (a,a)?Int
lives in DSeq(?)?Int
lives in DSeq(?? ?)?Int
13
Defining pcpo frame P in terms of a given pcpo
frame D
Frame Objects are type-indexed sets of values
Other Structure (lub p.o. defined pointwise)
By Theorem 1 in the paper, P is a pcpo frame
14
Frame Semantics of PR
VAR
PFIX
where
Semantics defined by induction on type derivations
15
Application Haskell Type Classes
The Eq class
defines () at infinitely many types
Without Poly-Rec, any Haskell program uses
finitely many, statically determinable instances
of () Jones94 not true with Poly-Rec
With the Simple Model, dictionaries are just
denotations
16
Historical Note
Polymorphic Recursion entered Haskell through a
backdoor when certain expert programmers
noticed that the following variety of kludge
worked.
17
Related Work
  • Mycroft 84 introduced PR gave a model based on
    ideals MacQueen, et al. 84
  • Cousot 97 formulated a hierarchy of type systems
    (including Mycrofts) in terms of lattice of
    abstract interpretations of untyped lambda
    calculus
  • Henglein 93 showed PR type inference is
    undecidable
  • Kfoury, et al. 93, gave several type systems for
    PR ours is called ML/1
  • Models of Type classes WadlerBlott89, Thatte94,
    StuckeySulzmann04 and Higher-order polymorphism
    Jones93

18
Conclusions
  • Textbook semantics
  • Substance of denotations change (type awareness)
  • Form of semantic definitions mostly familiar
  • Conservative extension of Simple Model of ML
    Polymorphism
  • Straightforward, albeit non-trivial
  • Present work models recursion in Haskell
  • Remaining aspects seem to fit well type classes
    higher-order polymorphism

Goal Haskell 98 Semantics
Simple Model for Polymorphic Recursion APLAS05
Demand in Haskell 98 JFP05
Simple Model for ML Polymorphism Ohori89
Write a Comment
User Comments (0)
About PowerShow.com