Skip to content

mkulke/ts-monads

Folders and files

NameName
Last commit message
Last commit date

Latest commit

0b8e75e · Mar 26, 2019

History

22 Commits
Mar 26, 2019
Mar 26, 2019
May 1, 2018
Mar 26, 2019
Mar 26, 2019
Mar 26, 2019
May 14, 2018
May 14, 2018
May 14, 2018
May 14, 2018
Nov 24, 2018
Nov 24, 2018
May 20, 2018
May 20, 2018
May 14, 2018
May 14, 2018
Mar 26, 2019
Nov 24, 2018
Mar 26, 2019

Repository files navigation

ts-monads

  • several monads, written in typescript
  • very barebone, for exploration around types
  • do not use for anything
  • maybe, list, result, future, reader & state

install & compile

npm i
$(npm bin)/tsc

usage

import { Future, map, flatMap, fork } from './future';

const one: Future<Error, number> = (_rej, res) => {
  setTimeout(() => res(10), 1000);
});

const byThree = (val: number): Future<Error, number> =>
  (_rej, res) => {
    setTimeout(() => res(val * 3), 300);
  };

const two = map(x => x * 2, one);
const three = flatMap(byThree, two);
fork(console.error, console.log, three);

examples

state

node dist/examples/mining.js

reader

provide request context in web service layers via reader monad and iterator functions.

node dist/examples/server.js
curl "http://localhost:3000?number=9" -H "X-Cid: 123"

test

find dist/*Spec.js -exec node {} \;

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published