-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | metric spaces -- @package ms @version 0.2 -- | A MetricSpace is a set together with a notion of distance -- between elements. Distance is computed by a function dist which -- has the following four laws: -- --
    --
  1. non-negative: forall x y. dist x y >= -- 0
  2. --
  3. identity of indiscernibles: forall x y. dist x y -- == 0 <=> x == y
  4. --
  5. symmetry: forall x y. dist x y == dist y -- x
  6. --
  7. triangle inequality: forall x y z. dist x z -- <= dist x y + dist y z
  8. --
-- -- See the Wikipedia article on metric spaces for more details. module Math.MetricSpace newtype MetricSpace a b MetricSpace :: (a -> a -> b) -> MetricSpace a b dist :: MetricSpace a b -> a -> a -> b type ClosedMetricSpace a = MetricSpace a a newtype FlippedMetricSpace b a FlippedMetricSpace :: (MetricSpace a b) -> FlippedMetricSpace b a type ClosedFlippedMetricSpace a = FlippedMetricSpace a a (<->) :: MetricSpace a b -> a -> a -> b _FlippedMetricSpace :: Iso (MetricSpace a b) (MetricSpace x y) (FlippedMetricSpace b a) (FlippedMetricSpace y x) class SwappedMetricSpace m _SwappedMetricSpace :: SwappedMetricSpace m => Iso (m a b) (m x y) (m a b) (m x y) -- | Levenshtein distance between Strings. -- --
--   >>> dist levenshtein "foo" "bar"
--   3
--   
-- --
--   >>> dist levenshtein "hi" "ha"
--   1
--   
-- --
--   >>> dist levenshtein "ff" "ff"
--   0
--   
levenshtein :: Integral b => MetricSpace String b -- | Discrete distance over n-dimensional Vectors. -- --
--   >>> dist discrete (V.fromList [3,4]) (V.fromList [3,4])
--   0
--   
-- --
--   >>> dist discrete (V.fromList [1,49]) (V.fromList [3,-94])
--   1
--   
discrete :: (Eq a, Integral b) => MetricSpace (Vector a) b -- | Euclidean distance over n-dimensional Vectors. -- --
--   >>> dist euclidean (V.fromList [3,4]) (V.fromList [3,4])
--   0.0
--   
-- --
--   >>> dist euclidean (V.fromList [1,49]) (V.fromList [3,-94])
--   143.01398533010678
--   
euclidean :: RealFloat a => MetricSpace (Vector a) a -- | Taxicab distance over n-dimensional Vectors. -- --
--   >>> dist taxicab (V.fromList [3,4]) (V.fromList [3,4])
--   0.0
--   
-- --
--   >>> dist taxicab (V.fromList [1,49]) (V.fromList [3,-94])
--   145.0
--   
taxicab :: RealFloat a => MetricSpace (Vector a) a instance SwappedMetricSpace FlippedMetricSpace instance SwappedMetricSpace MetricSpace instance Monoid b => Divisible (FlippedMetricSpace b) instance Contravariant (FlippedMetricSpace b) instance Profunctor MetricSpace instance Monoid b => Monoid (MetricSpace a b) instance Semigroup b => Semigroup (MetricSpace a b) instance Monad (MetricSpace a) instance Applicative (MetricSpace a) instance Functor (MetricSpace a)