Collection of Free monads
Install
npm install freeky
Synopsis
Video series on Free Monads here: https://www.youtube.com/watch?v=WH5BrkzGgQY&list=PLK_hdtAJ4KqUWp5LJdLOgkD_8qKW0iAHi&index=1
Walking through our example.js
Run with node --harmony_destructuring example.js
// either Exampleconst gtZero = x > 0 ? : // cont example (cont just wraps task. prob a misnomer)const asyncGet = // do syntax works for any 1 monad. Since it's all in Free, we can use multipleconst app = Monad // some nt's to Taskconst maybeToTask = mconst contToTask = ctconst eitherToTask = mconst ioToTask = // this tells our Free.foldMap how to dispatch. We need all of them to turn into a target monad (in this case Task)const runApp = app
Custom Types
You can define your own types in Free and use them as monads. This is useful if you want to define a composable dsl or multiple interpreters for an action:
const Http = daggyconst Get Post = Http const get = const post = var myFn =
or fake it for testing:
const httpToId = m myFn
use it with other monads
const app = Monad const runApp = runApp