Re:If statements considered harmful
by joncampbelldev on Tuesday March 14, 2017 @05:19AM
(#13866105)
that sounds a lot like sharing code by inheritance as opposed to composition. which is unrelated to dispatching by the type of the first (or implicit) argument.
i personally would prefer to code to interfaces and keep hierarchy separate from behaviour
Re:If statements considered harmful
by joncampbelldev on Tuesday March 14, 2017 @05:23AM
(#13866121)
perhaps I haven't felt your pain of rigid static designs because i mostly work in clojure, ymmv
A concrete example: you make a new type in Haskell, and you derive Show so it can be printed. But the default output isn't quite right - you want to add something to it. In an OO language you might "call into super" and append to the string. But in Haskell this isn't possible: you either get the default implementation, or you do it all from scratch.
More generally, typeclass default implementations are a lame replacement for overriding, and existentials are anemic compared to dynamic binding. This pushes Haskell interfaces towards rigid, static designs. That's fine if that's what you want, but let's not pretend it's equivalent in power to OO polymorphism.