Gleam type check using pattern matching
gleam add glatch
import glatch.{IsString}
import gleam/string
pub fn main() {
case glatch.get_type("Lucy") {
IsString(_) -> "Hello, 𓇼"
unknown -> "Who are you? " <> string.inspect(unknown)
}
}
Further documentation can be found at https://hexdocs.pm/glatch.
- String
- Int
- Float
- Bool
- List
- nested type check
- empty type check
- Option
- Some type check
- None type check
- Result
- Ok type check
- Error type check
- Dict
- key type check
- value type check
- empty type check
- Tuple
- Arity 0-6
gleam run # Run the project
gleam test # Run the tests
gleam shell # Run an Erlang shell