Haskell 入门项目教程

随笔1天前发布 陈金海
4 0 0

Haskell 入门项目教程

getting-started-with-haskellnotes on where to find Haskell tutorials and tips to complete them项目地址:https://gitcode.com/gh_mirrors/ge/getting-started-with-haskell

1. 项目的目录结构及介绍




getting-started-with-haskell/


├── README.md


├── src/


│   ├── Main.hs


│   └── ...


├── app/


│   └── Main.hs


├── test/


│   └── ...


├── stack.yaml


└── package.yaml

README.md: 项目介绍和使用说明。src/: 存放源代码文件,其中 Main.hs 是主要的源代码文件。app/: 存放应用程序的入口文件,Main.hs 是应用程序的启动文件。test/: 存放测试文件。stack.yaml: 项目的 Stack 配置文件。package.yaml: 项目的 Haskell 包配置文件。

2. 项目的启动文件介绍

app/Main.hs




module Main where


 


import Lib


 


main :: IO ()


main = someFunc

module Main where: 定义模块名为 Mainimport Lib: 导入 Lib 模块中的函数。main :: IO (): 定义 main 函数,这是程序的入口点。main = someFunc: 调用 Lib 模块中的 someFunc 函数。

3. 项目的配置文件介绍

stack.yaml




resolver: lts-18.18


packages:


- .


extra-deps: []


flags: {}


extra-package-dbs: []

resolver: 指定使用的 Stackage 解析器版本。packages: 指定包含的项目包。extra-deps: 额外的依赖包。flags: 包的编译标志。extra-package-dbs: 额外的包数据库。

package.yaml




name: getting-started-with-haskell


version: 0.1.0.0


dependencies:


- base >= 4.7 && < 5


library:


  source-dirs: src


executables:


  getting-started-with-haskell-exe:


    main: Main.hs


    source-dirs: app


    dependencies:


    - getting-started-with-haskell


tests:


  getting-started-with-haskell-test:


    main: Spec.hs


    source-dirs: test


    dependencies:


    - getting-started-with-haskell

name: 项目名称。version: 项目版本。dependencies: 项目依赖。library: 定义库部分的源代码目录。executables: 定义可执行文件部分,包括主文件和依赖。tests: 定义测试部分,包括主测试文件和依赖。

以上是基于 https://github.com/katychuang/getting-started-with-haskell.git 项目的教程内容。希望对你有所帮助!

getting-started-with-haskellnotes on where to find Haskell tutorials and tips to complete them项目地址:https://gitcode.com/gh_mirrors/ge/getting-started-with-haskell

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...