Haskell presentation

the slides from my Haskell presentation

Published on March 19, 2014

Here are the slides from my presentation of Haskell in the Hackerspace Trento. I tried to present some of the core concepts of Haskell, to a technical audience that have mostly experience in imperative programming. I showed notably the key aspects of Haskell: functional, pure, lazy and statically typed, and I tried to transmit my enthusiasm for the language!

Toward the end of the presentation, I chose to give an understanding of IO in Haskell without talking about monads: monads are certainly too advanced for a first contact with Haskell. Especially because a monad, as short as the definition is, uses 4 new concepts to beginners: type classes, type parameters, higher order functions and sugar notation. Among the 4, only the higher order functions were covered in this lecture.

Instead I used the metaphor of “passing the World around” in each IO-involved functions (see slides 18). This allows to show that pure functions, while not being able to “perform” IO at the moment they are run, can “program” IO by putting instructions in the “World” data structure that they output. That makes these IO functions chainable.

How can we make an impure program (a pure, effectless program would not be very useful), using a pure language? When compiling an executable, your compiled code is put together with what is called a “runtime system” (see slide 19). The runtime system takes care of executing the IO instructions that are found in the “World” data structure. This run time system is certainly not pure. However, it will call your pure instructions through the main, and react to IO programmed by IO functions that are passed through the World structure. The key point to understand is that you can create an impure program by putting together a runtime system calling pure language instructions.

I went on saying that passing the whole state of the world would be quite heavy indeed, so we use a special construct called a monad. This construct allows us to hide the heavy carrying of the World between functions. Monads come with a syntactic sugar called do notation that allows us to write those neat imperative style IOs.

Hope that was understandable :) Thanks to the cool guys in the Hackerspace!

Source of the slides.

Comments