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...

In this recipe, we created two snaplets for two data types: one for MyData, and another for MyApp. The following list shows the important aspects of creating and composing snaplets:

  • The MyData contains a list of strings. The field _someData starts with an underscore. This is done so that makeLenses (a Haskell Template function) can generate a lens for accessing and setting the field. More information about lenses is covered in Chapter 11, Working with Lens and Prism. Note that, in this recipe, we do not use lens as such, and the use of lenses is strictly restricted to only where Snap APIs demand.

  • The makeSnaplet function takes the snaplet name, description, and an optional data directory on the disc. Here we have used ...

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