ericelliott / ericelliott/rtype
rtype --> predicate parser/compiler
- Dominant language
- JavaScript
- Stars
- 1.1k
- Forks
- 38
- PR merge metrics
- No merged PRs in 30d
Description
Write a function that takes an rtype interface description as a string and returns an object that can be used for runtime type checking.
``` js
interface TypeChecker {
checkInputs: Predicate,
checkOutput: Predicate,
checkError: Predicate
}
parseSignature(signature: String) => TypeChecker
```
The target function will get wrapped by a utility such as [rfx](https://github.com/ericelliott/rfx). When the wrapper function gets called, it will pass inputs to `checkInputs()`. If it returns true, only then does the original function get called. When the function returns, its output will be similarly checked by `checkOutput()` before it gets returned to the original caller. If the function throws, the error will also be checked, by `checkError()`.
Useful background:
- [How to Build a Compiler](https://www.youtube.com/watch?v=Tar4WgAfMr4) Great video by James Kyle
- [How to Build a Compiler source](https://github.com/thejameskyle/the-super-tiny-compiler) Source companion to the James Kyle video
- The [Stanford Compilers course](https://www.coursera.org/course/compilers) (free online lectures)
If you're curious about types, see the [introduction to types](https://class.coursera.org/compilers/lecture/45) from the Stanford Compiler course.
## Contributing
Start with unit tests, please. See [Why I Use Tape Instead of Mocha & So Should You](https://medium.com/javascript-scene/why-i-use-tape-instead-of-mocha-so-should-you-6aa105d8eaf4) & [Five Questions Every Unit Test Must Answer](https://medium.com/javascript-scene/what-every-unit-test-needs-f6cd34d9836d) for guidance on how to write a good unit test suite.
Related issues:
- https://github.com/ericelliott/rtype/issues/46
- https://github.com/ericelliott/rtype/issues/47
- https://github.com/ericelliott/rtype/pull/61
- https://github.com/ericelliott/rtype/pull/42
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the parseSignature(signature) contract and writing unit tests, as requested in the issue. Review related issues #46 and #47 and prior pull requests #61 and #42 to understand the intended rtype syntax and behavior. Done means the parser returns a TypeChecker with input, output, and error predicates that enforce the described checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100