导入Haskell模块的特定部分的好处 [英] Benefit of importing specific parts of a Haskell module
问题描述
除了潜在的名称冲突 - 可以通过其他方式获得 - 是否有任何益处,仅从您需要的模块导入零件:
import SomeModule(x,y,z)
.. .verses只是导入它的所有内容,而且更加容易维护:
import SomeModule
$ c
$ b 是否会使二进制变小?
解决方案不,这只是为了防止名称冲突。另一种防止名称冲突的机制 - 也就是 import qualified
- 会产生更多的冗长(可读性较差的)代码。
它不会使二进制变小 - 考虑到给定模块中的函数通常都是相互引用的,所以它们需要一起编译。
Except from potential name clashes -- which can be got around by other means -- is there any benefit to importing only the parts from a module that you need:
import SomeModule (x, y, z)
...verses just importing all of it, which is terser and easier to maintain:
import SomeModule
Would it make the binary smaller, for instance?
解决方案 No, it's only for the purpose of preventing name clashes. The other mechanism for preventing name clashes - namely import qualified
- results in more verbose (less readable) code.
It wouldn't make the binary smaller - consider that functions in a given module all reference each other, usually, so they need to be compiled together.
这篇关于导入Haskell模块的特定部分的好处的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!