Loading user information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading user information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

C9 Lectures: Dr. Erik Meijer - Functional Programming Fundamentals Chapter 10 of 13

45 minutes, 7 seconds


Right click “Save as…”

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.


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


Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation
  • 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 Smiley) 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.

  • CharlesCharles Welcome Change

    Me too! Smiley


    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,



  • Bent Rasmussenexoteric stuck in a loop, for a while

    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. Smiley .  Thanks for taking the time to produce them. I’m looking forward to see this lecture tonight.

  • David Chuchudq Life is beautiful, and sharing is ​wonderful&#​33;

    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


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.