File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,31 @@ so we have included some useful features to make your life easier:
28
28
- [ Do notation] ( https://dry-monads.readthedocs.io/en/latest/pages/do-notation.html )
29
29
30
30
31
+ ## Example
32
+
33
+
34
+ ``` python
35
+ from dry_monads.do_notation import do_notation
36
+ from dry_monads.either import Result, Success, Failure
37
+
38
+ class CreateAccountAndUser (object ):
39
+ """ Creates new Account-User pair."""
40
+
41
+ @do_notation
42
+ def __call__ (self , username : str , email : str ) -> Result[' User' , str ]:
43
+ """ Can return a Success(user) or Failure(str_reason)."""
44
+ user_schema = self ._validate_user(username, email).unwrap()
45
+ account = self ._create_account(user_schema).unwrap()
46
+ return self ._create_user(account)
47
+
48
+ # Protected methods
49
+ # def _validate_user()
50
+ # ...
51
+
52
+ ```
53
+
54
+ We are [ covering what's going on in this example] ( https://dry-monads.readthedocs.io/en/latest/pages/do-notation.html ) in the docs.
55
+
31
56
## Inspirations
32
57
33
58
This module is heavily based on:
You can’t perform that action at this time.
0 commit comments