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 EIGHT

A Module of Regions

 

 

 

 

 

In this chapter I will use ideas developed in the last chapter to extend the functionality of geometric shapes defined in Chapter 2. In particular, we will consider the problem of combining shapes into larger, possibly overlapping, regions. We will not be interested in computing the area or perimeter of these regions (no easy task, by the way, with the shapes allowed to overlap in arbitrary ways), but rather we will want to know whether a particular point lies within a region. Regions are thus located on a two-dimensional (i.e., Cartesian) plane.

The functionality that we develop will be encapsulated in a module called Region:

Note that this module imports the Shape module, and exports a data type ...

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