Does Haskell have return type overloading?

后端 未结 5 878
囚心锁ツ
囚心锁ツ 2020-12-05 03:09

Based on what I\'ve read about Haskell, and the experimentation I\'ve done with GHC, it seems like Haskell has return type overloading (aka ad hoc polymorphism). One example

5条回答
  •  鱼传尺愫
    2020-12-05 03:59

    The seminal paper on Haskell-style typeclasses is called "How to make ad-hoc polymorphism less ad hoc". So, the answer to your question is a qualified "yes" -- depending on just how ad hoc you require your return-type overloading to be...

    In other words: there is no question that ad hoc polymorphism is relevant to typeclasses, since that was a motivating example for inventing them. But whether you think the result still qualifies as "return-type overloading" depends on the fiddly details of your favored definition.

提交回复
热议问题