Advanced Type System Features Tom Schrijvers. Leuven Haskell User Group

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "Advanced Type System Features Tom Schrijvers. Leuven Haskell User Group"

Transcription

1 Advanced Type System Features Tom Schrijvers Leuven Haskell User Group

2 Data Recursion Genericity Schemes Expression Problem Monads GADTs DSLs Type Type Families Classes Lists and Effect Free Other Handlers Theorems Monoids

3 Data Recursion Genericity Schemes Expression Problem Monads GADTs GADTS DSLs Type Type Families Classes Lists and Effect Free Other Handlers Theorems Monoids

4 Static Type System

5 Static Type System Lightweight specifications Verified / enforced by the type checker

6 Static Type System

7 Static Type System Rules out many invalid programs

8 Static Type System Rules out many invalid programs Rules out some valid programs

9 Advanced Type Systems accept more valid programs accept fewer invalid programs

10 Advanced Type Systems accept more valid programs Java 5 generics Java 4 accept fewer invalid programs

11 A Problem with Expressions

12 Expressions data Exp = ILit Int Add Exp Exp eval :: Exp -> Int eval (ILit n) = n eval (Add e1 e2) = eval e1 + eval e2

13 More Expressions data Exp = ILit Int Add Exp Exp BLit Bool

14 Revised Evaluator eval :: Exp -> Int eval (ILit n) = n eval (Add e1 e2) = eval e1 + eval e2 eval (BLit b) = b

15 Revised Evaluator eval :: Exp -> Int eval (ILit n) = n eval (Add e1 e2) = eval e1 + eval e2 eval (BLit b) = b

16 Revised Evaluator data Val = IVal Int BVal Bool eval :: Exp -> Val eval (ILit n) = n eval (Add e1 e2) = eval e1 + eval e2 eval (BLit b) = b

17 Revised Evaluator data Val = IVal Int BVal Bool eval :: Exp -> Val eval (ILit n) = n eval (Add e1 e2) = eval e1 + eval e2 eval (BLit b) = b

18 Revised Evaluator data Val = IVal Int BVal Bool eval :: Exp -> Val eval (ILit n) = IVal n eval (Add e1 e2) = IVal (eval e1 + eval e2) eval (BLit b) = BVal b

19 Revised Evaluator data Val = IVal Int BVal Bool eval :: Exp -> Val eval (ILit n) = IVal n eval (Add e1 e2) = IVal (eval e1 + eval e2) eval (BLit b) = BVal b

20 Revised Evaluator data Val = IVal Int BVal Bool eval :: Exp -> Val eval (ILit n) = IVal n eval (Add e1 e2) = case (eval e1, eval e2) of (IVal n1, IVal n2) -> IVal (n1+n2) eval (BLit b) = BVal b

21 Revised Evaluator data Val = IVal Int BVal Bool eval :: Exp -> Val eval (ILit n) = IVal n eval (Add e1 e2) = case (eval e1, eval e2) of (IVal n1, IVal n2) -> IVal (n1+n2) _ ->??? eval (BLit b) = BVal b

22 Revised Evaluator data Val = IVal Int BVal Bool eval :: Exp -> Maybe Val eval (ILit n) = IVal n eval (Add e1 e2) = case (eval e1, eval e2) of (IVal n1, IVal n2) -> IVal (n1+n2) _ -> Nothing eval (BLit b) = BVal b

23 Revised Evaluator data Val = IVal Int BVal Bool eval :: Exp -> Maybe Val eval (ILit n) = IVal n eval (Add e1 e2) = case (eval e1, eval e2) of (IVal n1, IVal n2) -> IVal (n1+n2) _ -> Nothing eval (BLit b) = BVal b

24 Revised Evaluator data Val = IVal Int BVal Bool eval :: Exp -> Maybe Val eval (ILit n) = Just (IVal n) eval (Add e1 e2) = case (eval e1, eval e2) of (IVal n1, IVal n2) -> Just (IVal (n1+n2)) _ -> Nothing eval (BLit b) = Just (BVal b)

25 Revised Evaluator data Val = IVal Int BVal Bool eval :: Exp -> Maybe Val eval (ILit n) = Just (IVal n) eval (Add e1 e2) = case (eval e1, eval e2) of (IVal n1, IVal n2) -> Just (IVal (n1+n2)) _ -> Nothing eval (BLit b) = Just (BVal b)

26 Revised Evaluator data Val = IVal Int BVal Bool eval :: Exp -> Maybe Val eval (ILit n) = Just (IVal n) eval (Add e1 e2) = case (eval e1, eval e2) of (Just (IVal n1), Just (IVal n2)) -> Just (IVal (n1+n2)) _ -> Nothing eval (BLit b) = Just (BVal b)

27 Revised Evaluator data Val = IVal Int BVal Bool eval :: Exp -> Maybe Val eval (ILit n) = Just (IVal n) eval (Add e1 e2) Overhead due to possibly ill-typed expressions = case (eval e1, eval e2) of (Just (IVal n1), Just (IVal n2)) -> Just (IVal (n1+n2)) _ -> Nothing eval (BLit b) = Just (BVal b)

28 GADTs to the Rescue

29 The Problem admits invalid values Exp

30 The Problem admits invalid values Exp Add (BLit True) (ILit 5)

31 The Problem accept more valid programs admits invalid values Exp accept fewer invalid programs

32 The Problem accept more valid programs admits invalid values Exp GADTs accept fewer invalid programs

33 The Problem accept more valid programs admits invalid values Exp Exp a GADTs accept fewer invalid programs

34 The Problem accept more valid programs admits invalid values Exp admits only valid values Exp a GADTs accept fewer invalid programs

35 Parametrised Expressions Exp a

36 Parametrised Expressions Expressions that yield a value of type a type a Exp a

37 Parametrised Expressions Expressions that yield a value of type a type a Exp a indexed family index

38 Parametrised Expressions Expressions that yield a value of type a type a Exp a indexed family index family members Exp Int Exp Bool

39 Parametrised Expressions Expressions that yield a value of type a type a Exp a indexed family index family members Exp Int Exp Bool ILit 0 Add (ILit 1) (ILit 2)

40 Parametrised Expressions Expressions that yield a value of type a type a Exp a indexed family index family members Exp Int ILit 0 Exp Bool BLit True Add (ILit 1) (ILit 2) BLit False

41 Generalized Algebraic Data Type data Exp where ILit :: Int -> Exp Add :: Exp -> Exp -> Exp BLit :: Bool -> Exp

42 Generalized Algebraic Data Type data Exp a where ILit :: Int -> Exp Int Add :: Exp Int -> Exp Int -> Exp Int BLit :: Bool -> Exp Bool

43 Generalized Algebraic Data Type indexed family data Exp a where ILit :: Int -> Exp Int Add :: Exp Int -> Exp Int -> Exp Int BLit :: Bool -> Exp Bool

44 Generalized Algebraic Data Type indexed family Refined index data Exp a where ILit :: Int -> Exp Int Add :: Exp Int -> Exp Int -> Exp Int BLit :: Bool -> Exp Bool

45 GADT Evaluator eval :: Exp a -> a eval (ILit n) = n eval (Add e1 e2) = eval e1 + eval e2 eval (BLit b) = b

46 GADT Evaluator eval :: Exp a -> a No noise due to possibly ill-typed expressions! eval (ILit n) = n eval (Add e1 e2) = eval e1 + eval e2 eval (BLit b) = b

47 GADT Evaluator eval :: Exp a -> a No noise due to possibly ill-typed expressions! eval (ILit n) = n From the pattern match we know that a = Int eval (Add e1 e2) = eval e1 + eval e2 eval (BLit b) = b

48 GADT Evaluator eval :: Exp a -> a No noise due to possibly ill-typed expressions! eval (ILit n) = n From the pattern match we know that a = Int eval (Add e1 e2) = eval e1 + eval e2 eval (BLit b) = b From the pattern match we know that a = Bool

49 GADT Extension data Exp a where ILit :: Int -> Exp Int Add :: Exp Int -> Exp Int -> Exp Int BLit :: Bool -> Exp Bool IfThenElse :: Exp Bool -> Exp a -> Exp a -> Exp a

50 Extended GADT Evaluator eval :: Exp a -> a eval (ILit n) = n eval (Add e1 e2) = eval e1 + eval e2 eval (BLit b) = b eval (IfThenElse i t e) = if eval i then eval t else eval e

51 Alternative Syntax data Exp = ILit Int Add (Exp ) (Exp ) BLit Bool

52 Alternative Syntax data Exp a = a ~ Int => ILit Int a ~ Int => Add (Exp Int) (Exp Int) a ~ Bool => BLit Bool

53 Alternative Syntax data Exp a = a ~ Int => ILit Int a ~ Int => Add (Exp Int) (Exp Int) a ~ Bool => BLit Bool Equality Constraint

54 Alternative Syntax data Exp a = a ~ Int => ILit Int a ~ Int => Add (Exp Int) (Exp Int) a ~ Bool => BLit Bool Equality Constraint a ~ Int a equals Int

55 Ensure & Assume Construct value ILit n :: Exp a Type checker has to assure that a ~ Int

56 Ensure & Assume Construct value ILit n :: Exp a Type checker has to assure that a ~ Int Deconstruct value case e :: Exp a of ILit n -> body Type checker can assume that a ~ Int

57 Length-Indexed Lists with GADTs

58 Regular Lists data List a = Nil Cons a (List a) head :: List a -> a head (Cons x xs) = x

59 Regular Lists data List a = Nil Cons a (List a) head :: List a -> a head (Cons x xs) = x

60 Regular Lists data List a = Nil Cons a (List a) head :: List a -> a head (Cons x xs) = x crashes on empty list!

61 The Problem crashes on empty list head List a

62 The Problem crashes on empty list head List a head Nil

63 The Problem accept more valid programs crashes on empty list head List a accept fewer invalid programs

64 The Problem accept more valid programs crashes on empty list head List a GADTs accept fewer invalid programs

65 The Problem accept more valid programs crashes on empty list head List a head List n a GADTs accept fewer invalid programs

66 The Problem accept more valid programs crashes on empty list head List a does not accept head Nil head List n a GADTs accept fewer invalid programs

67 Length-Indexed Lists List n a

68 Length-Indexed Lists List n a indexed family index

69 Length-Indexed Lists List n a indexed family index family members List Z a List (S Z) a List (S (S Z)) a

70 Length-Indexed Lists List n a indexed family index family members List Z a List (S Z) a List (S (S Z)) a Nil Cons x Nil Cons x (Cons y)ni

71 Length-Index List GADT data List a where Nil :: List a Cons :: a -> List a -> List a

72 Length-Index List GADT data List n a where Nil :: List Z a Cons :: a -> List n a -> List (S n) a

73 Length-Index List GADT indexed family data List n a where Nil :: List Z a Cons :: a -> List n a -> List (S n) a

74 Length-Index List GADT indexed family Refined index data List n a where Nil :: List Z a Cons :: a -> List n a -> List (S n) a

75 Length-Index List GADT indexed family Refined index data List n a where Nil :: List Z a Cons :: a -> List n a -> List (S n) a data Z data S n Empty data types: only used as type indices

76 Safe Head data List n a where Nil :: List Z a Cons :: a -> List n a -> List (S n) a head :: List a -> a head (Cons x xs) = x

77 Safe Head data List n a where Nil :: List Z a Cons :: a -> List n a -> List (S n) a head :: List (S n) a -> a head (Cons x xs) = x

78 Safe Head data List n a where Nil :: List Z a Cons :: a -> List n a -> List (S n) a head :: List (S n) a -> a head (Cons x xs) = x > head Nil Couldn't match type Z with S n0 Expected type: List (S n0) a Actual type: List Z a In the first argument of head, namely Nil In the expression: head Nil

79 Safe Zip data List n a where Nil :: List Z a Cons :: a -> List n a -> List (S n) a zip :: List a -> List b -> List (a,b) zip Nil Nil = Nil zip (Cons x xs) (Cons y ys) = Cons (x,y) (zip xs ys) lists of different length!

80 Safe Zip data List n a where Nil :: List Z a Cons :: a -> List n a -> List (S n) a zip :: List n a -> List n b -> List n (a,b) zip Nil Nil = Nil zip (Cons x xs) (Cons y ys) = Cons (x,y) (zip xs ys)

81 Type Families

82 Append? data List n a where Nil :: List Z a Cons :: a -> List n a -> List (S n) a append :: List n a -> List m a -> List? a append Nil ys = ys append (Cons x xs) ys = Cons x (append xs ys)

83 Append? data List n a where Nil :: List Z a Cons :: a -> List n a -> List (S n) a append :: List n a -> List m a -> List? a append Nil ys n + m = ys append (Cons x xs) ys = Cons x (append xs ys)

84 Append? data List n a where Nil :: List Z a Cons :: a -> List n a -> List (S n) a append :: List n a -> List m a -> List? a append Nil ys n + m = ys append (Cons x xs) ys = Cons x (append xs ys) type-level computation

85 The Problem append

86 The Problem accept more valid programs append accept fewer invalid programs

87 The Problem accept more valid programs Type Families append accept fewer invalid programs

88 The Problem accept more valid programs append Type Families append accept fewer invalid programs

89 Type Family aka Type Function type family Add n m where Add Z m = m Add (S n) m = S (Add n m)

90 Append with Type Family type family Add n m where Add Z m = m Add (S n) m = S (Add n m) append :: List n a -> List m a -> List (Add n m) a append Nil ys = ys append (Cons x xs) ys = Cons x (append xs ys)

91 Open & Associated Type Families

92 Collect Type Class class Collect c where insert :: c ->? -> c

93 Elem Type Family (open) type class declaration class Collect c where insert :: c -> Elem c -> c type family Elem c open type family declaration

94 Instances type class instance instance Collect [e] where insert l c = c : l type instance Elem [e] = e type family instance

95 Open Nature type instance Elem [e] = e instance Collect [e] where insert l c = c : l type instance Elem ByteString = Word8 instance Collect ByteString where insert l c = cons c l

96 Open Nature type instance Elem [e] = e instance Collect [e] where insert l c = c : l type instance Elem ByteString = Word8 instance Collect ByteString where insert l c = cons c l double instances

97 Associated Type Family class Collect c where type Elem c insert :: c -> Elem c -> c instance Collect [e] where type Elem [e] = e insert l c = c : l instance Collect ByteString where type Elem ByteString = Word8 insert l c = cons c l

98 Associated Type Family class Collect c where type Elem c insert :: c -> Elem c -> c instance Collect [e] where type Elem [e] = e insert l c = c : l instance Collect ByteString where type Elem ByteString = Word8 insert l c = cons c l

99 Summary

100 Advanced Type System Features Generalised Algebraic Data Types Type-level Functions aka Type Families

101 Advanced Type System Features Generalised Algebraic Data Types Type-level Functions aka Type Families accept more valid programs accept fewer invalid programs

102 More To Learn Existential Types Rank-n Polymorphism Kinds: Type Promotion, Kind Polymorphism Type Classes: Functional Dependencies, Resolution Extensions Value-Dependent Types (beyond Haskell)

103 Next time: 19/5/2015

104 Data Recursion Genericity Schemes Expression Problem Monads GADTs DSLs Type Type Families Classes Lists and Effect Free other Handlers Theorems Monoids

105 Data Recursion Genericity Schemes Expression Problem Monads GADTs DSLs Type Type Families Classes Lists Quattro Stagioni Effect Free Handlers Theorems other of Haskell Monoids and

106 Join the Google Group Leuven Haskell User Group

Advanced features of Functional Programming (Haskell)

Advanced features of Functional Programming (Haskell) Advanced features of Functional Programming (Haskell) Polymorphism and overloading January 10, 2017 Monomorphic and polymorphic types A (data) type specifies a set of values. Examples: Bool: the type of

More information

Programming with Math and Logic

Programming with Math and Logic .. Programming with Math and Logic an invitation to functional programming Ed Morehouse Wesleyan University The Plan why fp? terms types interfaces The What and Why of Functional Programming Computing

More information

Advances in Programming Languages

Advances in Programming Languages T O Y H Advances in Programming Languages APL8: Multiparameter Type Classes, Constructor Classes Ian Stark School of Informatics The University of Edinburgh Thursday 4 February Semester 2 Week 4 E H U

More information

GADTs. GADTs in Haskell

GADTs. GADTs in Haskell GADTs GADTs in Haskell ADT vs GADT Algebraic Datatype Data List a = Nil Cons a (List a) Data Tree a b = Tip a Node (Tree a b) b Fork (Tree a b) (Tree a b) Note that types than can be expressed as an ADT

More information

Shell CSCE 314 TAMU. Functions continued

Shell CSCE 314 TAMU. Functions continued 1 CSCE 314: Programming Languages Dr. Dylan Shell Functions continued 2 Outline Defining Functions List Comprehensions Recursion 3 A Function without Recursion Many functions can naturally be defined in

More information

Lecture 4: Higher Order Functions

Lecture 4: Higher Order Functions Lecture 4: Higher Order Functions Søren Haagerup Department of Mathematics and Computer Science University of Southern Denmark, Odense September 26, 2017 HIGHER ORDER FUNCTIONS The order of a function

More information

# true;; - : bool = true. # false;; - : bool = false 9/10/ // = {s (5, "hi", 3.2), c 4, a 1, b 5} 9/10/2017 4

# true;; - : bool = true. # false;; - : bool = false 9/10/ // = {s (5, hi, 3.2), c 4, a 1, b 5} 9/10/2017 4 Booleans (aka Truth Values) Programming Languages and Compilers (CS 421) Sasa Misailovic 4110 SC, UIUC https://courses.engr.illinois.edu/cs421/fa2017/cs421a # true;; - : bool = true # false;; - : bool

More information

Week 5 Tutorial Structural Induction

Week 5 Tutorial Structural Induction Department of Computer Science, Australian National University COMP2600 / COMP6260 Formal Methods in Software Engineering Semester 2, 2016 Week 5 Tutorial Structural Induction You should hand in attempts

More information

Overloading, Type Classes, and Algebraic Datatypes

Overloading, Type Classes, and Algebraic Datatypes Overloading, Type Classes, and Algebraic Datatypes Delivered by Michael Pellauer Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. September 28, 2006 September 28, 2006 http://www.csg.csail.mit.edu/6.827

More information

Polymorphism Overview (1A) Young Won Lim 2/20/18

Polymorphism Overview (1A) Young Won Lim 2/20/18 Polymorphism Overview (1A) Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2

More information

Types in Programming Languages Dynamic and Static Typing, Type Inference (CTM 2.8.3, EPL* 4) Abstract Data Types (CTM 3.7) Monads (GIH** 9)

Types in Programming Languages Dynamic and Static Typing, Type Inference (CTM 2.8.3, EPL* 4) Abstract Data Types (CTM 3.7) Monads (GIH** 9) Types in Programming Languages Dynamic and Static Typing, Type Inference (CTM 2.8.3, EPL* 4) Abstract Data Types (CTM 3.7) Monads (GIH** 9) Carlos Varela Rensselaer Polytechnic Institute September 23,

More information

Booleans (aka Truth Values) Programming Languages and Compilers (CS 421) Booleans and Short-Circuit Evaluation. Tuples as Values.

Booleans (aka Truth Values) Programming Languages and Compilers (CS 421) Booleans and Short-Circuit Evaluation. Tuples as Values. Booleans (aka Truth Values) Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC https://courses.engr.illinois.edu/cs421/fa2017/cs421d # true;; - : bool = true # false;; - : bool =

More information

Concepts of program design Exam January 31, 13:30 16:30

Concepts of program design Exam January 31, 13:30 16:30 Concepts of program design 2016 2017 Exam January 31, 13:30 16:30 Name: Student number: Please read the following instructions carefully: Fill in your name and student number above. Be prepared to identify

More information

Informatics 1 Functional Programming Lecture 12. Data Abstraction. Don Sannella University of Edinburgh

Informatics 1 Functional Programming Lecture 12. Data Abstraction. Don Sannella University of Edinburgh Informatics 1 Functional Programming Lecture 12 Data Abstraction Don Sannella University of Edinburgh Part I Sets as lists without abstraction We will look again at our four ways of implementing sets.

More information

CSc 372. Comparative Programming Languages. 8 : Haskell Function Examples. Department of Computer Science University of Arizona

CSc 372. Comparative Programming Languages. 8 : Haskell Function Examples. Department of Computer Science University of Arizona 1/43 CSc 372 Comparative Programming Languages 8 : Haskell Function Examples Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2013 Christian Collberg Functions over Lists

More information

Lists. Michael P. Fourman. February 2, 2010

Lists. Michael P. Fourman. February 2, 2010 Lists Michael P. Fourman February 2, 2010 1 Introduction The list is a fundamental datatype in most functional languages. ML is no exception; list is a built-in ML type constructor. However, to introduce

More information

Introduction to Functional Programming in Haskell 1 / 56

Introduction to Functional Programming in Haskell 1 / 56 Introduction to Functional Programming in Haskell 1 / 56 Outline Why learn functional programming? The essence of functional programming What is a function? Equational reasoning First-order vs. higher-order

More information

Tuples. CMSC 330: Organization of Programming Languages. Examples With Tuples. Another Example

Tuples. CMSC 330: Organization of Programming Languages. Examples With Tuples. Another Example CMSC 330: Organization of Programming Languages OCaml 2 Higher Order Functions Tuples Constructed using (e1,..., en) Deconstructed using pattern matching Patterns involve parens and commas, e.g., (p1,p2,

More information

Haskell Overloading (1) LiU-FP2016: Lecture 8 Type Classes. Haskell Overloading (3) Haskell Overloading (2)

Haskell Overloading (1) LiU-FP2016: Lecture 8 Type Classes. Haskell Overloading (3) Haskell Overloading (2) Haskell Overloading (1) LiU-FP2016: Lecture 8 Type Classes Henrik Nilsson University of Nottingham, UK What is the type of (==)? E.g. the following both work: 1 == 2 a == b I.e., (==) can be used to compare

More information

Writing code that I'm not smart enough to write. A funny thing happened at Lambda Jam

Writing code that I'm not smart enough to write. A funny thing happened at Lambda Jam Writing code that I'm not smart enough to write A funny thing happened at Lambda Jam Background "Let s make a lambda calculator" Rúnar Bjarnason Task: write an interpreter for the lambda calculus Lambda

More information

Programming Languages Fall 2013

Programming Languages Fall 2013 Programming Languages Fall 2013 Lecture 2: types Prof. Liang Huang huang@qc.cs.cuny.edu Recap of Lecture 1 functional programming vs. imperative programming basic Haskell syntax function definition lazy

More information

Lightweight Invariants with Full Dependent Types

Lightweight Invariants with Full Dependent Types Chapter 29 Lightweight Invariants with Full Dependent Types Edwin Brady 1, Christoph Herrmann 1, Kevin Hammond 1 Category: Position Paper Abstract: Dependent types allow a programmer to express invariant

More information

Algebraic data types. The case against null

Algebraic data types. The case against null Algebraic data types The case against null Motivation PL history (1970's) SML, OCaml, Haskell, Scala, F#, Rust, Swift Variants Null references User-defined Types compound ("Dunedin", 120_000) : string

More information

Introduction to Typed Racket. The plan: Racket Crash Course Typed Racket and PL Racket Differences with the text Some PL Racket Examples

Introduction to Typed Racket. The plan: Racket Crash Course Typed Racket and PL Racket Differences with the text Some PL Racket Examples Introduction to Typed Racket The plan: Racket Crash Course Typed Racket and PL Racket Differences with the text Some PL Racket Examples Getting started Find a machine with DrRacket installed (e.g. the

More information

Intro. Scheme Basics. scm> 5 5. scm>

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

More information

Functional dependencies versus type families and beyond

Functional dependencies versus type families and beyond Functional dependencies versus type families and beyond Martin Sulzmann National University of Singapore Joint work with Tom Schrijvers Functional dependencies versus type families and beyond p.1 What

More information

Programming Languages

Programming Languages CSE 130 : Spring 2011 Programming Languages Lecture 3: Crash Course Ctd, Expressions and Types Ranjit Jhala UC San Diego A shorthand for function binding # let neg = fun f -> fun x -> not (f x); # let

More information

cs242 Kathleen Fisher Reading: Concepts in Programming Languages, Chapter 6 Thanks to John Mitchell for some of these slides.

cs242 Kathleen Fisher Reading: Concepts in Programming Languages, Chapter 6 Thanks to John Mitchell for some of these slides. cs242 Kathleen Fisher Reading: Concepts in Programming Languages, Chapter 6 Thanks to John Mitchell for some of these slides. We are looking for homework graders. If you are interested, send mail to cs242cs.stanford.edu

More information

INTRODUCTION TO HASKELL

INTRODUCTION TO HASKELL INTRODUCTION TO HASKELL PRINCIPLES OF PROGRAMMING LANGUAGES Norbert Zeh Winter 2018 Dalhousie University 1/81 HASKELL: A PURELY FUNCTIONAL PROGRAMMING LANGUAGE Functions are first-class values: Can be

More information

Begin at the beginning

Begin at the beginning Begin at the beginning Expressions (Syntax) Exec-time Dynamic Values (Semantics) Compile-time Static Types 1. Programmer enters expression 2. ML checks if expression is well-typed Using a precise set of

More information

Adding GADTs to OCaml the direct approach

Adding GADTs to OCaml the direct approach Adding GADTs to OCaml the direct approach Jacques Garrigue & Jacques Le Normand Nagoya University / LexiFi (Paris) https://sites.google.com/site/ocamlgadt/ Garrigue & Le Normand Adding GADTs to OCaml 1

More information

CS 360: Programming Languages Lecture 12: More Haskell

CS 360: Programming Languages Lecture 12: More Haskell CS 360: Programming Languages Lecture 12: More Haskell Geoffrey Mainland Drexel University Adapted from Brent Yorgey s course Introduction to Haskell. Section 1 Administrivia Administrivia Homework 5 due

More information

INFOB3TC Solutions for the Exam

INFOB3TC Solutions for the Exam Department of Information and Computing Sciences Utrecht University INFOB3TC Solutions for the Exam Johan Jeuring Monday, 13 December 2010, 10:30 13:00 lease keep in mind that often, there are many possible

More information

How does ML deal with +?

How does ML deal with +? How does ML deal with +? Moscow ML version 2.00 (June 2000) - op +; > val it = fn : int * int -> int - 1 + 1; > val it = 2 : int - 1.0 + 1.0; > val it = 2.0 : real - false + false;! Overloaded + cannot

More information

CS Lecture 5: Pattern Matching. Prof. Clarkson Fall Today s music: Puff, the Magic Dragon by Peter, Paul & Mary

CS Lecture 5: Pattern Matching. Prof. Clarkson Fall Today s music: Puff, the Magic Dragon by Peter, Paul & Mary CS 3110 Lecture 5: Pattern Matching Prof. Clarkson Fall 2014 Today s music: Puff, the Magic Dragon by Peter, Paul & Mary Review Features so far: variables, operators, let expressions, if expressions, functions

More information

Monad Background (3A) Young Won Lim 11/18/17

Monad Background (3A) Young Won Lim 11/18/17 Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published

More information

CSC324- TUTORIAL 5. Shems Saleh* *Some slides inspired by/based on Afsaneh Fazly s slides

CSC324- TUTORIAL 5. Shems Saleh* *Some slides inspired by/based on Afsaneh Fazly s slides CSC324- TUTORIAL 5 ML Shems Saleh* *Some slides inspired by/based on Afsaneh Fazly s slides Assignment 1 2 More questions were added Questions regarding the assignment? Starting ML Who am I? Shems Saleh

More information

Idris: Implementing a Dependently Typed Programming Language

Idris: Implementing a Dependently Typed Programming Language Idris: Implementing a Dependently Typed Programming Language Edwin Brady University of St Andrews ecb10@st-andrews.ac.uk @edwinbrady Type Inference and Automated Proving, Dundee, 12th May 2015 1 / 25 Idris

More information

Recap from last time. Programming Languages. CSE 130 : Fall Lecture 3: Data Types. Put it together: a filter function

Recap from last time. Programming Languages. CSE 130 : Fall Lecture 3: Data Types. Put it together: a filter function CSE 130 : Fall 2011 Recap from last time Programming Languages Lecture 3: Data Types Ranjit Jhala UC San Diego 1 2 A shorthand for function binding Put it together: a filter function # let neg = fun f

More information

Refined typechecking with Stardust

Refined typechecking with Stardust Refined typechecking with Stardust Joshua Dunfield Carnegie Mellon University (current affiliation: McGill University) PLPV 2007 Freiburg, Germany 5 October 2007 1 Conventional Static Typing ML, Haskell,...

More information

Programming in Omega Part 2. Tim Sheard Portland State University

Programming in Omega Part 2. Tim Sheard Portland State University Programming in Omega Part 2 Tim Sheard Portland State University Recall Introduce new kinds Use GADTs to build indexed data Indexed data can supports singleton types (Nat ) relationships between types

More information

Advanced Functional Programming

Advanced Functional Programming Advanced Functional Programming Tim Sheard Polymorphism Hindley-Milner Polymorphism Rank 2 polymorphism Tim Sheard 1 Polymorphism A function is polymorphic if it can work on any kind of argument. f x =

More information

Accurate Step Counting

Accurate Step Counting Accurate Step Counting Catherine Hope and Graham Hutton School of Computer Science and IT University of Nottingham, UK {cvh,gmh}@cs.nott.ac.uk Abstract Starting with an evaluator for a language, an abstract

More information

GHCi: Getting started (1A) Young Won Lim 6/3/17

GHCi: Getting started (1A) Young Won Lim 6/3/17 GHCi: Getting started (1A) Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2

More information

Libraries for Generic Programming in Haskell

Libraries for Generic Programming in Haskell Libraries for Generic Programming in Haskell Johan Jeuring, Sean Leather, José PedroMagalhães, and Alexey Rodriguez Yakushev Universiteit Utrecht, The Netherlands Abstract. These lecture notes introduce

More information

02157 Functional Programming Tagged values and Higher-order list functions

02157 Functional Programming Tagged values and Higher-order list functions Tagged values and Higher-order list functions nsen 1 DTU Informatics, Technical University of Denmark Tagged values and Higher-order list functions MRH 27/09/2012 Part I: Disjoint Sets An Example A shape

More information

Abstract Types, Algebraic Types, and Type Classes

Abstract Types, Algebraic Types, and Type Classes Informatics 1 Functional Programming Lectures 13 and 14 Monday 9 and Tuesday 10 November 2009 Abstract Types, Algebraic Types, and Type Classes Philip Wadler University of Edinburgh Reminders Tutorial

More information

Recap: ML s Holy Trinity

Recap: ML s Holy Trinity Recap: ML s Holy Trinity Expressions (Syntax) Exec-time Dynamic Values (Semantics) Compile-time Static Types 1. Programmer enters expression 2. ML checks if expression is well-typed Using a precise set

More information

Recap. Recap. If-then-else expressions. If-then-else expressions. If-then-else expressions. If-then-else expressions

Recap. Recap. If-then-else expressions. If-then-else expressions. If-then-else expressions. If-then-else expressions Recap Epressions (Synta) Compile-time Static Eec-time Dynamic Types (Semantics) Recap Integers: +,-,* floats: +,-,* Booleans: =,

More information

Scheme. Functional Programming. Lambda Calculus. CSC 4101: Programming Languages 1. Textbook, Sections , 13.7

Scheme. Functional Programming. Lambda Calculus. CSC 4101: Programming Languages 1. Textbook, Sections , 13.7 Scheme Textbook, Sections 13.1 13.3, 13.7 1 Functional Programming Based on mathematical functions Take argument, return value Only function call, no assignment Functions are first-class values E.g., functions

More information

Idris, a language with dependent types Extended Abstract

Idris, a language with dependent types Extended Abstract Idris, a language with dependent types Extended Abstract Edwin Brady School of Computer Science, University of St Andrews, St Andrews, Scotland. Email: eb@cs.st-andrews.ac.uk. Tel: +44-1334-463253, Fax:

More information

CSci 450: Org. of Programming Languages Overloading and Type Classes

CSci 450: Org. of Programming Languages Overloading and Type Classes CSci 450: Org. of Programming Languages Overloading and Type Classes H. Conrad Cunningham 27 October 2017 (after class) Contents 9 Overloading and Type Classes 1 9.1 Chapter Introduction.........................

More information

Lecture 2: List algorithms using recursion and list comprehensions

Lecture 2: List algorithms using recursion and list comprehensions Lecture 2: List algorithms using recursion and list comprehensions Søren Haagerup Department of Mathematics and Computer Science University of Southern Denmark, Odense September 12, 2017 Expressions, patterns

More information

CSCI-GA Final Exam

CSCI-GA Final Exam CSCI-GA 2110-003 - Final Exam Instructor: Thomas Wies Name: Sample Solution ID: You have 110 minutes time. There are 7 assignments and you can reach 110 points in total. You can solve the exercises directly

More information

Polymorphic lambda calculus Princ. of Progr. Languages (and Extended ) The University of Birmingham. c Uday Reddy

Polymorphic lambda calculus Princ. of Progr. Languages (and Extended ) The University of Birmingham. c Uday Reddy 06-02552 Princ. of Progr. Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 6: Polymorphic Type Systems 1. Polymorphic

More information

CSC324 Functional Programming Typing, Exceptions in ML

CSC324 Functional Programming Typing, Exceptions in ML CSC324 Functional Programming Typing, Exceptions in ML Afsaneh Fazly 1 Winter 2013 1 with many thanks to Anya Tafliovich, Gerald Penn, Sheila McIlraith, Wael Aboelsaddat, Tony Bonner, Eric Joanis, Suzanne

More information

Haskell Making Our Own Types and Typeclasses

Haskell Making Our Own Types and Typeclasses Haskell Making Our Own Types and Typeclasses http://igm.univ-mlv.fr/~vialette/?section=teaching Stéphane Vialette LIGM, Université Paris-Est Marne-la-Vallée January 13, 2015 Making Our Own Types and Typeclasses

More information

Applying Type-Level and Generic Programming in Haskell

Applying Type-Level and Generic Programming in Haskell Summer School on Generic and Effectful Programming Applying Type-Level and Generic Programming in Haskell Andres Löh, Well-Typed LLP July 4, 2015 Contents 1 Introduction and type-level programming 5 1.1

More information

Typing Data. Chapter Recursive Types Declaring Recursive Types

Typing Data. Chapter Recursive Types Declaring Recursive Types Chapter 27 Typing Data 27.1 Recursive Types 27.1.1 Declaring Recursive Types We saw in the previous lecture how rec was necessary to write recursive programs. But what about defining recursive types? Recursive

More information

02157 Functional Programming. Michael R. Ha. Tagged values and Higher-order list functions. Michael R. Hansen

02157 Functional Programming. Michael R. Ha. Tagged values and Higher-order list functions. Michael R. Hansen Tagged values and Higher-order list functions nsen 1 DTU Compute, Technical University of Denmark Tagged values and Higher-order list functions MRH 3/10/2017 Overview Disjoint union (or Tagged Values)

More information

Monads. Prof. Clarkson Fall Today s music: Vámanos Pal Monte by Eddie Palmieri

Monads. Prof. Clarkson Fall Today s music: Vámanos Pal Monte by Eddie Palmieri Monads Prof. Clarkson Fall 2017 Today s music: Vámanos Pal Monte by Eddie Palmieri Review Currently in 3110: Advanced topics Futures: Async: deferreds, return, bind Today: Monads Monad tutorials since

More information

Side note: Tail Recursion. Begin at the beginning. Side note: Tail Recursion. Base Types. Base Type: int. Base Type: int

Side note: Tail Recursion. Begin at the beginning. Side note: Tail Recursion. Base Types. Base Type: int. Base Type: int Begin at the beginning Epressions (Synta) Compile-time Static Eec-time Dynamic Types Values (Semantics) 1. Programmer enters epression 2. ML checks if epression is well-typed Using a precise set of rules,

More information

CSE 307: Principles of Programming Languages

CSE 307: Principles of Programming Languages 1 / 63 CSE 307: Principles of Programming Languages Syntax R. Sekar Topics 1. Introduction 2. Basics 3. Functions 4. Data Structures 5. Overview 6. OCAML Performance 2 / 63 3 / 63 Section 1 Introduction

More information

CIS552: Advanced Programming

CIS552: Advanced Programming CIS552: Advanced Programming Handout 8 What is a Parser? A parser is a program that analyzes a piece of text to deine its structure (and, typically, returns a tree representing this structure). The World

More information

Tail Recursion: Factorial. Begin at the beginning. How does it execute? Tail recursion. Tail recursive factorial. Tail recursive factorial

Tail Recursion: Factorial. Begin at the beginning. How does it execute? Tail recursion. Tail recursive factorial. Tail recursive factorial Begin at the beginning Epressions (Synta) Compile-time Static Eec-time Dynamic Types Values (Semantics) 1. Programmer enters epression 2. ML checks if epression is well-typed Using a precise set of rules,

More information

CSE 307: Principles of Programming Languages

CSE 307: Principles of Programming Languages CSE 307: Principles of Programming Languages Syntax R. Sekar 1 / 63 Topics 1. Introduction 2. Basics 3. Functions 4. Data Structures 5. Overview 6. OCAML Performance 2 / 63 Section 1 Introduction 3 / 63

More information

Functional Paradigm II

Functional Paradigm II Processadors de Llenguatge II Functional Paradigm II Pratt A.7 Robert Harper s SML tutorial (Sec II) Rafael Ramirez Dep Tecnologia Universitat Pompeu Fabra User-Defined Types How to define the new type.

More information

Towards Reasoning about State Transformer Monads in Agda. Master of Science Thesis in Computer Science: Algorithm, Language and Logic.

Towards Reasoning about State Transformer Monads in Agda. Master of Science Thesis in Computer Science: Algorithm, Language and Logic. Towards Reasoning about State Transformer Monads in Agda Master of Science Thesis in Computer Science: Algorithm, Language and Logic Viet Ha Bui Department of Computer Science and Engineering CHALMERS

More information

Programming Languages. Datatypes

Programming Languages. Datatypes Programming Languages Datatypes Review so far Expressions Values Types Many kinds of expressions: 1. Simple 2. Variables 3. Functions Review so far We ve seen some base types and values: Integers, Floats,

More information

L28: Advanced functional programming

L28: Advanced functional programming L28: Advanced functional programming Exercise 2 Due on 8th March 2017 Submission instructions Your solutions for this exericse should be handed in to the Graduate Education Office by 4pm on the due date.

More information

User-Defined Algebraic Data Types

User-Defined Algebraic Data Types 72 Static Semantics User-Defined Types User-Defined Algebraic Data Types An algebraic data type declaration has the general form: data cx T α 1... α k = K 1 τ 11... τ 1k1... K n τ n1... τ nkn introduces

More information

CSE 130 Programming Languages. Lecture 3: Datatypes. Ranjit Jhala UC San Diego

CSE 130 Programming Languages. Lecture 3: Datatypes. Ranjit Jhala UC San Diego CSE 130 Programming Languages Lecture 3: Datatypes Ranjit Jhala UC San Diego News? PA #2 (coming tonight) Ocaml-top issues? Pleas post questions to Piazza Recap: ML s Holy Trinity Expressions (Syntax)

More information

Coq Summer School, Session 2 : Basic programming with numbers and lists. Pierre Letouzey

Coq Summer School, Session 2 : Basic programming with numbers and lists. Pierre Letouzey Coq Summer School, Session 2 : Basic programming with numbers and lists Pierre Letouzey Predened data structures Predened types are actually declared to Coq at load time 1 : Inductive bool := true false.

More information

Type system. Type theory. Haskell type system. EDAN40: Functional Programming Types and Type Classes (revisited)

Type system. Type theory. Haskell type system. EDAN40: Functional Programming Types and Type Classes (revisited) Type system EDAN40: Functional Programming Types and Type Classes (revisited) Jacek Malec Dept. of Computer Science, Lund University, Sweden April 3rd, 2017 In programming languages, a type system is a

More information

News. Programming Languages. Recap. Recap: Environments. Functions. of functions: Closures. CSE 130 : Fall Lecture 5: Functions and Datatypes

News. Programming Languages. Recap. Recap: Environments. Functions. of functions: Closures. CSE 130 : Fall Lecture 5: Functions and Datatypes CSE 130 : Fall 2007 Programming Languages News PA deadlines shifted PA #2 now due 10/24 (next Wed) Lecture 5: Functions and Datatypes Ranjit Jhala UC San Diego Recap: Environments Phone book Variables

More information

List Processing in Ocaml

List Processing in Ocaml CS251 Programming Languages Handout # 14 Prof. Lyn Turbak February 2, 2007 Wellesley College List Processing in Ocaml Given a list of integers ns, suppose we want to return a new list of the same length

More information

PROGRAMMING IN HASKELL. Chapter 2 - First Steps

PROGRAMMING IN HASKELL. Chapter 2 - First Steps PROGRAMMING IN HASKELL Chapter 2 - First Steps 0 The Hugs System Hugs is an implementation of Haskell 98, and is the most widely used Haskell system; The interactive nature of Hugs makes it well suited

More information

Monad Background (3A) Young Won Lim 11/20/17

Monad Background (3A) Young Won Lim 11/20/17 Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published

More information

Scheme: Data. CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, April 3, Glenn G.

Scheme: Data. CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, April 3, Glenn G. Scheme: Data CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, April 3, 2017 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks ggchappell@alaska.edu

More information

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End Outline Semantic Analysis The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors

More information

Programming Languages

Programming Languages CSE 130 : Winter 2009 Programming Languages News PA 2 out, and due Mon 1/26 5pm Lecture 5: Functions and Datatypes t UC San Diego Recap: Environments Phone book Variables = names Values = phone number

More information

Comp 311 Functional Programming. Eric Allen, Two Sigma Investments Robert Corky Cartwright, Rice University Sagnak Tasirlar, Two Sigma Investments

Comp 311 Functional Programming. Eric Allen, Two Sigma Investments Robert Corky Cartwright, Rice University Sagnak Tasirlar, Two Sigma Investments Comp 311 Functional Programming Eric Allen, Two Sigma Investments Robert Corky Cartwright, Rice University Sagnak Tasirlar, Two Sigma Investments How to Decide Between Structural and Generative Recursion

More information

Inductive Data Types

Inductive Data Types Inductive Data Types Lars-Henrik Eriksson Functional Programming 1 Original slides by Tjark Weber Lars-Henrik Eriksson (UU) Inductive Data Types 1 / 42 Inductive Data Types Today Today New names for old

More information

Edward Kmett. Iteratees, Parsec, and Monoids A PARSING TRIFECTA

Edward Kmett. Iteratees, Parsec, and Monoids A PARSING TRIFECTA Edward Kmett Iteratees, Parsec, and Monoids A PARSING TRIFECTA Overview The Problem Deriving Iteratees á la Oleg Buffered Iteratees Layering Parsec Over Iteratees Local Context-Sensitivity Monoids From

More information

Combining Programming with Theorem Proving

Combining Programming with Theorem Proving Combining Programming with Theorem Proving Chiyan Chen and Hongwei Xi Boston University Programming with Theorem Proving p.1/27 Motivation for the Research To support advanced type systems for practical

More information

Functional Programming TDA 452, DIT 142

Functional Programming TDA 452, DIT 142 Chalmers Göteborgs Universitet 2018-01-11 Examiner: Thomas Hallgren, D&IT, Answering questions at approx 15.00 (or by phone) Functional Programming TDA 452, DIT 142 2018-01-11 14.00 18.00 Samhällsbyggnad

More information

Types, Type Inference and Unification

Types, Type Inference and Unification Types, Type Inference and Unification Mooly Sagiv Slides by Kathleen Fisher and John Mitchell Cornell CS 6110 Summary (Functional Programming) Lambda Calculus Basic ML Advanced ML: Modules, References,

More information

Programming Languages

Programming Languages What about more complex data? CSE 130 : Fall 2012 Programming Languages Expressions Values Lecture 3: Datatypes Ranjit Jhala UC San Diego Types Many kinds of expressions: 1. Simple 2. Variables 3. Functions

More information

Functional programming with OCaml. Programming with OCaml. Fall Software Foundations CIS 500. OCaml and this course. Announcements. features.

Functional programming with OCaml. Programming with OCaml. Fall Software Foundations CIS 500. OCaml and this course. Announcements. features. CIS 500 Software Foundations Fall 2004 Programming with OCaml IS 500, Programming with OCaml 1 Functional programming with OCaml IS 500, Programming with OCaml 3 Announcements Homework 1 was due at noon.

More information

Documentation for the Idris Language. Version 0.99

Documentation for the Idris Language. Version 0.99 Documentation for the Idris Language Version 0.99 Contents 1 The Idris Tutorial 2 2 Frequently Asked Questions 61 3 The Effects Tutorial 66 4 Theorem Proving 98 5 Language Reference 109 6 Tutorials on

More information

Abstract Interpretation Using Laziness: Proving Conway s Lost Cosmological Theorem

Abstract Interpretation Using Laziness: Proving Conway s Lost Cosmological Theorem Abstract Interpretation Using Laziness: Proving Conway s Lost Cosmological Theorem Kevin Watkins CMU CSD POP Seminar December 8, 2006 In partial fulfillment of the speaking skills requirement ? 2111 1231

More information

Parametricity. Types Are Documentation. Tony Morris

Parametricity. Types Are Documentation. Tony Morris Parametricity Types Are Documentation Tony Morris The Journey Fast and loose reasoning is morally correct Danielsson, Hughes, Jansson & Gibbons [DHJG06] tell us: Functional programmers often reason about

More information

TYPE INFERENCE. François Pottier. The Programming Languages Mentoring ICFP August 30, 2015

TYPE INFERENCE. François Pottier. The Programming Languages Mentoring ICFP August 30, 2015 TYPE INFERENCE François Pottier The Programming Languages Mentoring Workshop @ ICFP August 30, 2015 What is type inference? What is the type of this OCaml function? let f verbose msg = if verbose then

More information

Specifications. Prof. Clarkson Fall Today s music: Nice to know you by Incubus

Specifications. Prof. Clarkson Fall Today s music: Nice to know you by Incubus Specifications Prof. Clarkson Fall 2015 Today s music: Nice to know you by Incubus Question Would you like a tiny bonus to your final grade for being here on time today? A. Yes B. Sí C. Hai D. Haan E.

More information

General Computer Science (CH ) Fall 2016 SML Tutorial: Practice Problems

General Computer Science (CH ) Fall 2016 SML Tutorial: Practice Problems General Computer Science (CH08-320101) Fall 2016 SML Tutorial: Practice Problems November 30, 2016 Abstract This document accompanies the traditional SML tutorial in GenCS. It contains a sequence of simple

More information

Monads seen so far: IO vs Gen

Monads seen so far: IO vs Gen Monads David Sands Monads seen so far: IO vs Gen IO A Gen A Instructions to build a value of type A by interacting with the operating system Instructions to create a random value of type A Run by the ghc

More information

Programming Paradigms, Fall 06

Programming Paradigms, Fall 06 Programming Paradigms, Fall 06 Multiple Choice Exam January 29, 2007, 10:00 11:15 ID Name Each of the following questions has exactly one correct answer. For each question, you may select one or more answers

More information

Type Systems. Parametric Polymorphism. 1. Recall Let-Polymorphism. 1. Recall Let-Polymorphism. Lecture 9 Dec. 15th, 2004 Sebastian Maneth

Type Systems. Parametric Polymorphism. 1. Recall Let-Polymorphism. 1. Recall Let-Polymorphism. Lecture 9 Dec. 15th, 2004 Sebastian Maneth Today Parametric Polymorphism Type Systems Lecture 9 Dec. 15th, 2004 Sebastian Maneth 1. Recall Let-Polymorphism 4. System F-sub 5. Properties of F-sub http://lampwww.epfl.ch/teaching/typesystems/2004

More information

LECTURE 3. Compiler Phases

LECTURE 3. Compiler Phases LECTURE 3 Compiler Phases COMPILER PHASES Compilation of a program proceeds through a fixed series of phases. Each phase uses an (intermediate) form of the program produced by an earlier phase. Subsequent

More information

Homework 1: Functional Programming, Haskell

Homework 1: Functional Programming, Haskell Com S 541 Programming Languages 1 September 25, 2005 Homework 1: Functional Programming, Haskell Due: problems 1 and 3, Thursday, September 1, 2005; problems 4-9, Thursday, September 15, 2005; remaining

More information