-
Notifications
You must be signed in to change notification settings - Fork 5
Notes for Week 1 Introduction
mattcallanan edited this page Dec 9, 2011
·
2 revisions
Links:
- Rough Weekly Plan
- Outline
- Meetup page
- Great intro to FP: "Guerilla Guide to Pure Functional Programming" vimeo slides
- Great interview with Haskell co-creator (and my rough transcription): Simon Peyton Jones on Functional Programming and Haskell
The three big topics from Chapter 1: Introduction are: purity, laziness, and static-typing.
See the "Guerilla Guide" linked above for examples on purity and Referential Transparency.
To see Haskell's laziness firsthand, fire up ghci and try the following:
>> let doubleMe xs = map (* 2) xs
>> doubleMe [1..] -- generates an infinite list of numbers.
This will print 2,4,6 etc endlessly. Press Ctrl-C to cancel. Next try:
>> head(doubleMe [1..])
Notice the result came back very quickly. That's because Haskell doesn't evaluate "doubleMe [1..]" first... "head" is executed first "doubleMe [1..]" is only invoked when "head" asks for it. All "head" needs is the 1 element of the list so that's all that gets evaluated.
Haskell does "call-by-need" compared to Java's "call-by-value".