Functional programming - Functors - Some more intuition
As additional support for my previous post on functors, I want to throw in this less technical example.
As you can see in the drawing, we have the following:
- A little world of transformations between things (currencies), called "Category of currencies"
- Another little world of transformations between things (feelings), called "Category of feelings"
- "f" and "g" are just generic names for transformations (give them any meaning you want.)
The point is that a functor is a sort of "meta" transformation.
It transforms a category into another category, i.e. a world of transformations into another world of transformations, in a way that makes sense.
What do I mean by "in a way that makes sense"?
In the drawing, all those fat horizontal arrows in the middle are doing the meta transformation. I.e. they're putting each object and transformation in the right place.
For example, we see that:
- BTC gets mapped to happy feeling.
- USD gets mapped to neutral/meh feeling.
In light of that, it makes sense that "f" (which goes from BTC to USD), gets transformed into a function from happy feeling to neutral/meh feeling.
Of course, saying "it makes sense" is a hand-wavy thing. The mathematical definition of functor is actually precise. But I'm just giving you some more intuition. I hope it helps!
Go here https://steemit.com/@a-a-a to get your post resteemed to over 72,000 followers.
Congratulations @noriega! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Award for the number of upvotes
Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word
STOP
Excellent submission.
RE: Your Post
I like to think of the invisible mechanics within the "black box" in between the lambda and the output is akin to the superposition space in quantum physics, or the universe of probabilities in between the Hadamard and output in QCL; that is, it is infinite, "it is what it is", and it JUST WORKS!
Trying to open that black box screws everything up, nullifies the experiment (or function), and effectively negates the whole process.
Why?
Because if you look into the box, the observation changes the result; it forces all the infinite possibilities to collapse into a single result (a la Schrödinger's cat).
Thanks for the cool analogy.
Namaste, Jaichai
Ah, that makes sense indeed. Interesting!
Cheers! :)
Nice post :). Not sure if that functor maps into my emotion. : P
Thank you! Hahah point taken
Hi @noriega!
Your post was upvoted by utopian.io in cooperation with steemstem - supporting knowledge, innovation and technological advancement on the Steem Blockchain.
Contribute to Open Source with utopian.io
Learn how to contribute on our website and join the new open source economy.
Want to chat? Join the Utopian Community on Discord https://discord.gg/h52nFrV