by LukeHoersten · 13y ago · 0 comments
Instances can't be explicitly imported either.
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. For example:
http://hackage.haskell.org/packages/archive/bytestring/0.10....
http://hackage.haskell.org/packages/archive/bytestring/0.10....
It's really not that bad but I do like how other languages allow the programmer to make this explicit.
We rely on confluence to enable us to move class constraints to where they are used rather than have to carry them around in every object.
Scala tries to get away with having the ability to explicitly pass dictionaries around and the result is frankly a muddled mess. Monad transformers wind up nigh unusable, sets can't use efficient hedge merges, etc.
Explicitly enumerating instance imports is one of those things that seems like a good idea until you actually explore its consequences.
I can't defend the ByteString API on the other hand. ;)
That said, I do not find it particularly "Haskelly".
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.