https://github.com/robrix/interval-functor
General purpose intervals of functors.
https://github.com/robrix/interval-functor
Last synced: about 1 year ago
JSON representation
General purpose intervals of functors.
- Host: GitHub
- URL: https://github.com/robrix/interval-functor
- Owner: robrix
- License: bsd-3-clause
- Created: 2020-07-10T19:19:40.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2024-10-04T12:54:57.000Z (over 1 year ago)
- Last Synced: 2025-04-30T15:22:38.553Z (about 1 year ago)
- Language: Haskell
- Size: 324 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# `interval-functor`
[](https://hackage.haskell.org/package/interval-functor)
[](LICENSE)
[](https://github.com/robrix/interval-functor/actions)
This is a Haskell package defining an `Interval` datatype parameterized by the type of endpoints and the type of their coordinates. For example, it can represent a simple one-dimensional range:
```haskell
import Data.Functor.Identity
import Data.Functor.Interval
zeroInterval :: Num a => Interval Identity a
zeroInterval = point 0
```
or a multi-dimensional region:
```haskell
import Data.Functor.Interval
import Linear.V3 -- from the linear package
unitCube :: Num a => Interval V3 a
unitCube = (-1)...1
```
## Development
Development currently assumes a Mac with `ghc` 8.10 & `cabal` 3.0. You can install them directly, or use [`ghcup`](https://www.haskell.org/ghcup/). It should be possible to develop on other platforms and compilers, but I probably haven’t tried them myself.
```bash
cabal build --enable-tests # initial build
cabal repl # load the library and tests in ghci
```
Once the repl has loaded, you can run the tests with `:main`.
```
λ :main
```
Configuration exists for `haskell-ide-engine`, which can be integrated into many editors.
## Advantages
`interval-functor` separates the representation of the coordinates of an interval from the representation of the space the coordinates occur in. This makes it particularly suitable for consistent treatment of multi-dimensional intervals; operations like e.g. `union` extend naturally to multi-dimensional spaces.
It is also thoroughly property tested and documented.