Skip to content

Commit fc0c3f3

Browse files
authored
Merge pull request #2 from lupuszr/readme-fixes
Readme and comment fixes
2 parents 5e15034 + 4e8e0d7 commit fc0c3f3

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ In our example we want to define a call service:
1313
class CallAlgebra {}
1414
```
1515

16-
Next we can meditate about the flow of our business logic. In the example we imagining a scenario
17-
where a customer wish to ask for some help from an agent. So our flow should look something like this:
16+
Next we can meditate about the flow of our business logic. In the example we imagine a scenario
17+
where a customer wishes to ask for some help from an agent. So our flow should look something like this:
1818
customerBackgroundCheck -> askForAgent -> establishCall -> endCall
1919
-> cancelCall
2020

@@ -40,7 +40,7 @@ class CallAlgebra<Customer, Agent, Call> {
4040
}
4141
```
4242

43-
As you see we are keeping our algebra pure and monadic, so we are able to chain our methods to build larger and more complex logic. For this example we are using funfix/effects but any IO implementation that support sync and async execution should work.
43+
As you see, we are keeping our algebra pure and monadic, so we are able to chain our methods to build larger and more complex logic. For this example we are using funfix/effects but any IO implementation that supports sync and async execution should work.
4444

4545
```typescript
4646
class CallAlgebra<Customer, Agent, Call> {
@@ -61,13 +61,13 @@ class CallAlgebra<Customer, Agent, Call> {
6161
}
6262
```
6363

64-
Now we have every piece to build our algebra, try play with this idea a bit and then we can move to the next step.
64+
Now we have every piece needed to build our algebra. Try to play with this idea a bit and then we can move on to the next step.
6565

6666
## 2. Provide a definition for the algebra
6767

68-
Now that we have an algebra we are ready to create an implementation for it (in FP word its called interpreter)
68+
Now that we have an algebra, we are ready to create an implementation for it (in FP word its called interpreter).
6969

70-
It is made of 2 sub steps. First we need to define our types for our algebras params and then we need to pass our methods implementation:
70+
It is made of 2 substeps. First we need to define types for the params of our algebra and then we need to pass the implementation of our methods:
7171

7272
```typescript
7373
export type Balance = {
@@ -149,7 +149,7 @@ const callAlgebraImplementation = new CallAlgebra<Customer, Agent, Call>(
149149
```
150150

151151
## 3. Connect the algebra to a react redux application.
152-
Because the IO monad is lazy and referentially transparent we can store its state in redux.
152+
Because the IO monad is lazy and referentially transparent we can store its representation as a state in redux.
153153
To make this work we need 2 reducers. One for the IO and the other one for the result of the IO.
154154

155155
```typescript
@@ -171,8 +171,7 @@ export default function ioCallReducer(state: IO<Call> = IO.of(() => initialState
171171
}
172172
```
173173

174-
As you see the reducer name starts with `io` this is a must because with this we can detect which reducers
175-
should are IO monads. Also it is important to mention that its actions should have a field target:
174+
As you see, the reducer name starts with `io`. This is a must because with this we can detect which reducers are IO monads. Also, it is important to mention that its actions should have a field `target`:
176175

177176
```typescript
178177
export const startACall: startACallT = customer => {

src/features/call/ioCallReducer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function ioCallReducer(state: IO<Call> = IO.of(() => initialState
99
return IO.of(() => initialState);
1010
}
1111
case 'startACall': {
12-
return callAlgebraImplementation.startACall(action.payload.customer); // old state does not mater
12+
return callAlgebraImplementation.startACall(action.payload.customer); // old state does not matter
1313
}
1414
case 'cancelCall': {
1515
return state.chain(call => callAlgebraImplementation.cancelCall(call));
@@ -26,4 +26,4 @@ export default function ioCallReducer(state: IO<Call> = IO.of(() => initialState
2626
default:
2727
return state;
2828
}
29-
}
29+
}

0 commit comments

Comments
 (0)