{"id":19094422,"url":"https://github.com/risto-stevcev/do-notation","last_synced_at":"2025-04-30T13:03:18.006Z","repository":{"id":57213745,"uuid":"52926152","full_name":"Risto-Stevcev/do-notation","owner":"Risto-Stevcev","description":":arrow_left: Do notation for Fantasy Land monad types","archived":false,"fork":false,"pushed_at":"2016-04-18T13:36:47.000Z","size":7,"stargazers_count":12,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-31T03:52:03.072Z","etag":null,"topics":["do","do-notation","fantasy-land","monad","notation","sugar"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/do-notation","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Risto-Stevcev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-02T02:15:28.000Z","updated_at":"2020-11-13T10:23:52.000Z","dependencies_parsed_at":"2022-08-29T02:10:37.339Z","dependency_job_id":null,"html_url":"https://github.com/Risto-Stevcev/do-notation","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Risto-Stevcev%2Fdo-notation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Risto-Stevcev%2Fdo-notation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Risto-Stevcev%2Fdo-notation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Risto-Stevcev%2Fdo-notation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Risto-Stevcev","download_url":"https://codeload.github.com/Risto-Stevcev/do-notation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223782084,"owners_count":17201722,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["do","do-notation","fantasy-land","monad","notation","sugar"],"created_at":"2024-11-09T03:29:03.363Z","updated_at":"2024-11-09T03:29:04.051Z","avatar_url":"https://github.com/Risto-Stevcev.png","language":"JavaScript","readme":"# Do Notation\n\n[![Build Status](https://travis-ci.org/Risto-Stevcev/do-notation.svg)](https://travis-ci.org/Risto-Stevcev/do-notation)\n[![Coverage Status](https://coveralls.io/repos/github/Risto-Stevcev/do-notation/badge.svg?branch=master)](https://coveralls.io/github/Risto-Stevcev/do-notation?branch=master)\n\nDo notation for Fantasy Land monad types.\n\n[![Fantasy Land](https://github.com/fantasyland/fantasy-land/raw/master/logo.png)](https://github.com/fantasyland/fantasy-land/)\n\n\n## Examples\n\nIt uses `yield` to \"unbox\" the Monad (the `\u003c-` in Haskell), which can then be transformed and fed to the next Monad in the `Do` block. The `Do` function returns the last Monad in the `Do` block:\n\n```js\nconst Do = require('do-notation')\n\nlet maybeString = Do(function*() {\n  let foo = yield S.Maybe.of('foo')\n  console.log(foo)\n  // 'foo'\n\n  let bar = yield S.Maybe.of('bar' + foo)\n  console.log(bar)\n  // 'barfoo'\n\n  let baz = yield S.Maybe.of('baz' + bar)\n  console.log(baz)\n  // 'bazbarfoo'\n\n}).toString()\n\nconsole.log(maybeString)\n// 'Just(\"bazbarfoo\")'\n```\n\n\n## Implementation\n\nThe entire implementation is very succinct and simple:\n\n```js\nDo = function(generatorFunction) {\n  const generator = generatorFunction()\n\n  return function next(error, v) {\n    const res = generator.next(v)\n\n    if (res.done)\n      return res.value\n    else\n      return res.value.chain((v) =\u003e next(null, v) || res.value.of(v))\n  }()\n}\n\nmodule.exports = { Do: Do }\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fristo-stevcev%2Fdo-notation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fristo-stevcev%2Fdo-notation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fristo-stevcev%2Fdo-notation/lists"}