Skip to content

vistuleB/either_or

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

either_or

Package Version Hex Docs

gleam add either_or@1
import gleam/string
import either_or as eo

// from eo:
//
// pub type EitherOr(a, b) {
//   Either(a)
//   Or(b)
// }

pub fn main() -> Nil {
  [
    "a",
    "a",
    "b",
    "a",
    "b",
    "a",
    "a",
    "a",
  ]
  |> eo.discriminate(string.starts_with(_, "a"))
  |> echo
  // [
  //   Either("a"),
  //   Either("a"),
  //   Or("b"),
  //   Either("a"),
  //   Or("b"),
  //   Either("a"),
  //   Either("a"),
  //   Either("a"),
  // ]
  |> eo.group_eithers
  |> echo
  // [
  //   Either(["a", "a"]),
  //   Or("b"),
  //   Either(["a"]),
  //   Or("b"),
  //   Either(["a", "a", "a"]),
  // ]
  Nil
}

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

Development

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

About

Gleam package implementing a generic choice type.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages