Lecture Notes
CPSC 326 (Spring 2014)
Todays Topics .
Intro to Haskell
S. Bowers
1 of 4
Lecture Notes
CPSC 326 (Spring 2014)
Very Brief History of Haskell
Prehistory
Alonzo Church invented lambda calculus in the 1930s
John McCarthy created Lisp based on
Lecture Notes
CPSC 326 (Spring 2014)
Today .
Quiz 4
User-dened types (cont.)
Parameterized types
Assignments .
Reading & HW 7 out
S. Bowers
1 of 10
Lecture Notes
CPSC 326 (Spring 2014)
Type Synonyms
The type keyword creates type synonyms
a type synom
Lecture Notes
CPSC 326 (Spring 2014)
Today .
More on recursion
Guards
Assignments .
Reading & HW 5 due
Reading & HW 6 out
S. Bowers
1 of 9
Lecture Notes
CPSC 326 (Spring 2014)
Firsts (warm up)
Q: Use recursion to dene a firsts ps function that takes a
Lecture Notes
CPSC 326 (Spring 2014)
Today .
More on Recursion
Pattern Matching
Assignments .
HW 4 due
HW 5 out
S. Bowers
1 of 9
Lecture Notes
CPSC 326 (Spring 2014)
The Occurs Check Error
Q: How can we dene a flatten function in Haskell?
e.g., flatt
Lecture Notes
CPSC 326 (Spring 2014)
Today .
Quiz 3
More on Recursion
Assignments .
Reading 4 due, Reading 5 out
HW 4 due Thursday
S. Bowers
1 of 6
Lecture Notes
CPSC 326 (Spring 2014)
Recursion (Review)
Sum the elements of a list
1. Sum of the empty
Lecture Notes
CPSC 326 (Spring 2014)
Today .
Quiz 2
Tuples (wrapup)
If-then-else
Local bindings
Assignments .
HW 3, Reading 3 out
S. Bowers
1 of 17
Lecture Notes
CPSC 326 (Spring 2014)
Getting data out of tuples is not so easy
For pairs, can use the
Lecture Notes
CPSC 326 (Spring 2014)
Today .
More on Haskell lists and tuples
Assignments .
HW 2, Reading 2 due
HW 3, Reading 3 out
S. Bowers
1 of 9
Lecture Notes
CPSC 326 (Spring 2014)
List Operations
List concatenation (+)
Returns an entirely new li
Lecture Notes
CPSC 326 (Spring 2014)
Today .
Haskell lists and tuples
Quiz 1
Assignments .
HW 2, Reading 2 out
S. Bowers
1 of 9
Lecture Notes
CPSC 326 (Spring 2014)
First Look at Haskell Typing (More later)
So far we have not needed to declare any type
Lecture Notes
CPSC 326 (Spring 2014)
Today .
Basic Haskell Syntax
Assignments .
HW 1, Reading 1 due
HW 2, Reading 2 out
S. Bowers
1 of 14
Lecture Notes
CPSC 326 (Spring 2014)
Using ghci as a Calculator
From the command line: (using Mac OS X or Linux)
$