Entries:
Posts:

Something went wrong getting user information from Channel 9

Latest Achievement:

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Something went wrong getting the Visual Studio Achievements

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

• Posted: Nov 26, 2009 at 10:48 AM
• Avg Rating: 5

(11)
• 75,615 Views

Right click “Save as…”

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.

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

Tags:

• Oops, something didn't work.

Getting "follow" information
• 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  =)

• 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.

• 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.

• 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

• 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  =)

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

• Where are you located?
C

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

• 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!

• 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

• 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

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

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

C

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

• Erik has mentioned "the forums" several times now.

Please can someone supply the Url ?

Thanks

•

...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...

• 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

• Hi Charles,

Thanks

• 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

• Hi Charles

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

• 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.

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

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

•

Banned spammer. Removed spam.

C

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.

• 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

• Charles,

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

C

• 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 ...

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

11,

C

• 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.

• 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

• 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.

• 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.

• 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!

• 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++

C

• 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

Arrows

Zippers

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

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

Thanks for the topic list.

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

C

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

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.