O'Reilly logo

Haskell Cookbook by Yogesh Sajanikar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Introduction

We have worked on functions, higher order functions, and also worked with data types in Haskell. We have looked at functions such as map and filter in the context of the data type list. In many of these examples, we have taken a function that operates on data of type a and applied them in the context of the list of type a. Look at the following definition of map:

    map :: (a -> b ) -> [a] -> [b]

You can clearly see that we have taken a function that operates on data type a and produces b, and we converted it to a function that takes a list of a and produces a list of b (map :: (a -> b) -> ([a] -> [b])). Instead of the list of a, we can think of some parametric data type T a. Now, we can rewrite the declaration of map as follows: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required