Skip to content

Commit da3fb95

Browse files
committed
fix a ton of indentation that got screwed up at some point
1 parent c8689b4 commit da3fb95

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

README.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,27 @@ A very quick example of using Effects:
4545
from effect import perform, sync_performer, Effect, TypeDispatcher
4646
4747
class ReadLine(object):
48-
def __init__(self, prompt):
49-
self.prompt = prompt
48+
def __init__(self, prompt):
49+
self.prompt = prompt
5050
5151
def get_user_name():
52-
return Effect(ReadLine("Enter a candy> "))
52+
return Effect(ReadLine("Enter a candy> "))
5353
5454
@sync_performer
5555
def perform_read_line(dispatcher, readline):
56-
return raw_input(readline.prompt)
56+
return raw_input(readline.prompt)
5757
5858
def main():
59-
effect = get_user_name()
60-
effect = effect.on(
61-
success=lambda result: print("I like {} too!".format(result)),
62-
error=lambda e: print("sorry, there was an error. {}".format(e)))
59+
effect = get_user_name()
60+
effect = effect.on(
61+
success=lambda result: print("I like {} too!".format(result)),
62+
error=lambda e: print("sorry, there was an error. {}".format(e)))
6363
64-
dispatcher = TypeDispatcher({ReadLine: perform_read_line})
65-
perform(dispatcher, effect)
64+
dispatcher = TypeDispatcher({ReadLine: perform_read_line})
65+
perform(dispatcher, effect)
6666
6767
if __name__ == '__main__':
68-
main()
68+
main()
6969
7070
7171
``Effect`` takes what we call an ``intent``, which is any object. The

docs/source/index.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ simple objects with public attributes and no behavior, only data.
4848
.. code:: python
4949
5050
class ReadLine(object):
51-
def __init__(self, prompt):
52-
self.prompt = prompt
51+
def __init__(self, prompt):
52+
self.prompt = prompt
5353
5454
To perform the ReadLine intent, we must implement a performer function:
5555

5656
.. code:: python
5757
5858
@sync_performer
5959
def perform_read_line(dispatcher, readline):
60-
return raw_input(readline.prompt)
60+
return raw_input(readline.prompt)
6161
6262
6363
To do something with the result of the effect, we must attach callbacks with
@@ -68,7 +68,7 @@ the ``on`` method:
6868
def greet():
6969
return get_user_name().on(
7070
success=lambda r: Effect(Print("Hello,", r)),
71-
error=lambda exc_info: Effect(Print("There was an error!", exc_info[1])))
71+
error=lambda exc_info: Effect(Print("There was an error!", exc_info[1])))
7272
7373
7474
(Here we assume another intent, ``Print``, which shows some text to the user.)
@@ -97,7 +97,7 @@ based on the intent.
9797
9898
def main():
9999
eff = greet()
100-
dispatcher = TypeDispatcher({ReadLine: perform_read_line})
100+
dispatcher = TypeDispatcher({ReadLine: perform_read_line})
101101
perform(dispatcher, effect)
102102
103103
This has a number of advantages. First, your unit tests for ``get_user_name``

0 commit comments

Comments
 (0)