Skip to content

dinkelspiel/comparator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

comparator

Compare if two types have the same constructor in Gleam

Package Version Hex Docs

gleam add comparator@1
import comparator.{is_same_kind}

type Size {
  Small
  Medium
}

type Variant {
  Primary
  Secondary
}

type Key {
  Size(Size)
  Variant(Variant)
}

pub fn main() -> Nil {
  assert is_same_kind(Size(Medium), Size(Small)) == True
  assert is_same_kind(Size(Medium), Variant(Primary)) == False
  assert is_same_kind(Variant(Primary), Variant(Primary)) == True
  assert is_same_kind(Variant(Primary), Variant(Secondary)) == True
}

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

Development

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

About

Compare if two types have the same constructor in Gleam

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors