Update README.md.

This commit is contained in:
Yamada Ryo 2024-09-05 06:46:37 +09:00
parent 6cfe9349f6
commit 130b477aa4
No known key found for this signature in database
GPG Key ID: AAE3C7A542B02DBF

View File

@ -188,19 +188,29 @@ Examples with explanations in Japanese can be found in the [docs-ja/examples/](h
* Effect System: For a term representing an effectful program, is it possible to statically decidable a type that enumerates all the effects the program may produce?
* Purely Monadic: Is an effectful program represented as a transparent data structure that is a monad, and can it be interpreted into other data types using only pure operations without side effects or `unsafePerformIO`?
* Dynamic Effect Rewriting: Can an effectful program have its internal effects altered afterwards (by functions typically referred to as `handle with`, `intercept`, `interpose`, `transform`, `translate`, or `rewrite`) ?
For example, would it be possible to apply `interpose` as many times as the number of values input by the user at runtime?
* Semantics: Classification of behaviors resulting from the interpretation of effects.
* continuation-based: The same as Algebraic Effects and Handlers.
* IO-based: IO + Reader pattern.
* carrier dependent: The behavior depends on the specific type inference result of the monad. Tagless-final style.
* Performance: Time complexity or space complexity.
| Library or Language | Higher-Order Effects | Delimited Continuation | Effect System | Purely Monadic | Dynamic Effect Rewriting | Performance (TODO) |
| ------------------- | -------------------- | ---------------------- | --------------| --------------------------------- | ------------------------ | ------------------ |
| Heftia | Yes | Multi-shot | Yes | Yes (also Applicative and others) | Yes | ? |
| freer-simple | No | Multi-shot | Yes | Yes | Yes | ? |
| Polysemy | Yes | No | Yes | Yes | Yes | ? |
| Effectful | Yes | No | Yes | No (based on the `IO` monad) | Yes | ? |
| eff | Yes | Multi-shot? | Yes | No (based on the `IO` monad) | Yes | Fast |
| mtl | Yes | Multi-shot (`ContT`) | Yes | Yes | No | ? |
| fused-effects | Yes | No? | Yes | Yes | No | ? |
| koka-lang | No [^2] | Multi-shot | Yes | No (language built-in) | Yes | ? |
| OCaml-lang 5 | ? | One-shot | No [^3] | No (language built-in) | ? | ? |
| Library or Language | Higher-Order Effects | Delimited Continuation | Effect System | Purely Monadic | Dynamic Effect Rewriting | Semantics | Performance (TODO) |
| ------------------- | -------------------- | ---------------------- | --------------| --------------------------------- | ------------------------ | -------------------------------- | ------------------ |
| Heftia | Yes | Multi-shot | Yes | Yes (also Applicative and others) | Yes | continuation-based | ? |
| freer-simple | No | Multi-shot | Yes | Yes | Yes | continuation-based | ? |
| Polysemy | Yes | No | Yes | Yes | Yes | weaving-based (functorial state) | ? |
| Effectful | Yes | No | Yes | No (based on the `IO` monad) | Yes | IO-based | ? |
| eff | Yes | Multi-shot? | Yes | No (based on the `IO` monad) | Yes | continuation-based (IO-fused) | Fast |
| in-other-words | Yes | Multi-shot? | Yes | Yes | No? | carrier dependent | ? |
| mtl | Yes | Multi-shot (`ContT`) | Yes | Yes | No | carrier dependent | ? |
| fused-effects | Yes | No? | Yes | Yes | No | carrier dependent & weaving-based (functorial state) | ? |
| koka-lang | No [^2] | Multi-shot | Yes | No (language built-in) | Yes | continuation-based | ? |
| OCaml-lang 5 | ? | One-shot | No [^3] | No (language built-in) | ? | continuation-based? | ? |
[^2]: https://gist.github.com/ymdryo/6fb2f7f4020c6fcda98ccc67c090dc75
[^3]: Effects do not appear in the type signature and can potentially cause unhandled errors at runtime
@ -208,6 +218,16 @@ Examples with explanations in Japanese can be found in the [docs-ja/examples/](h
Heftia can simply be described as a higher-order version of freer-simple.
This is indeed true in terms of its internal mechanisms as well.
Additionally, this library provides a consistent *continuation-based* semantics that is independent of carriers and effects.
On the other hand, in libraries like in-other-words, mtl, and fused-effects, the semantics of the code depend on the effect and, in part, the carrier inferred by type inference.
Fixing the semantics to a *continuation-based* model helps improve the predictability of the behavior (interpretation result) of the code.
In situations where types are implicit, this may lead to unexpected behavior for the code reader.
Particularly, attention should be given to the fact that due to type inference, semantic changes may propagate beyond the blocks enclosed by `interpret` or `interpose`.
In the case of carrier-independent semantics, especially with Freer-based effects, `interpret` and `interpose` do not alter the semantics by intervening in type inference or instance resolution of the carrier.
Instead, they function as traditional functions, simply transforming the content of the data structure.
This results in minimal surprise to the mental model of the code reader.
### Compatibility with other libraries
#### Representation of effects
* Heftia Effects relies on [data-effects](https://github.com/sayo-hs/data-effects) for the definitions of standard effects such as `Reader`, `Writer`, and `State`.