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

Sign in to queue

Description

In Chapter 9, Interactive Programs, Dr. Meijer will teach us how to make programs in Haskell that are side-effecting:
interactive. Haskell programs are pure mathematical functions with no side effects. That said, you want to be able to write Haskell programs that can read input from the keyboard and write output to the screen which are in fact side effects. So, interactive programs have side effects... Interactive programs can be written in Haskell by using types to distinguish pure expressions from impure actions that may involve side effects.

Consider the following:

IO a
The type of actions that return values of type a

IO Char
The type of actions that return a character

IO()
The type of purely side effecting actions that return no result value|

Warning: This lecture may contain the use of the term Monad. Do not fear. Everything will be OK. Smiley

You should watch these in sequence (or skip around depending on your curent level of knowledge in this domain):

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

 

Embed

Download

Download this episode

More episodes in this series

Related episodes

The Discussion

  • User profile image
    lambdaf

    Until this US Thanksgiving, I never realized that monads and turkey go together so well!  Thank you Erik for your excellent tutorials.  Hopefully the future of code will be more sane from your efforts  =)

  • User profile image
    exoteric

    To be sure: once an expression involves IO, is it possible to ever derive a type that is not IO'd from it? I suspect not.

     

    Thanks for the palm tree. It's a great place to be lazy, as its recursive structure bends over the ever-changing sea of waves.

  • User profile image
    head.in.the.​box

    You can do that using my all time favorite non-function unsafePerformIO :: IO a -> a. Keep in mind that as the name warns you, it is unsafe, very unsafe.

  • User profile image
    stefanolson

    I'm having a problem downloading or displaying this video. When downloading it gets to 6% and stops.  If I try and display it in the in-line Silverlight player and skip forward to eight minutes or so it has a media failure.  I'm seeing the same problem with many of the PDC videos, e.g (WMV high):

    http://microsoftpdc.com/Sessions/FT24

     

    ...Stefan

  • User profile image
    lambdaf

    In essence, the point of the IO monad is to "tag" values as IO when there's a possibility of state.  Once you enter the dimension of state, you can of course not remove the idea that side effects have occured.  Therefore, it is recommended to keep your code pure.

     

    Using do-notation and the monadic functions, it isn't too hard to make working with monads not too difficult, and for some, fun  =)

  • User profile image
    exoteric

    Now to examine why anyone would want to soil an otherwise clean language, i.e. the use-cases.

  • User profile image
    mihailo

    I cannot download or play WMV file.  Download stops at about 8%.

  • User profile image
    Charles

    Where are you located?
    C

  • User profile image
    GraemeBlack

    Download of WMV finishes for me after 7.90 MB. Please don't make me download WMV (High) !

    I am in New Zealand.

    In general downloading this video series has been very slow. It looks like the maximum bandwidth is about 200KBytes/s . Normally I can get 900K - 1.2 MBytes/s from microsoft.

     

    Still - it is an extremely interesting series and very worthwhile. Even if it just turns out (for me) to be background to F# and Linq.

    -G

  • User profile image
    guercheLE

    Nice you are linking to all previous sessions so it makes easier to get back in time and review what have being said before. You guys rock!

  • User profile image
    stefanolson

    Charles,

     

    I am in New Zealand too.  I'm having problems downloading this file from Channel 9 and a large number of files from the PDC conference.

     

    ...Stefan

  • User profile image
    Charles

    Hmm. Could be do to our CDN (and the distance from you or lack of a node in your region?). I will FW this info to Duncan.

    C

  • User profile image
    sylvan

    I'm in the UK and I had major problems downloading PDC videos. This one seems fine though.

  • User profile image
    mntb

    I am having the same problems. I live in Australia. The downloading stops after a few minutes (using IE).

  • User profile image
    Charles

    Interesting. I will pass this info along to our CDN team.

    C

  • User profile image
    mntb

    I can't download this AVI (using IE). The downloading stops after a few minutes. Same if I use the Silverlight player. I live in Australia and have no problems downloading AVI's from other sites (.NET Rocks, IT Conversations etc.)

  • User profile image
    GRNZ

    I'm another C9 member in New Zealand having the same download problems as others here ...

  • User profile image
    Graham Hay

    Erik has mentioned "the forums" several times now.

     

    Please can someone supply the Url ?

     

    Thanks

     

  • User profile image
    exoteric

    Generic Comment Image

     

    ...And of course, most of all, the thread associated with every lecture video (that would be this one, for example.)

    There's also a fb group for this series, but that's mostly for historical reasons, and for disseminating the content...

  • User profile image
    mihailo

    Hi Charles,

     

    I'm in New Zealand.  I've just tried to download it again and it still does not work.

    WMV and WMV (High) are both broken. Is there and alternative download site?

     

    Thanks

     

  • User profile image
    mihailo

    Hi Charles,

    I'm in New Zealand.  I've just re-tried to download WMV and WMV (High) and both downloads fail.

    Is there an alternative download site?

     

    Thanks

     

     

  • User profile image
    DesB

    I'm in Australia, also can't download any versions of this. Can you let us know what the progress is with resolving this.

     

    Thanks,

    - Des

  • User profile image
    GRNZ

    Hi Charles

     

    Just confirming the experience of others ... downloads to NZ are still broken. The download typically stops after approx 8 MB.

     

    I have been enjoying this series so hope this can be sorted out soon. Thanks!

  • User profile image
    mntb

    I just tried downloading it again today and still the same problem. The download stops after a few minutes. I have tried with both IE and Firefox. I live in Australia and can download from other US websites without any problem.

  • User profile image
    GraemeBlack

    Thanks to whoever fixed up the download problem.  I finally have all 400MB of it.

  • User profile image
    head.in.the.​box

    Wow, spam comments on a discussion about fundamentalist functional programming. That means we have really hit the mainstream baby!!!!!

  • User profile image
    Charles

    Smiley

     

    Banned spammer. Removed spam.

    C

  • User profile image
    reachhasan

    I also have the same problems downloading the mp4 or low-res wmv files. I have tried to download them from two different ISPs Sad in Australia.

     

    I used to be able to download those files within less than 10 minutes. Now, after 3-5 minutes(10-20%)  the connection is lost.

  • User profile image
    Charles

    We have alerted our CDN provider. We have provided the trace data some of you have shared (thanks for that). Waiting to hear back.

    C

  • User profile image
    reachhasan

    Charles,

     

    I tried again after reading your reply twice downloading the mp4 and low-res wmv. Still could only download 10% of it. The initial speed is very fast  but after 2-3 minutes it started to drop to zero.

  • User profile image
    Charles

    We do not know what the problem is. Our CDN is supposed to be figuring it out....

    C

  • User profile image
    head.in.the.​box

    Especially for all our Australian viewers we have a very special episode 11, so keep on watching and let's hope that the download problems are fixed by then ...

  • User profile image
    Charles

    We will have the issue resolved by 10 (or close to 10 or not too far from 10). Smiley

     

    11,

    C

  • User profile image
    Graham Hay

     

     

     

  • User profile image
    reachhasan

    Hi Charles,

     

    I could download it now. Though the speed sometimes fluctuated and was slow. It took me 10 minutes just to download the mp4.

     

    By the way, I wonder whether there will be series talking about F# as this is a "new" language from MS.

     

    It would be good to compare how to do something in F# and Haskell.

     

     

  • User profile image
    Charles

    This basic problem is currently being fixed by ECN. Sorry for the inconvenience. You should be able to download successfully from locations in Australia and New Zealand.

    C

  • User profile image
    cat77xx

    Overall general comment: Microsoft is the best thing to ever happen to the pursuit of higher knowledge by human beings. It is truly sad when competitors attack Microsoft. Are these same competitors giving even 1/10th of what MS gives for FREE to the average computer users? I think not. 

  • User profile image
    fbrubacher

    Hey Erik , I love the series, can you do some more advanced topics when you finish the book, maybe analyze some paper you find interesting (like your paper of recursion schemes -titlte was sth like Glasess, Bananas etc - ? I know it might be tiring to do all these casts but i would very much like to see you explain some advanced topics since you are very good at explaining stuff.

  • User profile image
    head.in.the.​box

    That is a good idea, do a C9 "study group" on advanced FP. We'll need to convince Charles to provide studio and air time. There is plenty more to discuss!

  • User profile image
    Charles

    No need for covincing, my friend. You got it! I love this idea. I would also like to get some other folks involved in the advanced study group series of conversations/lectures (like Luke Hoban and the F# people). We could do this for C# as well. And, dare I say, C++ Smiley

     

    C

  • User profile image
    fbrubacher

    Charles, thanks for the support of the Idea , here are some of the topics i would love for Erik to cover or anyone have a discussion about them (from the top of my head) : 

    QuickCheck

    Applicative functors and Parsec

    Monads (Writer, State, ST) and MonadTransformers

    Arrows

    Zippers

    GADTs

    STM examples (there are some videos explaining the basics by SPJ)

    Recursion Schemes (anamorphisms , catamorphisms)

    Combinators (SK)

    I'm sure i'm forgetting some of them, but I would really love your and Erik's take on these subjects.

     

    Fede

     

  • User profile image
    Charles

    In terms of Monads, Brian Beckman has covered the State Monad in detail here and here.

     

    Thanks for the topic list. Smiley

     

    You will learn about Zippers and much more very soon in an upcoming conversation with Jeffrey Van Gogh and Bart De Smet.

    C

  • User profile image
    zurk

    I'd like to add my +1 for QuickCheck, and for Applicative.  Been enjoying this series a whole lot!  Thanks!

  • User profile image
    exoteric

    I vote for arrows, when we've covered all about monads.

     

    They look like a way to model function composition. In a way monads look like that too, so I wonder what the differences are and when to use what.

Add Your 2 Cents