1- .. Effect documentation master file, created by
2- sphinx-quickstart on Mon Dec 22 12:01:30 2014.
3- You can adapt this file completely to your liking, but it should at least
4- contain the root `toctree` directive.
5-
61Effect
72======
83
@@ -53,16 +48,16 @@ simple objects with public attributes and no behavior, only data.
5348.. code :: python
5449
5550 class ReadLine (object ):
56- def __init__ (self , prompt ):
57- self .prompt = prompt
51+ def __init__ (self , prompt ):
52+ self .prompt = prompt
5853
5954 To perform the ReadLine intent, we must implement a performer function:
6055
6156.. code :: python
6257
6358 @sync_performer
6459 def perform_read_line (dispatcher , readline ):
65- return raw_input (readline.prompt)
60+ return raw_input (readline.prompt)
6661
6762
6863 To do something with the result of the effect, we must attach callbacks with
@@ -73,7 +68,7 @@ the ``on`` method:
7368 def greet ():
7469 return get_user_name().on(
7570 success = lambda r : Effect(Print(" Hello," , r)),
76- 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 ])))
7772
7873
7974 (Here we assume another intent, ``Print ``, which shows some text to the user.)
@@ -102,7 +97,7 @@ based on the intent.
10297
10398 def main ():
10499 eff = greet()
105- dispatcher = TypeDispatcher({ReadLine: perform_read_line})
100+ dispatcher = TypeDispatcher({ReadLine: perform_read_line})
106101 perform(dispatcher, effect)
107102
108103 This has a number of advantages. First, your unit tests for ``get_user_name ``
@@ -190,7 +185,7 @@ following:
190185 """
191186 Perform an HTTP request where the body is sent as JSON and the response
192187 is automatically decoded as JSON if the Content-type is
193- application/json.
188+ application/json.
194189 """
195190 str_body = json.dumps(dict_body)
196191 return request_200_url(method, url, str_body).on(success = decode_json)
0 commit comments