-- Slide 23 data Point = Point Float Float data Shape = Singularity Point | Circle Float Point | Square Point Point distance p1 p2 = let (Point a b) = p1 in let (Point c d) = p2 in sqrt ((a - c) * (a - c) + (b - d) * (b - d)) perimeter sh = case sh of Singularity _ -> 0.0 Circle r _ -> 3.14 * 2 * r Square (Point a b) (Point c d) -> 2 * abs (a - c) + 2 * abs (b - d)