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

How it works...

We have seen common functions for dealing with map. Typically, the function without the suffix With or WithKey has default behavior. For example, in insert, the default behavior is to replace the existing value. The suffix With takes two values to produce a new value. The suffix WithKey also takes into consideration the key for which we are combining values.

There are two variants of map, Data.Map.Strict and Data.Map.Lazy. Both the modules export the same function names. These functions vary in their strictness. The strict map will immediately evaluate the resulting map, whereas the lazy map will do so lazily by storing the expressions and reducing them only when asked for. 

However, the functor and Applicative instances of ...

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