r/functionalprogramming • u/daedaluscommunity • May 31 '25
Intro to FP My Attempt at a Monad Explainer
https://www.youtube.com/watch?v=X4LSPH-NGLc&list=PLm3B56ql_akOkilkOByPFYu3HitCgfU9p
24
Upvotes
View all comments
Show parent comment
-2
u/daedaluscommunity May 31 '25
For the cartesian product thing, think of A×B as "the set of all pairs (a,b) such that a is an element of A, and b is an element of B".
So, a function (int × int) → int is just one that takes a pair of integers (a,b) and returns a single integer. Nothing too deep.
When I say int×int ~ Z×Z "modulo finitude", I simply mean that the set of pairs of elements of type int is kinda the same as the pairs of elements of pairs of actual integer numbers, with the exception that machine integers are finitely many, whereas there are infinitely many actual integer numbers.
"modulo ..." here is just a fancy way of saying "without taking into account ...". My bad for not being very clear there.
As for the collection of all types, which I called "Type" in the video, you can think of it as a set containing all possible types:
{int, int × int, int → int, List<int>, float, .....}
(Mathematically, it's wrong to call it a set, for weird ass math reasons... But that's the intuition.)
Therefore, the List type constructor is a function that takes an element t of Type (i.e. a type t) and returns the type of lists List<t>.
As an example, if you pass the type int to List, you get List<int>.
As for the crappiness, I don't really think that notation is crap, it's just kind of a running gag on my channel that I sometimes tease java devs..