Part B of the assignment has lots of confusing data types! State, Graphics, InteractionOf. Don’t worry! By the end of this activity, you will be a master of Part B in no time!

Understanding State

Consider the State data type:

data State = World
                [Graphic]
                Tool
                ColourName
  1. What is the type name of the type constructor in State. What does it do?

  2. Give an explanation of each of the component data types. Give an example of each.

We are going to understanding this data type through drawing. Go through the following exercise as a group:

  1. Draw a “canvas” on the whiteboard. This is where we will draw pictures.

  2. Consider this example of the State data type: World [Graphic (Line (1.0,1.0) (2.0,2.0)) Cyan (0.0,0.0)] (LineTool Nothing) Cyan

Draw this State on your canvas. Label each of the component parts.

  1. Draw any shape you want on your canvas. Write out a corresponding State data type.

  2. Write a function called extractGraphics, which inputs a State and outputs the [Graphics] of this State.