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 FOUR

Shapes II: Drawing Shapes

 

 

 

 

 

In Chapter 2 a shape data type and a function for computing the area of shapes were defined. In the last chapter you learned about basic graphics programming in Haskell. In this chapter I will define another function of shapes, namely one that converts a shape into a graphics value that can then be drawn in a graphics window. Conceptually, this function is no different from the area function defined in Chapter 2. In both cases, a shape is turned into some other kind of value; in the case of area, that value has type Float, and in the case of the function to be defined in this chapter, that value has type Graphic.

In order to perform graphics 10, we need to import the graphics library, as discussed ...

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