newbi question again Well, here I go again… I foun...
# arrow
e
newbi question again Well, here I go again… I found pretty good this blog to understand monads and functors, etc. https://medium.com/beingprofessional/understanding-functor-and-monad-with-a-bag-of-peanuts-8fa702b3f69e But I am not sure if kotlin
map
6
flatMap
is just the same as explained there?
b
Are you talking about these implementations?
Copy code
def map[B](f: A => B): Bag[B] = Bag(f(content))
def flatMap[B](f: A => Bag[B]): Bag[B] = f(content)
e
… I think so,
b
maybe this can help you I think it still a map from Bag[A] to Bag[B] - https://stackoverflow.com/questions/18531887/explanation-of-scala-map-function-signature
r
Those are in arrow
Functor.map
and
Monad.flatMap
which have concrete implementations in most data types
t
Typeclassopedia should be the goto reference for understanding monads and functors.
p
@earroyoron arrow is a collection of data types (classes) and interfaces (behaviors). One of those behaviors is map, the other is flatMap. That behavior is implemented for most classes, including List, Map, IO, Reader, Observable, NonEmptyList, Function0, Day…tens of them.
🔝 1
the simplest data type is Id
I suggest you look at the implementation
once you are confident with it, move to Option
and to NonEmptyList
Option is either Some or None, while NEL is a set of values. That’s one of the classifications of data types, those who grow on alternatives and others that grown on size.