class Shape a where
    perimeter :: a -> Double
    area      :: a -> Double


data Rectangle = Rectangle Double Double


data Circle = Circle Double

instance Shape Rectangle where
    perimeter (Rectangle width height) = 2 * width + 2 * height
    area      (Rectangle width height) = width * height


instance Shape Circle where
    perimeter (Circle radius) = 2 * pi * radius
    area      (Circle radius) = pi * radius^2

apRatio :: Shape a => a -> Double

apRatio shape = area shape / perimeter shape

main = do
    print $ apRatio $ Circle 5
    print $ apRatio $ Rectangle 5 5