O'Reilly logo

The Haskell School of Expression by Paul Hudak

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

CHAPTER SIX

Shapes III: Perimeters of Shapes

 

 

 

 

 

In this chapter, I will extend the Shape module first introduced in Chapter 2 with the ability to compute the perimeters of geometric shapes. In the process several techniques involving polymorphic higher-order functions learned in the last chapter will be used. I will also introduce a new idea: the infinite list.

Our goal will be to define a new module Perimeter, which imports the Shape module and exports just one function, perimeter, to be defined shortly:

images

This module also does something new: It exports the entire Shape module, as indicated by the phrase “module Shape” in the export list. ...

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