I am considering using sum types for my package, and I have a question about the interface. Say I have a sum type of fruits, Apple
Orange
, and Pear
. I have 3 methods consume(::Apple)
, consume(::Orange)
, consume(::Pear).
If I have a
@sumtype Fruit begin
AppleFruit(::Apple)
OrangFruit(::Orange)
PearFruit(::Pear)
end
Can I call consume consume(::Fruit)
and rely on implicit conversion to convert to an Apple
, Orange
or Pear
, or do I need to write my own consume(::Fruit)
function with case that dispatches to each method?