Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/relrod/ms
metric spaces
https://github.com/relrod/ms
Last synced: 13 days ago
JSON representation
metric spaces
- Host: GitHub
- URL: https://github.com/relrod/ms
- Owner: relrod
- License: bsd-2-clause
- Created: 2015-07-15T21:44:31.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-25T02:56:16.000Z (about 9 years ago)
- Last Synced: 2024-04-23T22:37:19.475Z (7 months ago)
- Language: Haskell
- Homepage: https://hackage.haskell.org/package/ms
- Size: 250 KB
- Stars: 6
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ms - metric spaces
[![Build Status](https://travis-ci.org/relrod/ms.svg?branch=master)](https://travis-ci.org/relrod/ms)
A metric space is a set together with some notion of distance function which
obeys four laws. See
[the haddock](https://relrod.github.io/ms/Math-MetricSpace.html) for more
information.We implement these not using a typeclass, but using a simple datatype. This
avoids needing to create newtypes for every metric implementation over a given
type, meaning that we gain more code re-use and an easier-to-use API.**WARNING**: The triangle-inequality law does not necessarily hold in the
presence of `Floating a => a`, which we use. This is because `Double` and
`Float` both don't have arbitrary precision. However, some of our metrics, such
as that of `euclidean` distance, require the use of the `sqrt` function, which
requires a `Floating` constraint.## Usage
```haskell
dist levenshtein "foo" "bar" -- => 3.0
dist euclidean (V.fromList [3,2]) (V.fromList [2,3]) -- => 1.4142135623730951
```# License
[BSD-2](LICENSE).