From d4e2b5338cd26b636f613737bcefa48b6ff5bab9 Mon Sep 17 00:00:00 2001 From: timofey Date: Wed, 26 Apr 2023 20:34:49 +0000 Subject: [PATCH] book --- book/.gitignore | 1 + book/book.toml | 14 ++++++++++++++ book/src/SUMMARY.md | 7 +++++++ book/src/ch00/s00-introduction.md | 1 + book/src/ch01/s00-background.md | 1 + book/src/ch02/s00-implementation.md | 1 + src/func/classes/option.rs | 7 ++++--- src/func/classes/result.rs | 5 +++-- 8 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 book/.gitignore create mode 100644 book/book.toml create mode 100644 book/src/SUMMARY.md create mode 100644 book/src/ch00/s00-introduction.md create mode 100644 book/src/ch01/s00-background.md create mode 100644 book/src/ch02/s00-implementation.md diff --git a/book/.gitignore b/book/.gitignore new file mode 100644 index 0000000..7585238 --- /dev/null +++ b/book/.gitignore @@ -0,0 +1 @@ +book diff --git a/book/book.toml b/book/book.toml new file mode 100644 index 0000000..b589e48 --- /dev/null +++ b/book/book.toml @@ -0,0 +1,14 @@ +[book] +authors = ["Alisa Feistel"] +language = "en" +multilingual = false +src = "src" +title = "Monads in Rust" + +[build] +create-missing = false + +[output.html] +default-theme = "navy" +mathjax-support = true +git-repository-url = "https://gitea.parrrate.ru/PTV/radn-rs" diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md new file mode 100644 index 0000000..a754f25 --- /dev/null +++ b/book/src/SUMMARY.md @@ -0,0 +1,7 @@ +# Summary + +[Introduction](./ch00/s00-introduction.md) + +- [Background](./ch01/s00-background.md) +- [Implementation](./ch02/s00-implementation.md) +- [Usage]() diff --git a/book/src/ch00/s00-introduction.md b/book/src/ch00/s00-introduction.md new file mode 100644 index 0000000..e10b99d --- /dev/null +++ b/book/src/ch00/s00-introduction.md @@ -0,0 +1 @@ +# Introduction diff --git a/book/src/ch01/s00-background.md b/book/src/ch01/s00-background.md new file mode 100644 index 0000000..5767328 --- /dev/null +++ b/book/src/ch01/s00-background.md @@ -0,0 +1 @@ +# Background diff --git a/book/src/ch02/s00-implementation.md b/book/src/ch02/s00-implementation.md new file mode 100644 index 0000000..d2557ff --- /dev/null +++ b/book/src/ch02/s00-implementation.md @@ -0,0 +1 @@ +# Implementation diff --git a/src/func/classes/option.rs b/src/func/classes/option.rs index b37775c..6328533 100644 --- a/src/func/classes/option.rs +++ b/src/func/classes/option.rs @@ -30,8 +30,9 @@ impl Functor for OptionClass { } fn void<'a, A: 'a>(fa: Self::F<'a, A>) -> Self::F<'a, ()> - where - Self: 'a, { + where + Self: 'a, + { fa?; Self::pure(()) } @@ -138,7 +139,7 @@ impl MonadFail<()> for OptionClass { fn fail<'a, A: 'a>(_e: ()) -> Self::F<'a, A> where Self: 'a, - (): 'a { + { None } } diff --git a/src/func/classes/result.rs b/src/func/classes/result.rs index 5509e10..dcc54f9 100644 --- a/src/func/classes/result.rs +++ b/src/func/classes/result.rs @@ -33,8 +33,9 @@ impl Functor for ResultClass { } fn void<'a, A: 'a>(fa: Self::F<'a, A>) -> Self::F<'a, ()> - where - Self: 'a, { + where + Self: 'a, + { fa?; Self::pure(()) }