You'd just do the same thing you do in any language, you parse the incoming data into a format that's more idiomatic, e.g. in Gleam
type Record {
NShares(n: Int)
ZeroTheAccount()
}
fn parse_record(n: Int) -> Record {
case n {
0 -> ZeroTheAccount()
_ -> NShares(n)
}
}
Then you don't have to worry about mixing up the two :)