Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kongware/scriptum
Functional Programming Unorthodoxly Adjusted to Client-/Server-side Javascript
https://github.com/kongware/scriptum
algebraic-data-types anamorphism catamorphism composition corecursion folding function-composition functional-programming javascript lazyness monad monad-transformers point-free polymorphism pure-function purity recursion sum-types tagged-unions transducers
Last synced: 3 months ago
JSON representation
Functional Programming Unorthodoxly Adjusted to Client-/Server-side Javascript
- Host: GitHub
- URL: https://github.com/kongware/scriptum
- Owner: kongware
- License: mit
- Created: 2018-02-21T16:57:59.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-29T08:47:49.000Z (3 months ago)
- Last Synced: 2024-10-29T09:58:48.008Z (3 months ago)
- Topics: algebraic-data-types, anamorphism, catamorphism, composition, corecursion, folding, function-composition, functional-programming, javascript, lazyness, monad, monad-transformers, point-free, polymorphism, pure-function, purity, recursion, sum-types, tagged-unions, transducers
- Language: JavaScript
- Homepage:
- Size: 4.52 MB
- Stars: 384
- Watchers: 15
- Forks: 21
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
```
___ ___ ___ ___ ___ ___ ___
/\ \ /\ \ /\ \ ___ /\ \ /\ \ /\__\ /\__\
/::\ \ /::\ \ /::\ \ /\ \ /::\ \ \:\ \ /:/ / /::| |
/:/\ \ \ /:/\:\ \ /:/\:\ \ \:\ \ /:/\:\ \ \:\ \ /:/ / /:|:| |
_\:\~\ \ \ /:/ \:\ \ /::\~\:\ \ /::\__\ /::\~\:\ \ /::\ \ /:/ / ___ /:/|:|__|__
/\ \:\ \ \__\ /:/__/ \:\__\ /:/\:\ \:\__\ __/:/\/__/ /:/\:\ \:\__\ /:/\:\__\ /:/__/ /\__\ /:/ |::::\__\
\:\ \:\ \/__/ \:\ \ \/__/ \/_|::\/:/ / /\/:/ / /:/ \:\/:/ / /:/ \/__/ \:\ \ /:/ / \/__/~~/:/ /
\:\ \:\__\ \:\ \ |:|::/ / \::/__/ /:/ / \::/ / /:/ / \:\ /:/ / /:/ /
\:\/:/ / \:\ \ |:|\/__/ \:\__\ /:/ / \/__/ /:/ / \:\/:/ / /:/ /
\::/ / \:\__\ |:| | \/__/ \/__/ \/__/ \::/ / /:/ /
\/__/ \/__/ \|__| \/__/ \/__/
```# Functional Programming Unorthodoxly Adjusted to Client-/Server-side Javascript
[scriptum](https://github.com/kongware/scriptum/blob/master/scriptum.js), a functional standard library.
There are three categories of effects:
* mutations
* input/output
* control flowscriptum handles these three categories using the following concepts:
* tree-based persistent data structures (mutations)
* continuation types optimized for serial/parallel asynchronous processing (I/O)
* continuation type optimized for synchronous processing (control flow)Since I/O is asynchronous in Javascript/Node.js, the first iteration of the event loop is pure in terms of interacting with the real world. It is thus possible in the context of the event loop to implement the pure core imperative shell design pattern provided the following two requirements are met by asynchronous types:
* they are lazy
* they are statelessWhile the native `Promise` type misses both criteria, scriptum's `Serial` and `Parallel` types are compliant.
Control flow comprises the following instances:
* short circuiting
* indeterminism (0..n iterations of evaluation)Features:
* persistent data structures based on 2-3 trees
* lazy evaluation with implicit/explicit thunks
* principled, purely functional async computation (serial/parallel)
* stack safe recursion (tail recursion, modulo cons, monad recursion)
* reification control flow using CPS and the `Cont` type
* product and variant types
* simple pattern matching
* functional `Iterator` machinery
* functional iterator type idempotent in its `next` method
* reactive programming with event streams and behaviors
* `DequeMap`, a doubly-ended queue based on a native map
* `MultiMap` to encode 1:m key/value relations
* lots of predefined type class definitions
* lots of predefined polymorphic functions
* lots of functor, applicative and monad definitions
* dynamic functorial fusion using yoneda
* static loop fusion using transducers
* flat composition syntax using `infix`
* memoization of recursive functions
* functional optics
* parser combinators
* functor composition
* let expressions
* recursion schemes
* delimited continuations
* coroutines
* tracked functions
* and much more..## Status
_unstable_
Obsolete projects:
* [in-depth functional programming course](https://github.com/kongware/scriptum/blob/7172eb77cbd494938eb3ded6ab402ee81bd23555/course/ch-001.md)
* [higher-rank/kinded runtime type validator source code](https://github.com/kongware/scriptum/blob/master/src/validator.js)
* [higher-rank/kinded runtime type validator manpage](https://github.com/kongware/scriptum/blob/7172eb77cbd494938eb3ded6ab402ee81bd23555/validator.md)## Future Studies
- [ ] probabilistic data structures
- [ ] fuzzy logic and encoding uncertainty
- [ ] separation of command and query model + event sourcing (CQRS/ES)
- [ ] software transaction memory (STM)
- [ ] strong eventual consistency (CRDTs)
- [ ] distributed applications