简体   繁体   English

模块,package和Haskell中的库有什么区别?

[英]What's the difference between module, package and library in Haskell?

What's the difference between module, package and library in Haskell?模块,package和Haskell中的库有什么区别?

From http://www.haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html来自http://www.haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html
Prelude: a standard module imported by default into all Haskell modules. Prelude:默认导入所有Haskell模块的标准模块

From http://www.haskell.org/haskellwiki/Base_package来自http://www.haskell.org/haskellwiki/Base_package
Base package: The base package contains the Prelude and its support libraries, and a large collection of useful libraries ranging from data structures to parsing combinators and debugging utilities.基础 package:基础package包含 Prelude 及其支持库,以及从数据结构到解析组合器和调试实用程序的大量有用

Thanks.谢谢。

See also: What's the difference between a Python module and a Python package?另请参阅: Python 模块和 Python package 之间有什么区别?

A module is a set of functions, types, classes, ... put together in a common namespace. 模块是一组函数,类型,类,......放在一个共同的命名空间中。

A library is a set of modules which makes sense to be together and that can be used in a program or another library. 是一组模块,它们在一起是有意义的,可以在程序或其他库中使用。

A package is a unit of distribution that can contain a library or an executable or both. 是一个分发单元,可以包含库或可执行文件或两者。 It's a way to share your code with the community. 这是与社区共享代码的一种方式。

Note that a library doesn't have to be in isolation in a package. 请注意,库不必在包中隔离。 That is, it's perfectly acceptable to have a library in your project that is used inside this project. 也就是说,在项目中使用该库中的库是完全可以接受的。 The code is therefore seperated from the rest for clarity and maintainability. 因此,为了清晰和可维护性,代码与其余部分分开。 This is also a good way to isolate some general-purpose from your business logic code and this lib could eventually be extracted and shared between projects or with the community if needed. 这也是将一些通用功能与业务逻辑代码隔离开的好方法,如果需要,最终可以在项目之间或与社区共享此lib。

Module: The individual file of a reusable code.模块:可重用代码的单个文件。 The reusable code contains set of functions, classes etc. We can use these tested functions, classes etc. without reinventing the wheel in our code.可重用代码包含一组函数、类等。我们可以使用这些经过测试的函数、类等,而无需在代码中重新发明轮子。

Package: A package is a directory which contains one or more modules. Package: package 是一个包含一个或多个模块的目录。

Library: It is a directory where the packages are stored.库:它是存储包的目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM