r/functionalprogramming • • 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

21 comments sorted by

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.. 

2

u/TorbenKoehn Jun 02 '25

I thank you that you're trying to explain it to me now, but remember this is in feedback to your video and I don't think you get these explanations in there easily :)

Just wanted to give you something to improve on for your next video! You got this :)

2

u/daedaluscommunity Jun 02 '25

Thanks :)

I'll try to be more careful in the next videos