14.8 - eqShape Shape> Shape> Bool eqShape(Circle...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
--14.8 -- make a new instance of class Eq for type Shape instance Eq Shape where (==) = eqShape -- no need to derive (Eq) in Shape because it's explicitly defined data Shape = Circle Float | Rectangle Float Float | Triangle Float Float Float -- eqShape is the equality function to compare Shapes with
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: eqShape :: Shape -> Shape -> Bool eqShape (Circle r1) (Circle r2) = r1 == (-r2) eqShape _ _ = False-- rectangles with negative sides are not equated, because they would-- have a different "position in space" (mirrored at a side or corner)-- (which is not the case with circles)...
View Full Document

Ask a homework question - tutors are online