3 ms·
In my opinion the module system (http://www.haskell.org/onlinereport/modules.html http://www.haskell.org/onlinereport/modules.html) is a bit weak. For example:
by LukeHoersten 13y ago
In my opinion the module system (http://www.haskell.org/onlinereport/modules.html http://www.haskell.org/onlinereport/modules.html) is a bit weak. For example: "It is not possible, however, to hide instance declarations in the Prelude. For example, one cannot define a new instance for Show Char."
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.2.0/doc/html/Data-ByteString-Char8.html http://hackage.haskell.org/packages/archive/bytestring/0.10....
http://hackage.haskell.org/packages/archive/bytestring/0.10.2.0/doc/html/Data-ByteString-Lazy-Char8.html 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.
- ac 13y ago> Instances can't be explicitly imported either. You can import only instances by saying "import A.B.C.Instances ()" where A.B.C.Instances is the name of the module where the instances are defined.
- tome 13y agoBut not individual instances.
- ekmett 13y agoWhen given the ability to qualify the instances you import you lose confluence of instance resolution. This is BAD. 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".
- 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
- sold 13y agoThere is a very good reason instances cannot be explicitly imported: http://stackoverflow.com/questions/8728596 http://stackoverflow.com/questions/8728596