https://publish-01.obsidian.md/access/017fdca1a82df1fa88d36b...
https://publish-01.obsidian.md/access/017fdca1a82df1fa88d36b...
https://publish-01.obsidian.md/access/017fdca1a82df1fa88d36b...
This looks very mundane but I do think about it very mathematically as well: user interaction with a search engine. The "encode" arrow for example is very much about NLP and tokenizing, which is a functor from the "category" of natural language to the functor of "lucene tokens" which then has a functor to "lucene queries". This is of course the very mundane typing of functions as:
function parseQuery(query: NaturalLanguageString): LuceneQuery
nothing spectacular, but the abstract approach means I know I can cache/batch/precompute/distribute/pipeline/modularize it.
Similar mathematical concepts apply to all the other arrows, even if some are a bit wild (how does a search result influence a person's ideas?) But it means I can try to model the "wildness", and create say a probabilistic model to exercise and understand how my search engine actually performs (see for example click models and probabilistic graphical models)
I hope that makes sense?
edit: forgot picture link
https://redux.js.org/understanding/history-and-design/prior-...
Although Redux is like Elm, the language (Typescript or ES) make immutability hard so it doesn’t feel as natural a paradigm.
Also pragmatically calling setState from an event is just easier for small projects.
Having no side effects in JS is easy (just don't do it!) but immutability takes some effort.
React requires immutability so that if it sees the reference to an object again, it knows that it contains the same data. If it promised to work when mutating objects it would continuously need to deep search inside them to see what changed.
In JS, some array operations mutate the array, some copy it, you have to know specifically what operation you are using. In Elm, nothing mutates objects. All built in functions and functions you create will not do this.
In short - you can do (state, action) => state in any programming language, but mistakes caused by mutations are impossible in Elm by design.
Hope that makes sense.
So hopefully nobody is feeling intimidated by fancy mathy stuff. Haskell is just this cool, productive programming language.
Will it make you write code that is more optimal and yet harder to penetrate by others?
const renderer = props => <h1>Hello {props.pageName}</h1>
const Title = ReactComponent(renderer).contramap(props => { pageName: props.title })
Title.fold({ title: 'Home page' }) // <h1>Hello Home page</h1>