https://github.com/lpil/glue
🩹 Generate functions from your Gleam code!
https://github.com/lpil/glue
Last synced: 3 months ago
JSON representation
🩹 Generate functions from your Gleam code!
- Host: GitHub
- URL: https://github.com/lpil/glue
- Owner: lpil
- Created: 2023-05-13T18:12:52.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-08T14:20:49.000Z (over 1 year ago)
- Last Synced: 2025-06-20T03:44:33.971Z (11 months ago)
- Language: Gleam
- Homepage:
- Size: 11.7 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# glue
[](https://hex.pm/packages/glue)
[](https://hexdocs.pm/glue/)
A package for generating functions from your Gleam code!
## Generators
- [compare](#compare)
- [list_variants](#list_variants)
### compare
Given a module containing this type:
```gleam
pub type LogLevel {
Debug
Info
Warn
Error
}
```
This generator will generate the following function:
```gleam
pub fn compare_log_level(a: LogLevel, b: LogLevel) -> Order {
let to_int = fn(x) {
case x {
Debug -> 0
Info -> 1
Warn -> 2
Error -> 3
}
}
int.compare(to_int(a), to_int(b))
}
```
### list_variants
Given a module containing this type:
```gleam
pub type Direction {
North
East
South
West
}
```
This generator will generate the following function:
```gleam
pub fn direction_list() -> List(Direction) {
[North, East, South, West]
}
```
## Installation
Add the package to your Gleam project
```sh
gleam add glue
```
API documentation can be found at .