4 ms·
> Another thing I don't like is if you have two different functions with the same signature but different implementations meant to give swappable functionality,
by sparkie 13y ago
> Another thing I don't like is if you have two different functions with the same signature but different implementations meant to give swappable functionality, there's no way of specifying that explicitly. As a user of a library, you just have to realize the functions can be swapped out with modules.
Haskell is possibly better in this regard than many other languages, as you can make existing functions become polymorphic without modifying them. (say for example, in most OOP languages, you would need to add an additional interface to each class where you want to use a method interchangeably, which you can't always do.)
In hask, you can just create a new typeclass for the particular functions you want to be swappable, and add an instance definition for each.
eg, http://pastebin.com/9RVMZyz1 http://pastebin.com/9RVMZyz1