Posted By: Charles | Oct 15th @ 8:46 AM | 42,429 Views | 53 Comments
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 3, Dr. Meijer explores types and classes in Haskell. A type is a collection of related values and in Haskell every well-formed expression has a type. Using type inference, these types are automatically calculated at run time. If expression e returns a type t, then e is of type t, e :: t. A function is a mapping of one type to another type and you will learn about new types of functions in this lecture, specifically curried functions: functions that return functions as a result (and functions are values, remember) and polymorphic functions (function with a type that contains one or more type variables).

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

Chapter 1
Chapter 2

Now, we do have a textbook and you should go buy it: The great Graham Hutton's Programming in Haskell. We worked with the publisher, Cambridge University Press, to get all Niners a 20% discount on the book. Now, you don't need the book to learn a great deal from this lecture series since Graham's website has all the slides and samples from the book as well as answers to the exercises. That said, it's highly recommended reading and you should consider it.

The promotion code is 09HASK and it is vaild on both the Hardback:

9780521871723 and Paperback: 9780521692694. The catalog pages are:

Hardback:

http://www.cambridge.org/us/catalogue/catalogue.asp?isbn=9780521871723 and the paperback is:

http://www.cambridge.org/us/catalogue/catalogue.asp?isbn=9780521692694

Note: This special offer is valid until December 31, 2009

Rating:
14
0
wil2300
wil2300
Super #

Thank you - excellent series so far. Also Learn You A Haskell A Great Good (http://learnyouahaskell.com/) is an excellent reference source for some of this material. Thanks again Dr. Meijer.

Some might like my Haskell Cheatsheet at http://cheatsheet.codeslower.com. It's a short reference & mini-tutorial.

 

OK - done pimping now Smiley

 

Justin

wil2300
wil2300
Super #

Well it's the good kind of pimping and that is a nice cheat sheet. I will definitely reference it when my memory fails to remember some construct that I know would be simple in the first place Smiley

Exelent! I was looking forward to the next lecture. Smiley

exoteric
exoteric
I : Next<I>

I like the syntactic symmetry of inverse associativity for function declarations and function applications. 

f :: (Int -> (Int -> Int))         f :: Int -> Int -> Int
     ((f 1) 2)                             f 1 2

So the paranthesis' become denser at the left or the right.

 

The zip function is quite beautiful and metaphoric. Erik's definition

zip :: ([a], [a]) -> [(a, a)]

is super-symmetrical*. But then there is something nagging me (just a little bit) - here currying is suddenly not as pretty anymore because it breaks the symmetry, which is the motivation for Erik's own definition. 3 notions of structure: curried function (function to function to sequence), list (homogeneous unbounded sequence) and tuple (heterogeneous bounded sequence).

 

I assume curried functions can be treated as sequences as well - flipping and reversing arguments. And lazily (always here) so no time is wasted while jusing doing what I think Erik refers to as symbol pushing. Must see...

 

The book has not arrived yet, still waiting. That's not unusual, but hopefully it will arrive before the end of the lecture series.

 

* Sometimes (especially functional) programming language design looks like the search for a unified theory of everything - for computation, types and syntax. Slowly crawling closer and closer to nirvana. Haskell looks like the closest thing so far, although maybe still susceptible to decades of further axiomatization.

AdamSpeight2008
AdamSpeight2008
The Bandito Coder

This episode is so full of Funk it could do with a 70's porno music track.

chudq
chudq
Life is beautiful, and sharing is wonderful!

Last time Eric mentioned his hope about interactive app with C# codes. There is one actually available: LINQPad.net

chudq
chudq
Life is beautiful, and sharing is wonderful!

One question about this:

 

f::Int->Int->Int

or

f::(Int->(Int->Int))

 

I typed those in hugs and they are not recognized syntax. Are those just description about a function?

 

By the way, is there any way to get descriptions like above ones out for a predefined function such as zip?

 

Microsoft Communities