Sum Types question

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?

I think what you meant to write here was something more like

@sum_type Fruit begin
    Apple # Maybe you want to store some data inside, like Apple(weight::Float64)
    Orange
    Pear
end

you’d then write something like

consume(f::Fruit) = @cases f begin
    Apple => do_something_for_apples() # If Apple stores data this might be Apple(w) => do_something_for_apples(w)
    Orange => do_something_for_oranges()
    Pear => do_something_for_pears()
end