Skip to content
/ glue Public

🩹 Generate functions from your Gleam code!

Notifications You must be signed in to change notification settings

lpil/glue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

glue

Package Version Hex Docs

A package for generating functions from your Gleam code!

Generators

compare

Given a module containing this type:

pub type LogLevel {
  Debug
  Info
  Warn
  Error
}

This generator will generate the following function:

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:

pub type Direction {
  North
  East
  South
  West
}

This generator will generate the following function:

pub fn direction_list() -> List(Direction) {
  [North, East, South, West]
}

Installation

Add the package to your Gleam project

gleam add glue

API documentation can be found at https://hexdocs.pm/glue.

About

🩹 Generate functions from your Gleam code!

Resources

Stars

Watchers

Forks

Languages