包,模块和Haskell导入 [英] Packages, modules and import in Haskell
问题描述
请解释包,模块和导入声明如何工作,然后告诉我如何使用它们将代码组织到一个更大的,测试驱动的项目中。 解释方案
Haskell for Great Good!:
http://learnyouahaskell.com / modules
我会将包称为Haskell软件的最小可交付单元。对于大多数人来说,只需说软件包就是 Hackage 。
如果您要发布一个可执行文件,我不会担心在您开始第二个项目并希望从第一个项目重新使用模块之前将项目拆分为多个包。
I'm newish to Haskell. Would someone kindly explain how code organization works in Haskell? To date I have written everything in one big long file and tested code from GHCi. I want to start writing tests an refactor my code into logical units. There are bits and pieces about how to do this in lots of places, but nothing comprehensive.
Please explain how packages, modules and the import statement work then tell me how to use them to organize code into a larger, test-driven project.
Here is an introduction Haskell modules from "Learn You a Haskell for Great Good!":
http://learnyouahaskell.com/modules
I would call a package the smallest deliverable unit of Haskell software. For most people, it is enough to say "packages are the things on Hackage".
If you're shipping an executable I wouldn't worry about breaking up your project into multiple packages until you get to your second project, and want to re-use modules from the first.
这篇关于包,模块和Haskell导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!