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

Working with Rank-N type

We will be using ST s a monad to convert imperative actions into pure actions. ST Monad provides a strictly isolated mutability. ST monad allows access to mutable memory to be strictly inside the ST monad itself. Once we run an ST monad, the mutability goes away, and we get a referentially transparent function. Thus ST monad is very useful in creating an efficient isolated computation where mutability is strictly isolated from outside world, and, by running it, we can embed it as a pure function.

To be able to isolate ST monad, we will use higher ranked data type in this recipe.

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