Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/allo-media/canopy
A generic Tree API in Elm
https://github.com/allo-media/canopy
elm rosetree tree
Last synced: about 1 month ago
JSON representation
A generic Tree API in Elm
- Host: GitHub
- URL: https://github.com/allo-media/canopy
- Owner: allo-media
- License: mit
- Created: 2018-05-04T08:23:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-28T13:03:49.000Z (over 5 years ago)
- Last Synced: 2023-08-08T20:37:49.506Z (over 1 year ago)
- Topics: elm, rosetree, tree
- Language: Elm
- Homepage: http://package.elm-lang.org/packages/allo-media/canopy/latest
- Size: 18.6 KB
- Stars: 11
- Watchers: 11
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Canopy
======A Generic Tree API, based on the [Rose Tree](https://en.wikipedia.org/wiki/Rose_tree)
algebraic data type, augmented with helpers for building, querying and manipulating nodes.Building a tree is basically done with using `node` and `leaf`:
```elm
tree : Node String
tree =
node "root"
[ node "foo"
[ leaf "bar" ]
, node "baz"
[ leaf "qux" ]
]
```The API focuses on node values for common operations:
```elm
tree
|> remove "baz"
|> append "foo" "bingo"
== node "root"
[ node "foo"
[ leaf "bar"
, leaf "bingo"
]
]
```It exposes powerful helpers for working with tree data structures:
```elm
node 1
[ node 2
[ leaf 3, leaf 4 ]
, node 5
[ leaf 6 ]
]
|> flatMap (value >> (*) 2)
|> List.sum
== 42
```License
-------MIT.