C9 Lectures: Dr. Erik Meijer  Functional Programming Fundamentals Chapter 10 of 13
Description
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
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Share
Download
Download this episode
 High Quality WMV (1005.4 MB)
 MP3 (20.7 MB)
 Low Quality MP4 (282.8 MB)
 Mid Quality WMV (393.8 MB)
More episodes in this series
C9 Lectures: Dr. Graham Hutton  Functional Programming Fundamentals Chapter 11 of 13
Related episodes
C9 Lectures: Dr. Erik Meijer  Functional Programming Fundamentals Chapter 13 of 13
C9 Lectures: Dr. Erik Meijer  Functional Programming Fundamentals Chapter 12 of 13
C9 Lectures: Dr. Erik Meijer  Functional Programming Fundamentals Chapter 9 of 13
C9 Lectures: Dr. Erik Meijer  Functional Programming Fundamentals Chapter 8 of 13
C9 Lectures: Dr. Erik Meijer  Functional Programming Fundamentals Chapter 7 of 13
C9 Lectures: Dr. Erik Meijer  Functional Programming Fundamentals Chapter 5 of 13
C9 Lectures: Dr. Erik Meijer  Functional Programming Fundamentals, Chapter 3 of 13
C9 Lectures: Dr. Erik Meijer  Functional Programming Fundamentals, Chapter 1 of 13
C9 Lectures: Graham Hutton  How To Be More Productive
C9 Lectures: Dr. Ralf Lämmel  Going Bananas
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 subclasses late after super class has been defined. The two definitions need not be done simultaneously. Moreover, there is no limit on the number of subclasses 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?