Wrap long README lines.
This commit is contained in:
parent
531780ccc2
commit
89f217b2a2
25
README.md
25
README.md
|
@ -1,8 +1,8 @@
|
|||
# README
|
||||
|
||||
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
|
||||
[![MIT License][]](LICENSE)
|
||||
|
||||
type-unlambda - [Unlambda](http://www.madore.org/~david/programs/unlambda) interpreter implemented in TypeScript's type system
|
||||
[Unlambda][] interpreter implemented in TypeScript's type system.
|
||||
|
||||
## Getting Started
|
||||
|
||||
|
@ -33,9 +33,11 @@ You're likely to get the following error when trying to run a program with type-
|
|||
|
||||
> Type instantiation is excessively deep and possibly infinite.ts(2589).
|
||||
|
||||
To write loops in TypeScript's type system, we have to use recursions, like we do in other purely functional programming languages. Meanwhile, we use [CPS](https://en.wikipedia.org/wiki/Continuation-passing_style) to implement continuations, which also introduces heavy recursion. However, TypeScript's type system is not meant for general purpose programming, and recursion has its limits.
|
||||
To write loops in TypeScript's type system, we have to use recursions, like we do in other purely functional
|
||||
programming languages. Meanwhile, we use [CPS][] to implement continuations, which also introduces heavy recursion.
|
||||
However, TypeScript's type system is not meant for general purpose programming, and recursion has its limits.
|
||||
|
||||
In [src/compiler/checker.ts](https://raw.githubusercontent.com/microsoft/TypeScript/release-4.1/src/compiler/checker.ts), there is a hard-coded limit for type instantiation:
|
||||
In [src/compiler/checker.ts][TSC checker], there is a hard-coded limit for type instantiation:
|
||||
|
||||
```typescript
|
||||
if (instantiationDepth === 50 || instantiationCount >= 5000000) {
|
||||
|
@ -44,6 +46,17 @@ if (instantiationDepth === 50 || instantiationCount >= 5000000) {
|
|||
}
|
||||
```
|
||||
|
||||
You may expect that there is an option somewhere that this limit can be configured, like `-ftemplate-depth=n` in gcc/clang. Unfortunately, there isn't, [and it's likely to stay that way](https://github.com/microsoft/TypeScript/pull/29602).
|
||||
You may expect that there is an option somewhere that this limit can be configured, like `-ftemplate-depth=n` in
|
||||
gcc/clang. Unfortunately, there isn't, [and it's likely to stay that way][PR 29602].
|
||||
|
||||
To workaround this limitation, we modify the code of `tsserver` or `tsc` in `node_modules` until the error no longer applies. Changing `instantiationDepth` to `1000` is sufficient to run the example above.
|
||||
To workaround this limitation, we modify the code of `tsserver` or `tsc` in `node_modules`, until the error no longer
|
||||
applies. Changing `instantiationDepth` to `1000` is sufficient to run the example above.
|
||||
|
||||
|
||||
<!-- Reference Links -->
|
||||
|
||||
[MIT License]: https://img.shields.io/badge/license-MIT-blue.svg
|
||||
[Unlambda]: http://www.madore.org/~david/programs/unlambda/
|
||||
[CPS]: https://en.wikipedia.org/wiki/Continuation-passing_style/
|
||||
[TSC checker]: https://github.com/microsoft/TypeScript/blob/v4.1.2/src/compiler/checker.ts
|
||||
[PR 29602]: https://github.com/microsoft/TypeScript/pull/29602
|
||||
|
|
Loading…
Reference in New Issue