Re:The visitor pattern is essentially the same thing as Chur...
by tsimionescu on Friday February 05, 2021 @01:38AM
(#26033734)
So how would a subtype of Addition look here? Who would tell stringEvaluator how to handle this SmallNumberAddition?
Re:The visitor pattern is essentially the same thing as Chur...
by dwohnitmok on Saturday February 06, 2021 @05:02PM
(#26050419)
There wouldn't be a subtype of Addition because Haskell doesn't have a notion of subtyping in the same way C# does. It would depend on the particulars of what the difference between SmallNumberAddition and Addition look like (in particular which parts are kept with the same functionality and which are different). The answer could be either a simple function or a typeclass depending on that.
That's not true. I think you may be misunderstanding open unions (or polymorphic variants) here. Tags are types in and of themselves. That's why these are all `type alias`es. You could decide to modify the type alias if you'd like, but you don't have to. You can add the additional tag just to the call site.