Skip to content

Commit e374962

Browse files
Renaming the package to r-tree (#31)
Additionally cleaning up and updating the README
1 parent 9514a31 commit e374962

File tree

23 files changed

+718
-749
lines changed

23 files changed

+718
-749
lines changed

.circleci/config.yml

-55
This file was deleted.

.github/workflows/ci.yaml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CI
2+
on:
3+
- push
4+
- pull_request
5+
6+
defaults:
7+
run:
8+
shell: bash
9+
10+
jobs:
11+
main:
12+
name: GHC ${{ matrix.ghc }} on ${{ matrix.os }}
13+
runs-on: ${{ matrix.os }}
14+
15+
# https://github.com/orgs/community/discussions/57827
16+
if: github.event_name != 'pull_request' ||
17+
github.event.pull_request.head.repo.full_name !=
18+
github.event.pull_request.base.repo.full_name
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
os: [ubuntu-latest]
24+
ghc:
25+
- "9.0"
26+
- "9.2"
27+
- "9.4"
28+
- "9.6"
29+
- "9.8"
30+
- "9.10"
31+
32+
steps:
33+
34+
- uses: actions/checkout@v4
35+
36+
- uses: haskell-actions/setup@v2
37+
id: setup-haskell-cabal
38+
with:
39+
ghc-version: ${{ matrix.ghc }}
40+
41+
- uses: actions/cache@v4
42+
name: Cache cabal stuff
43+
with:
44+
path: |
45+
${{ steps.setup-haskell-cabal.outputs.cabal-store }}
46+
dist-newstyle
47+
key: ${{ runner.os }}-${{ matrix.ghc }}
48+
49+
- name: Cabal version
50+
run: |
51+
cabal --version
52+
53+
- name: Build & Test
54+
run: |
55+
cabal build --enable-tests
56+
cabal test --enable-tests --test-show-details=direct properties

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## 1.0.0.0 -- September 2024
2+
3+
- Initial rewrite.
4+
- Library renamed from `data-r-tree`.

README.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
data-r-tree
1+
# r-tree [![Hackage](http://img.shields.io/hackage/v/r-tree.svg)](https://hackage.haskell.org/package/r-tree)
22

3-
---
3+
A Haskell library for [R-trees](https://en.wikipedia.org/wiki/R-tree) and [R\*-trees](https://en.wikipedia.org/wiki/R\*-tree).
44

5-
R/R\*-trees, currently only two-dimensional `Float` and `Double` varieties.
5+
> [!NOTE]
6+
>
7+
> R-trees are self-balancing and as such can only be spine-strict.
8+
9+
Featuring:
10+
11+
- `Data.R2Tree.*`: two-dimensional R-tree with the R\*-tree insertion algorithm.
12+
13+
`Double`-based implementation is considered the default one;
14+
a `Float`-based variant is provided for cases where reduced precision is preferred,
15+
for example rendering.
16+
17+
Higher-dimensional R-trees are not currently provided,
18+
but should be trivial to add if needed.

benchmark/space/Main.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module Main where
44

5-
import qualified Data.RTree.D2.Float as R
5+
import qualified Data.R2Tree.Float as R
66

77
import Control.Monad
88
import Data.Foldable

benchmark/time/Main.hs

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
module Main where
66

7-
import Data.RTree.D2.Double (RTree, MBR, Predicate)
8-
import qualified Data.RTree.D2.Double as R
7+
import Data.R2Tree.Double (R2Tree, MBR, Predicate)
8+
import qualified Data.R2Tree.Double as R
99

1010
import Control.DeepSeq
1111
import Control.Monad
1212
import Data.Foldable
1313
import Data.List hiding (lookup, map)
1414
import Data.Monoid
15-
import Gauge
1615
import Prelude hiding (lookup, map)
1716
import System.Random.Stateful
17+
import Test.Tasty.Bench
1818

1919

2020

@@ -51,7 +51,7 @@ genAreas n = replicateM n . randPoint
5151

5252

5353
lookup
54-
:: String -> ([(MBR, Int)] -> RTree Int)
54+
:: String -> ([(MBR, Int)] -> R2Tree Int)
5555
-> String -> (MBR -> Predicate) -> Benchmark
5656
lookup cat from name pre =
5757
env ( do g <- newIOGenM $ mkStdGen 0
@@ -70,7 +70,7 @@ lookup cat from name pre =
7070

7171

7272
map
73-
:: String -> ([(MBR, Int)] -> RTree Int)
73+
:: String -> ([(MBR, Int)] -> R2Tree Int)
7474
-> String -> (MBR -> Predicate) -> Benchmark
7575
map cat from name pre =
7676
env ( do g <- newIOGenM $ mkStdGen 0
@@ -83,7 +83,7 @@ map cat from name pre =
8383
fmap $ \x -> [R.adjustRangeWithKey (pre x) (\_ -> (+) 1) r]
8484

8585
traversal
86-
:: String -> ([(MBR, Int)] -> RTree Int)
86+
:: String -> ([(MBR, Int)] -> R2Tree Int)
8787
-> String -> (MBR -> Predicate) -> Benchmark
8888
traversal cat from name pre =
8989
env ( do g <- newIOGenM $ mkStdGen 0
@@ -96,11 +96,11 @@ traversal cat from name pre =
9696
traverse $ \x -> fmap (:[]) $ R.traverseRangeWithKey (pre x) (\_ -> pure @IO . (+) 1) r
9797

9898

99-
fromList :: Foldable t => t (MBR, b) -> RTree b
100-
fromList = foldr (uncurry R.insert) R.empty
99+
fromList :: Foldable t => t (MBR, b) -> R2Tree b
100+
fromList = foldl' (\z (a, b) -> R.insert a b z) R.empty
101101

102-
fromListGut :: Foldable t => t (MBR, b) -> RTree b
103-
fromListGut = foldr (uncurry R.insertGut) R.empty
102+
fromListGut :: Foldable t => t (MBR, b) -> R2Tree b
103+
fromListGut = foldl' (\z (a, b) -> R.insertGut a b z) R.empty
104104

105105

106106
main :: IO ()

cabal.project

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
packages:
2-
data-r-tree.cabal
2+
r-tree.cabal
33
visualizer/r-tree-visualizer.cabal

changelog.md

-70
This file was deleted.

no/No/Tree/D2.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
module No.Tree.D2 where
1010

11-
import Data.RTree.D2.Double.Unsafe (MBR (..), Predicate (..))
11+
import Data.R2Tree.Double.Unsafe (MBR (..), Predicate (..))
1212

1313
import Control.DeepSeq
1414
import qualified Data.Foldable as Fold

data-r-tree.cabal renamed to r-tree.cabal

+20-17
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
cabal-version: 2.2
22

3-
name: data-r-tree
4-
version: 1.2.0
5-
synopsis: R/R*-trees.
6-
description: Spatial trees utilizing R-tree and R*-tree algorithms.
3+
name: r-tree
4+
version: 1.0.0.0
5+
synopsis: R-/R*-trees.
6+
description: R-trees and R*-trees.
7+
8+
See the <https://github.com/sebastian-philipp/r-tree/blob/master/README.md README>
9+
for a brief overview of the data structures included in this package.
710

811
license: MIT
912
license-file: LICENSE
@@ -13,7 +16,7 @@ copyright: Sebastian Wagner, Birte Wagner, Oleksii Divak
1316
category: Data Structures
1417
build-type: Simple
1518

16-
extra-doc-files: changelog.md
19+
extra-doc-files: CHANGELOG.md
1720
README.md
1821

1922
bug-reports: https://github.com/sebastian-philipp/r-tree/issues
@@ -31,25 +34,25 @@ library
3134

3235
hs-source-dirs: src
3336

34-
exposed-modules: Data.RTree.D2.Double
35-
Data.RTree.D2.Double.Debug
36-
Data.RTree.D2.Double.Unsafe
37-
Data.RTree.D2.Float
38-
Data.RTree.D2.Float.Debug
39-
Data.RTree.D2.Float.Unsafe
37+
exposed-modules: Data.R2Tree.Double
38+
Data.R2Tree.Double.Debug
39+
Data.R2Tree.Double.Unsafe
40+
Data.R2Tree.Float
41+
Data.R2Tree.Float.Debug
42+
Data.R2Tree.Float.Unsafe
4043

41-
other-modules: Data.RTree.D2.Double.Internal
42-
Data.RTree.D2.Float.Internal
44+
other-modules: Data.R2Tree.Double.Internal
45+
Data.R2Tree.Float.Internal
4346

4447
ghc-options: -Wall
4548

4649
default-language: Haskell2010
4750

4851
benchmark time
4952
build-depends: base
50-
, data-r-tree
53+
, r-tree
5154
, deepseq
52-
, gauge >= 0.2 && < 0.3
55+
, tasty-bench >= 0.3 && < 0.5
5356
, random >= 1.2 && < 1.3
5457

5558
type: exitcode-stdio-1.0
@@ -64,7 +67,7 @@ benchmark time
6467

6568
benchmark space
6669
build-depends: base
67-
, data-r-tree
70+
, r-tree
6871
, random
6972
, weigh >= 0.0.16 && < 0.1
7073

@@ -80,7 +83,7 @@ benchmark space
8083

8184
test-suite properties
8285
build-depends: base
83-
, data-r-tree
86+
, r-tree
8487
, deepseq
8588
, hspec >= 2 && < 2.12
8689
, random

0 commit comments

Comments
 (0)