{"id":16897695,"url":"https://github.com/texitoi/rust-mdo","last_synced_at":"2025-04-05T15:05:42.837Z","repository":{"id":19345891,"uuid":"22585052","full_name":"TeXitoi/rust-mdo","owner":"TeXitoi","description":"Monadic do notation for rust using macro and duck typing","archived":false,"fork":false,"pushed_at":"2019-05-30T13:57:48.000Z","size":33,"stargazers_count":227,"open_issues_count":2,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-17T11:58:44.347Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"IsabelLafaia/Meetup3","license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TeXitoi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-03T22:34:45.000Z","updated_at":"2024-11-08T10:46:26.000Z","dependencies_parsed_at":"2022-09-10T22:02:12.425Z","dependency_job_id":null,"html_url":"https://github.com/TeXitoi/rust-mdo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TeXitoi%2Frust-mdo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TeXitoi%2Frust-mdo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TeXitoi%2Frust-mdo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TeXitoi%2Frust-mdo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TeXitoi","download_url":"https://codeload.github.com/TeXitoi/rust-mdo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353731,"owners_count":20925329,"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":[],"created_at":"2024-10-13T17:39:19.317Z","updated_at":"2025-04-05T15:05:42.813Z","avatar_url":"https://github.com/TeXitoi.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rust mdo [![Build Status](https://travis-ci.org/TeXitoi/rust-mdo.svg?branch=master)](https://travis-ci.org/TeXitoi/rust-mdo)\n\n## Presentation\n\nRust mdo is a monadic do notation using macros and duck typing.  It\nprovides a syntax extension providing something that looks like the\nHaskell do notation, and rewrites it using a `bind` function.  Some\nfunctions are provided for a number of common monadic structures.\n\n## Example\n\nAdd to your `Cargo.toml`:\n```toml\n[dependencies]\nmdo = \"*\"\n```\n\n```rust\n#[macro_use] extern crate mdo;\n\nfn main() {\n    // exporting the monadic functions for the Iterator monad (similar\n    // to list comprehension)\n    use mdo::iter::{bind, ret, mzero};\n\n    // getting the list of (x, y, z) such that\n    //  - 1 \u003c= x \u003c= y \u003c z \u003c 11\n    //  - x^2 + y^2 == z^2\n    let l = bind(1i32..11, move |z|\n                 bind(1..z, move |x|\n                      bind(x..z, move |y|\n                           bind(if x * x + y * y == z * z { ret(()) }\n                                else { mzero() },\n                                move |_|\n                                ret((x, y, z))\n                                )))).collect::\u003cVec\u003c_\u003e\u003e();\n    println!(\"{:?}\", l);\n\n    // the same thing, using the mdo! macro\n    let l = mdo! {\n        z =\u003c\u003c 1i32..11;\n        x =\u003c\u003c 1..z;\n        y =\u003c\u003c x..z;\n        when x * x + y * y == z * z;\n        ret ret((x, y, z))\n    }.collect::\u003cVec\u003c_\u003e\u003e();\n    println!(\"{:?}\", l);\n}\n```\n\n## Documentation\n\nYou can find the rustdoc [here](https://texitoi.eu/rust/mdo/).\n\n## Supported monads\n\nThis library provides definitions for the following monads:\n  - `Option`\n  - `Iterator`\n  - `Result` (without error conversion)\n  \nOther implementations in external crates:\n  - `Future` in [mdo-future](https://crates.io/crates/mdo-future)\n\n## License\n\nThis work is free. You can redistribute it and/or modify it under the\nterms of the Do What The Fuck You Want To Public License, Version 2,\nas published by Sam Hocevar. See the COPYING file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftexitoi%2Frust-mdo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftexitoi%2Frust-mdo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftexitoi%2Frust-mdo/lists"}