Skip to content

inoas/gleam-gond

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gond 🚡 — cond-like multi-branch conditionals for Gleam

Package <a href="https://github.com/inoas/gleam-gond/releases"><img src="https://img.shields.io/github/release/inoas/gleam-gond" alt="GitHub release"></a> Version Erlang-compatible JavaScript Compatible Hex Docs Discord CI Test



Think of a gondola lift 🚠 ride, where you can hop off at any station.


Installation

gleam add gond@2

Examples

import gleam/int
import gleam/io
import gleam/string
import gond.{
  cond as cond, fact as fact, run as run, when as when, yield as yield,
}

pub fn example() {
  cond(
    branches: [
      when(fn() { int.random(3) == 1 }) |> run(fn() { "Heads!" }),
      fact(int.random(3) == 2) |> run(fn() { "Tails!" }),
      when(fn() { True }) |> yield("This always occurs!"),
      fact(False) |> yield("This is never the fact!"),
    ],
    default: fn() { "Lost the coin?" },
  )
}

pub fn main() {
  example() |> string.inspect |> io.println
}
gleam run --module gond/internal/usage_examples

Further documentation can be found at https://hexdocs.pm/gond.

Development

gleam run   # Run the project
gleam test  # Run the tests

Inspirations

About

Gond 🔠: cond for Gleam

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages