[add] information about the 'Could not deduce KnownNat' error.

This commit is contained in:
Yamada Ryo 2023-09-17 14:10:16 +09:00
parent 7f2f1984f8
commit 1794222905
No known key found for this signature in database
GPG Key ID: AAE3C7A542B02DBF
2 changed files with 5 additions and 0 deletions

View File

@ -193,6 +193,9 @@ main =
エフェクトクラス・リストに掛かる制約だ。
関数を書いていて`Could not deduce (Forall HFunctor ...)`が出たら、関数の制約にこれを追加しよう。
また、`Could not deduce KnownNat`といったエラーは、制約を関数に追加せずとも
`ghc-typelits-knownnat`プラグインを導入することで回避できるだろう。
そして`Hef`だが、これは`Fre` (Freer)に対する高階版、その名も**Heftia**(のモナドトランスフォーマー)である。
FreerがFreeモナドとco-Yonedaの合成であるように、
Heftiaはhefty treeとco-Yonedaの高階版の合成であり、高階エフェクトの取り扱いのために本ライブラリが新たに導入するものだ。

View File

@ -184,6 +184,8 @@ Also here, the function type has a slightly unusual structure.
First, the constraint `ForallHFunctor ...` is a constraint on the effect class list in `heftia-effects`, required throughout the library. If you encounter a `Could not deduce (Forall HFunctor ...)` error while writing a function, add this to the function's constraints.
Additionally, errors like `Could not deduce KnownNat` can be avoided by introducing the `ghc-typelits-knownnat` plugin without adding constraints to the function.
Then, there's `Hef`, which is a higher-order version of `Fre` (Freer) and is (a monad transformer) called **Heftia**. Just as Freer is a combination of the Free monad and co-Yoneda, Heftia is a combination of a hefty tree and a higher-order co-Yoneda. This is introduced by this library specifically for handling higher-order effects.
In `heftia-effects`, the system uses the Heftia transformer to handle higher-order effects. And the carriers for first-order effects (namely, Freer) are usually placed as subordinate carriers under the carriers for higher-order effects (namely, Heftia).