包,模块和Haskell导入 [英] Packages, modules and import in Haskell

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

问题描述

我对Haskell很新鲜。有人会好心解释代码组织如何在Haskell中工作吗?迄今为止,我已经将所有的东西都写入了一个大的长文件,并从GHCi中测试了代码。我想开始将测试重构我的代码写入逻辑单元。有很多关于如何在很多地方做到这一点的东西,但没有什么全面的。



请解释包,模块和导入声明如何工作,然后告诉我如何使用它们将代码组织到一个更大的,测试驱动的项目中。 解释方案

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屋!

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