{-# LANGUAGE MultiParamTypeClasses #-} -- | This module provides a type class to modell distance between -- geometric objects. module Geom2d.Distance where import Geom2d.Point.Internal -- | The Distance between objects that have no volume, like points, -- should satisfy the triangle inequality. class Distance p q where distance :: (Ord a, Floating a) => p a -> q a -> a instance Distance Point' Point' where distance (Point' (a1,a2)) (Point' (b1,b2)) = sqrt $ (a1 - b1)^(2::Int) + (a2 - b2)^(2::Int)