Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenMian committed Nov 10, 2024
1 parent 4475753 commit 7601684
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
5 changes: 5 additions & 0 deletions docs/其他/Git.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ scoop install gh # Windows

gh auth login # 登录 GitHub 账号
gh auth setup-git # 配置 Git

gh extension install github/gh-copilot # 安装 Copilot 拓展

gh copilot explain "sudo apt-get" # 解释命令
gh copilot suggest "Undo the last commit" # 生成命令
```

## 常见错误
Expand Down
13 changes: 10 additions & 3 deletions docs/程序设计语言/Haskell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ scoop install msys2
Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; try { & ([ScriptBlock]::Create((Invoke-WebRequest https://www.haskell.org/ghcup/sh/bootstrap-haskell.ps1 -UseBasicParsing))) -Interactive -DisableCurl } catch { Write-Error $_ }
```

## 资源

- [Haskell CheatSheet](https://cheatsheet.codeslower.com/CheatSheet.pdf).

---

`data` 类似 `enum`.
`class` 类似 `trait`.
`instance` 类似 `impl`.
Rust 在类型系统方面受到了 Haskell 的影响. 如果曾学习过 Rust, 则可以加速 Haskell 这方面的内容的学习.
下面列举了它们之间的一些相似之处:

- Haskell 的 `data` 类似 Rust 的 `enum`.
- Haskell 的 `class` 类似 Rust 的 `trait`.
- Haskell 的 `instance` 类似 Rust 的 `impl`.
13 changes: 9 additions & 4 deletions docs/程序设计语言/Haskell/类型.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,23 @@ instance Num Integer -- Defined in `GHC.Num'
instance Num Word -- Defined in `GHC.Num'
```

## 数据类型(Data type)
## 添加新类型

与 Rust 当中的枚举类型 (Enumerated types) 类似.
- `type`: 为类型指定别名.
- `data`: 创建新的类型.

### 数据类型 (Data type)

Haskell 中的 Tagged union 数据类型, 与 Rust 当中的枚举类型 (Enumerated types) 相似.

```hs
data Option a = None | Some(a)
deriving (Eq, Show)
```

TODO
可以使用 `deriving` 为类型自动添加指定类类型的实现, 与 Rust 中的 `derive` 宏相似.

## 类型别名
### 类型别名

可以使用 `type`[^type] 关键字为类型添加别名, 也被称为类型同义词 (type synonyms).

Expand Down

0 comments on commit 7601684

Please sign in to comment.