pub type Widget
{
Bracket(name: String, model: String)
Sprocket(diameter: Float, thickness: Float)
}
fn update_widget(widget: Widget) -> Widget {
case widget {
Bracket(..) as b -> Bracket(..b, name: "new name")
Sprocket(..) as s -> Sprocket(..s, diameter: 2*s.diameter)
}
}
produces the error
I can't tell this is always the right constructor.
This type has multiple constructors so it cannot be safely updated.
If this value was one of the other variants then the update would be
produce incorrect results.
at Bracket(..b, name: "new name") -- does Gleam not have enough type info to know that b is a Bracket specifically?