mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-18 14:31:42 +00:00
25 lines
556 B
Text
25 lines
556 B
Text
app [main!] { pf: platform "./platform/main.roc" }
|
|
|
|
import pf.Stdout
|
|
|
|
# Define an opaque type with a custom to_inspect method
|
|
Color := [Red, Green, Blue].{
|
|
to_inspect : Color -> Str
|
|
to_inspect = |color| match color {
|
|
Red => "Color::Red"
|
|
Green => "Color::Green"
|
|
Blue => "Color::Blue"
|
|
}
|
|
}
|
|
|
|
main! = || {
|
|
red : Color
|
|
red = Red
|
|
|
|
# Test inspect with custom to_inspect method
|
|
result = inspect red
|
|
Stdout.line!(result)
|
|
|
|
# Compare with what the default would be
|
|
Stdout.line!("Expected: Color::Red")
|
|
}
|