22
33[ ![ Latest release] ( http://img.shields.io/github/release/purescript/purescript-effect.svg )] ( https://github.com/purescript/purescript-effect/releases )
44[ ![ Build status] ( https://github.com/purescript/purescript-effect/workflows/CI/badge.svg?branch=master )] ( https://github.com/purescript/purescript-effect/actions?query=workflow%3ACI+branch%3Amaster )
5+ [ ![ Pursuit] ( https://pursuit.purescript.org/packages/purescript-effect/badge )] ( https://pursuit.purescript.org/packages/purescript-effect )
56
67The ` Effect ` monad, for handling native side effects.
78
@@ -18,17 +19,17 @@ the standard type PureScript uses to handle "native" effects, i.e. effects
1819which are provided by the runtime system, and which cannot be emulated by pure
1920functions. Some examples of native effects are:
2021
21- * Console IO
22- * Random number generation
23- * Exceptions
24- * Reading/writing mutable state
22+ - Console IO
23+ - Random number generation
24+ - Exceptions
25+ - Reading/writing mutable state
2526
2627And in the browser:
2728
28- * DOM manipulation
29- * XMLHttpRequest / AJAX calls
30- * Interacting with a websocket
31- * Writing/reading to/from local storage
29+ - DOM manipulation
30+ - XMLHttpRequest / AJAX calls
31+ - Interacting with a websocket
32+ - Writing/reading to/from local storage
3233
3334All of these things may be represented in PureScript by the ` Effect ` type.
3435A value of the type ` Effect a ` represents a computation which may perform
@@ -122,12 +123,12 @@ and in the corresponding JavaScript module:
122123
123124``` javascript
124125// Counter.js
125- exports .incrCounter = function () {
126+ exports .incrCounter = function () {
126127 if (! window .globalCounter ) {
127128 window .globalCounter = 0 ;
128129 }
129130 return ++ window .globalCounter ;
130- }
131+ };
131132```
132133
133134For more information about the FFI (Foreign Function Interface), see
@@ -149,16 +150,19 @@ compiler produces the following JavaScript:
149150
150151``` javascript
151152var printRandom = function __do () {
152- var $0 = Effect_Random .random ();
153- return Effect_Console .log (Data_Show .show (Data_Show .showNumber )($0))();
153+ var $0 = Effect_Random .random ();
154+ return Effect_Console .log (Data_Show .show (Data_Show .showNumber )($0))();
154155};
155156```
156157
157158whereas a more naive compiler might, for instance, produce:
159+
158160``` javascript
159- var printRandom = Control_Bind .bind (Effect .bindEffect )(Effect_Random .random )(function ($0 ) {
161+ var printRandom = Control_Bind .bind (Effect .bindEffect )(Effect_Random .random )(
162+ function ($0 ) {
160163 return Effect_Console .log (Data_Show .show (Data_Show .showNumber )($0));
161- });
164+ }
165+ );
162166```
163167
164168While this is a small improvement, the benefit is greater when using
0 commit comments