This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makePromiseMachine(params) { | |
let state = { | |
control: 'pending', | |
// ... other pieces of state | |
}; | |
return function (event) { | |
const control = state.control; | |
let output; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const movieSearchFsmDef = { | |
initialExtendedState: { | |
queryFieldHasChanged: false, movieQuery: '', results: null, movieTitle: null | |
}, | |
states: makeStates([ | |
START, MOVIE_QUERYING, MOVIE_SELECTION, MOVIE_SELECTION_ERROR, | |
MOVIE_DETAIL_QUERYING, MOVIE_DETAIL_SELECTION, | |
MOVIE_DETAIL_SELECTION_ERROR | |
]), | |
events: [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TOC] | |
# Introduction | |
As many before me, I have struggled (and probably continue to struggle) with the concept of monads and comonads. I reviewed a large number of tutorials presenting the concept in many different ways. I think I found a way that works for me, at least for monads, and I wanted to detail that in what follows with the hope that it will be useful for others too[^1]. | |
[^1]: Note that I am referring to monads in the context of computer science and programming. While this is obviously linked to monads in category theory, the presentation of the latter is much more abstract, and I do not deal with that here. | |
Now, I am trying to end the struggle with : |