C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 10 of 13
- Posted: Dec 07, 2009 at 4:38 PM
- 53,981 Views
- 8 Comments
Download
How do I download the videos?
- To download, right click the file type you would like and pick “Save target as…” or “Save link as…”
Why should I download videos from Channel9?
- It's an easy way to save the videos you like locally.
- You can save the videos in order to watch them offline.
- If all you want is to hear the audio, you can download the MP3!
Which version should I choose?
- If you want to view the video on your PC, Xbox or Media Center, download the High Quality WMV file (this is the highest quality version we have available).
- If you'd like a lower bitrate version, to reduce the download time or cost, then choose the Medium Quality WMV file.
- If you have a Zune, WP7, iPhone, iPad, or iPod device, choose the low or medium MP4 file.
- If you just want to hear the audio of the video, choose the MP3 file.
Right click “Save as…”
- High Quality WMV (PC, Xbox, MCE)
- MP3 (Audio only)
- MP4 (iPod, Zune HD)
- Mid Quality WMV (Lo-band, Mobile)
We've kicked off
C9 Lectures with a journey into the world of Functional Programming with functional language purist and high priest of the lambda calculus, Dr.
Erik Meijer (you can thank Erik for many of the functional constructs that have shown up in languages like C# and VB.NET. When you use LINQ, thank Erik in addition to Anders).
We will release a new chapter in this series every Thursday.
In Chapter 10, Declaring Types and Classes, Dr. Meijer teaches us about type declarations, data declarations, arithmetic expressions, etc. In Haskell, a new name for an existing type can be defined using a type declaration:
type String = [Char]
String is a synonym for the type [Char].
Like function definitions, type declarations can also have parameters. Type declarations can be nested, but not recursive.
Nested:
type Pos = (Int,Int)
Illegal recursion:
type Tree = (Int,[Tree])
A completely new type can be defined by specifying its values using a data declaration:
data Bool = False | True
Bool is a new type, with two new values False and True.
Get the presentation slides here
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
We will release a new chapter in this series every Thursday.
In Chapter 10, Declaring Types and Classes, Dr. Meijer teaches us about type declarations, data declarations, arithmetic expressions, etc. In Haskell, a new name for an existing type can be defined using a type declaration:
type String = [Char]
String is a synonym for the type [Char].
Like function definitions, type declarations can also have parameters. Type declarations can be nested, but not recursive.
Nested:
type Pos = (Int,Int)
type Trans = Pos -> Pos
Illegal recursion:
type Tree = (Int,[Tree])
A completely new type can be defined by specifying its values using a data declaration:
data Bool = False | True
Bool is a new type, with two new values False and True.
Get the presentation slides here
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Comments Closed
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
I'm so loving these lectures!
Thank you very much Charles and Erik for your work...you're doing a wonderful job!
I'm really looking forward to see the last three (or maybe four
) lectures
Excellent job Erik and C !! We would love very much for you guys to cover some advanced topics in Haskell and Fuctional Programming (as i mentioned in chapter 9 thread ) Thanks and continue with the excellent work.
Me too!
Thank you.
Erik deserves most of the credit here, of course - he's doing the lectures. Me, I just had the idea to do lectures on Channel 9. FP was the clear choice to launch this new content type on C9 because we have spent so much time talking about functional programming over the years that we felt it appropriate to just focus on FP in the most efficient way possible - experts lecturing, teaching.
Keep on watching,
C
Still watching this episode, I just had to say I love how you tied "Theorems for free!" together with dependent typing as well as ADTs!
In progress...
These lectures have been the highlight of my Thursdays.
. Thanks for taking the time to produce them. I’m looking forward to see this lecture tonight.
Today there is big snow in Calgary. I am enjoying the lecture on my Mac. Here is my type: snow a = Nothing | Big snow. Thank you Eric!
Erik: You are talking about "the expression problem" as still being a research subject. However, multimethods (as defined in the language Clojure) elegantly solves the problem?
Eric, a very late question
In object oriented languages, we have the flexibility of defining sub-classes late after super class has been defined. The two definitions need not be done simultaneously. Moreover, there is no limit on the number of sub-classes baring the case of sealed types (which could still be circumvented using containment and defining casts).
In relation to the analogy of algebraic types and class hierarchies, what is the way in Haskell to extend the types as we can do in object oriented languages.
For example:
data Answer = No | Yes
data AnswerEx = FromAnswer Answer | Unknown
fromAnswerEx :: AnswerEx -> Answer
fromAnswerEx FromAnswer a = a
fromAnswerEx Unknown = No -- in Haskell we have to generate a value of Answer type here
We could surely define functions for explicit conversion e.g. fromAnswerEx but the compiles can not use them automatically. In code given below we have to use the explicit conversions.
answers = [Yes, No, fromAnswerEx Unknown, fromAnswerEx FromAnswer Yes]
The following will not work.
answers = [Yes, No, Unknown, FromAnswer Yes]
It is possible there in object oriented languages.
Is there any pattern/idiom in Haskell to achieve same?
Remove this comment
Remove this thread
close