https://github.com/awto/mfjs-core
Abstract runtime library for embedded effects compiler
https://github.com/awto/mfjs-core
Last synced: 10 months ago
JSON representation
Abstract runtime library for embedded effects compiler
- Host: GitHub
- URL: https://github.com/awto/mfjs-core
- Owner: awto
- License: mit
- Created: 2016-05-14T08:37:25.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-07-13T17:58:03.000Z (over 9 years ago)
- Last Synced: 2025-03-08T09:35:49.324Z (10 months ago)
- Language: JavaScript
- Size: 42 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mfjs-core
Library provides utilities for implementing monads with interfaces compatible
with [mfjs compiler](https://github.com/awto/mfjs-compiler).
It doesn’t implement any concrete effects but it contains tools for monads
construction used by in other libraries.
Monad is encoded in the library using simple object with a set of functions
for operations. It exports a prototype with a set of default implementations
as `MonadDict`. There are also a few transformers for definitions. They add
some common boilerplate features into concrete monad definitions.
Library stores global context with current monad definition to allow usage of
several monads within same project. There are `M.setContext`, `M.liftContext`,
`M.withContext` function to manage its value. To add context management into
some definition use `M.addContext` transformer.
Because of global context storing it is critical only single instance of the
library is loaded at the moment, for example using peer dependencies.
The generated code expects some functions to be method of monadic values.
To add default implementations to prototype of monadic value use `M.addMethods`
and `M.completePrototype` functions.
Sometime same data type may be used as monadic value of several monads, or
developer simply doesn't want to pollute some probably external type with
more prototype methods. To avoid this use `M.wrap` function.
`M.withControlByToken` transformer implements JS control operators using
special value threading through monad steps and probably ignoring or changing
behavior of some of them.
For more information about mentioned functions check [API reference](doc/api.md).
## LICENSE
License
Copyright © 2016 Vitaliy Akimov
Distributed under the terms of the The MIT License (MIT).