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

查看:25
本文介绍了Haskell 中的模块、包和库有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Haskell 中的模块、包和库有什么区别?

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

来自 http://www.haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html
Prelude:一个标准的模块,默认导入到所有 Haskell 模块中.

From http://www.haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html
Prelude: a standard module imported by default into all Haskell modules.

来自 http://www.haskell.org/haskellwiki/Base_package
基础包:基础包含 Prelude 及其支持库,以及从数据结构到解析组合器和调试实用程序的大量有用的.

From 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.

谢谢.

另请参阅:Python模块和Python有什么区别包?

推荐答案

模块是一组函数、类型、类...放在一个公共命名空间中.

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.

这篇关于Haskell 中的模块、包和库有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆